Saturday, 3 October 2020

Avatar 2 subtitle

Avatar 2 is an upcoming movie directed by James Cameron. It is the second film in the Avatar franchise. 

Movie is planed yo release on 2021, die to covid-19 release date has not finalised yet. 

Meanwhile Avatar 3 production is going . 

Check the below link for Avatar 2 subtitle:
Link will be Updated here once movie is released. 


Friday, 17 July 2020

Git on Windows: How do you set up a mergetool?

I've tried msysGit and Git on Cygwin. Both work just fine in and of themselves and both run gitk and git-gui perfectly.

Now how the heck do I configure a mergetool? (Vimdiff works on Cygwin, but preferably I would like something a little more user-friendly for some of our Windows-loving coworkers.)


Answers:


git mergetool is fully configurable so you can pretty much chose your favourite tool.

The full documentation is here: http://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html

In brief, you can set a default mergetool by setting the user config variable merge.tool.

If the merge tool is one of the ones supported natively by it you just have to set mergetool.<tool>.path to the full path to the tool (replace <tool> by what you have configured merge.tool to be.

Otherwise, you can set mergetool.<tool>.cmd to a bit of shell to be eval'ed at runtime with the shell variables $BASE, $LOCAL, $REMOTE, $MERGED set to the appropriate files. You have to be a bit careful with the escaping whether you directly edit a config file or set the variable with the git config command.

Something like this should give the flavour of what you can do ('mymerge' is a fictional tool).

git config merge.tool mymerge
git config merge.mymerge.cmd 'mymerge.exe --base '$BASE' '$LOCAL' '$REMOTE' -o '$MERGED''

Once you've setup your favourite merge tool, it's simply a matter of running git mergetool whenever you have conflicts to resolve.

The p4merge tool from Perforce is a pretty good standalone merge tool.


Answers:


As already answered here (and here and here), mergetool is the command to configure this. For a nice graphical frontend I recommend kdiff3 (GPL).


Answers:


To follow-up on Charles Bailey's answer, here's my git setup that's using p4merge (free cross-platform 3way merge tool); tested on msys Git (Windows) install:

git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd 'p4merge.exe '$BASE' '$LOCAL' '$REMOTE' '$MERGED''

or, from a windows cmd.exe shell, the second line becomes :

git config --global mergetool.p4merge.cmd 'p4merge.exe '$BASE' '$LOCAL' '$REMOTE' '$MERGED''

The changes (relative to Charles Bailey):

  • added to global git config, i.e. valid for all git projects not just the current one
  • the custom tool config value resides in 'mergetool.[tool].cmd', not 'merge.[tool].cmd' (silly me, spent an hour troubleshooting why git kept complaining about non-existing tool)
  • added double quotes for all file names so that files with spaces can still be found by the merge tool (I tested this in msys Git from Powershell)
  • note that by default Perforce will add its installation dir to PATH, thus no need to specify full path to p4merge in the command

Download: http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools


EDIT (Feb 2014)

As pointed out by @Gregory Pakosz, latest msys git now 'natively' supports p4merge (tested on 1.8.5.2.msysgit.0).

You can display list of supported tools by running:

git mergetool --tool-help

You should see p4merge in either available or valid list. If not, please update your git.

If p4merge was listed as available, it is in your PATH and you only have to set merge.tool:

git config --global merge.tool p4merge

If it was listed as valid, you have to define mergetool.p4merge.path in addition to merge.tool:

git config --global mergetool.p4merge.path c:/Users/my-login/AppData/Local/Perforce/p4merge.exe
  • The above is an example path when p4merge was installed for the current user, not system-wide (does not need admin rights or UAC elevation)
  • Although ~ should expand to current user's home directory (so in theory the path should be ~/AppData/Local/Perforce/p4merge.exe), this did not work for me
  • Even better would have been to take advantage of an environment variable (e.g. $LOCALAPPDATA/Perforce/p4merge.exe), git does not seem to be expanding environment variables for paths (if you know how to get this working, please let me know or update this answer)

Answers:


I had to drop the extra quoting using msysGit on windows 7, not sure why.

git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd 'p4merge $BASE $LOCAL $REMOTE $MERGED'

Answers:


If you're doing this through cygwin, you may need to use cygpath:

git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd 'p4merge `cygpath -w $BASE` `cygpath -w $LOCAL` `cygpath -w $REMOTE` `cygpath -w $MERGED`'

Answers:


Under Cygwin, the only thing that worked for me is the following:

git config --global merge.tool myp4merge
git config --global mergetool.myp4merge.cmd 'p4merge.exe '$(cygpath -wla $BASE)' '$(cygpath -wla $LOCAL)' '$(cygpath -wla $REMOTE)' '$(cygpath -wla $MERGED)''
git config --global diff.tool myp4diff
git config --global difftool.myp4diff.cmd 'p4merge.exe '$(cygpath -wla $LOCAL)' '$(cygpath -wla $REMOTE)''

Also, I like to turn off the prompt message for difftool:

git config --global difftool.prompt false

Answers:


Bah, this finally worked for me (Windows 7 + Cygwin + TortoiseMerge):

In .git/config:

cmd = TortoiseMerge.exe /base:$(cygpath -d '$BASE') /theirs:$(cygpath -d '$REMOTE') /mine:$(cygpath -d '$LOCAL') /merged:$(cygpath -d '$MERGED')

Thanks to previous posters for the tip to use cygpath!


Answers:


I'm using Portable Git on WinXP (works a treat!), and needed to resolve a conflict that came up in branching. Of all the gui's I checked, KDiff3 proved to be the most transparent to use.

But I found the instructions I needed to get it working in Windows in this blog post, instructions which differ slightly from the other approaches listed here. It basically amounted to adding these lines to my .gitconfig file:

[merge]
    tool = kdiff3

[mergetool 'kdiff3']
    path = C:/YourPathToBinaryHere/KDiff3/kdiff3.exe
    keepBackup = false
    trustExitCode = false

Working nicely now!


Answers:


setting mergetool.p4merge.cmd will not work anymore since Git has started trying to support p4merge, see libexec/git-core/git-mergetool--lib.so we just need to specify the mergetool path for git,for example the p4merge:

git config --global mergetool.p4merge.path 'C:Program FilesPerforcep4merge.exe'
git config --global merge.tool p4merge

Then it will work.


Answers:


i use an app called WinMerge ( http://winmerge.org/ ) info from their manual ( http://manual.winmerge.org/CommandLine.html )

this is the bash script i use from the mergetool directive via .gitconfig

#!/bin/sh
# using winmerge with git
# replaces unix style null files with a newly created empty windows temp file

file1=$1
if [ '$file1' == '/dev/null' ] || [ '$file1' == '\.
ul' ] || [ ! -e '$file1' ]
    then 
       file1='/tmp/gitnull'
       `echo ''>$file1`
fi
file2=$2
if [ '$file2' == '/dev/null' ] || [ '$file2' == '\.
ul' ] || [ ! -e '$file2' ]
    then 
       file2='/tmp/gitnull'
       `echo ''>$file2`
fi
echo diff : $1 -- $2
'C:Program files (x86)WinMergeWinMergeU.exe' -e -ub -dl 'Base' -dr 'Mine' '$file1' '$file2'

basically the bash accounts for when the result of the diff in an empty file and creates a new temp file in the correct location.


Answers:


It seems that newer git versions support p4merge directly, so

git config --global merge.tool p4merge

should be all you need, if p4merge.exe is on your path. No need to set up cmd or path.


Answers:


For beyond compare on Windows 7

git config --global merge.tool bc3
git config --global mergetool.bc3.path 'C:Program Files (x86)Beyond Compare 3BCompare.exe'

Answers:


You may want to add these options too:

git config --global merge.tool p4mergetool
git config --global mergetool.p4merge.cmd 'p4merge $BASE $LOCAL $REMOTE $MERGED'
git config --global mergetool.p4mergetool.trustExitCode false
git config --global mergetool.keepBackup false

Also, I don't know why but the quoting and slash from Milan Gardian's answer screwed things up for me.


Answers:


If anyone wants to use gvim as their diff tool on TortoiseGit, then this is what you need to enter into the text input for the path to the external diff tool:

path	ogvim.exe -f -d -c 'wincmd R' -c 'wincmd R' -c 'wincmd h' -c 'wincmd J'

Answers:


To setup p4merge, installed using chocolatey on windows for both merge and diff, take a look here: https://gist.github.com/CamW/88e95ea8d9f0786d746a


Answers:


For IntelliJ IDEA (Community Edition) 3-way git mergetool configuration in Windows environment (~/.gitconfig)

Cygwin

[mergetool 'ideamerge']
     cmd = C:/Program\ Files\ \(x86\)/JetBrains/IntelliJ\ IDEA\ Community\ Edition\ 14.1.3/bin/idea.exe merge `cygpath -wa $LOCAL` `cygpath -wa $REMOTE` `cygpath -wa $BASE` `cygpath -wa $MERGED`
[merge]
     tool = ideamerge

Msys

[mergetool 'ideamerge']
cmd = '/c/Program\ Files\ \(x86\)/JetBrains/IntelliJ\ IDEA\ Community\ Edition\ 14.1.3/bin/idea.exe' merge `~/winpath.sh $LOCAL` `~/winpath.sh $REMOTE` `~/winpath.sh $BASE` `~/winpath.sh $MERGED`
[merge]
 tool = ideamerge

The ~/winpath.sh is to convert paths to Windows on msys and is taken from msys path conversion question on stackoverflow

#! /bin/sh                                                               

function wpath {                                                         
    if [ -z '$1' ]; then                                                 
        echo '$@'                                                        
    else                                                                 
        if [ -f '$1' ]; then                                             
            local dir=$(dirname '$1')                                    
            local fn=$(basename '$1')                                    
            echo '$(cd '$dir'; echo '$(pwd -W)/$fn')' | sed 's|/|\|g';  
        else                                                             
            if [ -d '$1' ]; then                                         
                echo '$(cd '$1'; pwd -W)' | sed 's|/|\|g';              
            else                                                         
                echo '$1' | sed 's|^/(.)/|1:\|g; s|/|\|g';          
            fi                                                           
        fi                                                               
    fi                                                                   
}                                                                        

wpath '$@' 

Answers:


If you're having problems opening p4merge from SourceTree look for you local configuration file named config under MyRepo.git and delete any merge configuration. In my case it was trying to open Meld which I just uninstalled


Answers:


I found two ways to configure 'SourceGear DiffMerge' as difftool and mergetool in github Windows.

The following commands in a Command Prompt window will update your .gitconfig to configure GIT use DiffMerge:

git config --global diff.tool diffmerge
git config --global difftool.diffmerge.cmd 'C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe  '$LOCAL' '$REMOTE''

git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmd  'C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe  -merge  -result='$MERGED' '$LOCAL' '$BASE' '$REMOTE''

[OR]

Add the following lines to your .gitconfig. This file should be in your home directory in C:UsersUserName:

[diff]
    tool = diffmerge
[difftool 'diffmerge']
    cmd = C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe '$LOCAL' '$REMOTE'

[merge]
    tool = diffmerge
[mergetool 'diffmerge']
    trustExitCode = true
    cmd = C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe -merge -result='$MERGED' '$LOCAL' '$BASE' '$REMOTE'

Answers:


For kdiff3 you can use:

git config --global merge.tool kdiff3
git config --global mergetool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe"
git config --global mergetool.kdiff3.trustExitCode false

git config --global diff.guitool kdiff3
git config --global difftool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe"
git config --global difftool.kdiff3.trustExitCode false

Answers:


SVG Positioning

I'm having a play with SVG and am having a few problems with positioning. I have a series of shapes which are contained in the g group tag. I was hoping to use it like a container, so I could set its x position and then all the elements in that group would also move. But that doesn't seem to be possible.

  1. How do most people go about positioning a group of elements which you wish to move in tandem?
  2. Is there any concept of relative positioning? e.g. relative to its parent

Answers:


Everything in the g element is positioned relative to the current transform matrix.

To move the content, just put the transformation in the g element:

<g transform='translate(20,2.5) rotate(10)'>
    <rect x='0' y='0' width='60' height='10'/>
</g>

Links: Example from the SVG 1.1 spec


Answers:


As mentioned in the other comment, the transform attribute on the g element is what you want. Use transform='translate(x,y)' to move the g around and things within the g will move in relation to the g.


Answers:


There is a shorter alternative to the previous answer. SVG Elements can also be grouped by nesting svg elements:

<svg xmlns='http://www.w3.org/2000/svg'
  xmlns:xlink='http://www.w3.org/1999/xlink'>
  <svg x='10'>
    <rect x='10' y='10' height='100' width='100' style='stroke:#ff0000;fill: #0000ff'/>
  </svg>
  <svg x='200'>
    <rect x='10' y='10' height='100' width='100' style='stroke:#009900;fill: #00cc00'/>
  </svg>
</svg>

The two rectangles are identical (apart from the colors), but the parent svg elements have different x values.

See http://tutorials.jenkov.com/svg/svg-element.html.


Answers:


There are two ways to group multiple SVG shapes and position the group:

The first to use <g> with transform attribute as Aaron wrote. But you can't just use a x attribute on the <g> element.

The other way is to use nested <svg> element.

<svg id='parent'>
   <svg id='group1' x='10'>
      <!-- some shapes -->
   </svg>
</svg>

In this way, the #group1 svg is nested in #parent, and the x=10 is relative to the parent svg. However, you can't use transform attribute on <svg> element, which is quite the contrary of <g> element.


Answers:


I know this is old but neither an <svg> group tag nor a <g> fixed the issue I was facing. I needed to adjust the y position of a tag which also had animation on it.

The solution was to use both the and tag together:

<svg y="1190" x="235">
   <g class="light-1">
     <path />
   </g>
</svg>

Answers:


What is a stored procedure?

What is a 'stored procedure' and how do they work?

What is the make-up of a stored procedure (things each must have to be a stored procedure)?


Answers:


Generally, a stored procedure is a 'SQL Function.' They have:

-- a name
CREATE PROCEDURE spGetPerson
-- parameters
CREATE PROCEDURE spGetPerson(@PersonID int)
-- a body
CREATE PROCEDURE spGetPerson(@PersonID int)
AS
SELECT FirstName, LastName ....
FROM People
WHERE PersonID = @PersonID

This is a T-SQL focused example. Stored procedures can execute most SQL statements, return scalar and table-based values, and are considered to be more secure because they prevent SQL injection attacks.


Answers:


Stored procedures are a batch of SQL statements that can be executed in a couple of ways. Most major DBMs support stored procedures; however, not all do. You will need to verify with your particular DBMS help documentation for specifics. As I am most familiar with SQL Server I will use that as my samples.

To create a stored procedure the syntax is fairly simple:

CREATE PROCEDURE <owner>.<procedure name>

     <Param> <datatype>

AS

     <Body>

So for example:

CREATE PROCEDURE Users_GetUserInfo

    @login nvarchar(30)=null

AS

    SELECT * from [Users]
    WHERE ISNULL(@login,login)=login

A benefit of stored procedures is that you can centralize data access logic into a single place that is then easy for DBA's to optimize. Stored procedures also have a security benefit in that you can grant execute rights to a stored procedure but the user will not need to have read/write permissions on the underlying tables. This is a good first step against SQL injection.

Stored procedures do come with downsides, basically the maintenance associated with your basic CRUD operation. Let's say for each table you have an Insert, Update, Delete and at least one select based on the primary key, that means each table will have 4 procedures. Now take a decent size database of 400 tables, and you have 1600 procedures! And that's assuming you don't have duplicates which you probably will.

This is where using an ORM or some other method to auto generate your basic CRUD operations has a ton of merit.


Answers:


A stored procedure is a set of precompiled SQL statements that are used to perform a special task.

Example: If I have an Employee table

Employee ID  Name       Age  Mobile
---------------------------------------
001          Sidheswar  25   9938885469
002          Pritish    32   9178542436

First I am retrieving the Employee table:

Create Procedure Employee details
As
Begin
    Select * from Employee
End

To run the procedure on SQL Server:

Execute   Employee details

--- (Employee details is a user defined name, give a name as you want)

Then second, I am inserting the value into the Employee Table

Create Procedure employee_insert
    (@EmployeeID int, @Name Varchar(30), @Age int, @Mobile int)
As
Begin
    Insert Into Employee
    Values (@EmployeeID, @Name, @Age, @Mobile)
End

To run the parametrized procedure on SQL Server:

Execute employee_insert 003,’xyz’,27,1234567890

  --(Parameter size must be same as declared column size)

Example: @Name Varchar(30)

In the Employee table the Name column's size must be varchar(30).


Answers:


A stored procedure is mainly used to perform certain tasks on a database. For example

  • Get database result sets from some business logic on data.
  • Execute multiple database operations in a single call.
  • Used to migrate data from one table to another table.
  • Can be called for other programming languages, like Java.

Answers:


A stored procedure is used to retrieve data, modify data, and delete data in database table. You don't need to write a whole SQL command each time you want to insert, update or delete data in an SQL database.


Answers:


A stored procedure is a named collection of SQL statements and procedural logic i.e, compiled, verified and stored in the server database. A stored procedure is typically treated like other database objects and controlled through server security mechanism.


Answers:


A stored procedure is a group of SQL statements that has been created and stored in the database. A stored procedure will accept input parameters so that a single procedure can be used over the network by several clients using different input data. A stored procedures will reduce network traffic and increase the performance. If we modify a stored procedure all the clients will get the updated stored procedure.

Sample of creating a stored procedure

CREATE PROCEDURE test_display
AS
    SELECT FirstName, LastName
    FROM tb_test;

EXEC test_display;

Advantages of using stored procedures

  • A stored procedure allows modular programming.

    You can create the procedure once, store it in the database, and call it any number of times in your program.

  • A stored procedure allows faster execution.

    If the operation requires a large amount of SQL code that is performed repetitively, stored procedures can be faster. They are parsed and optimized when they are first executed, and a compiled version of the stored procedure remains in a memory cache for later use. This means the stored procedure does not need to be reparsed and reoptimized with each use, resulting in much faster execution times.

  • A stored procedure can reduce network traffic.

    An operation requiring hundreds of lines of Transact-SQL code can be performed through a single statement that executes the code in a procedure, rather than by sending hundreds of lines of code over the network.

  • Stored procedures provide better security to your data

    Users can be granted permission to execute a stored procedure even if they do not have permission to execute the procedure's statements directly.

    In SQL Server we have different types of stored procedures:

    • System stored procedures
    • User-defined stored procedures
    • Extended stored Procedures
  • System-stored procedures are stored in the master database and these start with a sp_ prefix. These procedures can be used to perform a variety of tasks to support SQL Server functions for external application calls in the system tables

    Example: sp_helptext [StoredProcedure_Name]

  • User-defined stored procedures are usually stored in a user database and are typically designed to complete the tasks in the user database. While coding these procedures don’t use the sp_ prefix because if we use the sp_ prefix first, it will check the master database, and then it comes to user defined database.

  • Extended stored procedures are the procedures that call functions from DLL files. Nowadays, extended stored procedures are deprecated for the reason it would be better to avoid using extended stored procedures.


Answers:


A stored procedure is nothing but a group of SQL statements compiled into a single execution plan.

  1. Create once time and call it n number of times
  2. It reduces the network traffic

Example: creating a stored procedure

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE GetEmployee
      @EmployeeID int = 0
AS
BEGIN
      SET NOCOUNT ON;

      SELECT FirstName, LastName, BirthDate, City, Country
      FROM Employees 
      WHERE EmployeeID = @EmployeeID
END
GO

Alter or modify a stored procedure:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE GetEmployee
      @EmployeeID int = 0
AS
BEGIN
    SET NOCOUNT ON;

    SELECT FirstName, LastName, BirthDate, City, Country
    FROM Employees 
    WHERE EmployeeID = @EmployeeID
END
GO

Drop or delete a stored procedure:

DROP PROCEDURE GetEmployee

Answers:


Think of a situation like this,

  • You have a database with data.
  • There are a number of different applications needed to access that central database, and in the future some new applications too.
  • If you are going to insert the inline database queries to access the central database, inside each application's code individually, then probably you have to duplicate the same query again and again inside different applications' code.
  • In that kind of a situation, you can use stored procedures (SPs). With stored procedures, you are writing number of common queries (procedures) and store them with the central database.
  • Now the duplication of work will never happen as before and the data access and the maintenance will be done centrally.

NOTE:

  • In the above situation, you may wonder 'Why cannot we introduce a central data access server to interact with all the applications? Yes. That will be a possible alternative. But,
  • The main advantage with SPs over that approach is, unlike your data-access-code with inline queries, SPs are pre-compiled statements, so they will execute faster. And communication costs (over networks) will be at a minimum.
  • Opposite to that, SPs will add some more load to the database server. If that would be a concern according to the situation, a centralized data access server with inline queries will be a better choice.

Answers:


  • A stored procedure is a precompiled set of one or more SQL statements which perform some specific task.

  • A stored procedure should be executed stand alone using EXEC

  • A stored procedure can return multiple parameters

  • A stored procedure can be used to implement transact


Answers:


In a DBMS, a stored procedure is a set of SQL statements with an assigned name that's stored in the database in compiled form so that it can be shared by a number of programs.

The use of a stored procedure can be helpful in

  1. Providing a controlled access to data (end users can only enter or change data, but can't write procedures)

  2. Ensuring data integrity (data would be entered in a consistent manner) and

  3. Improves productivity (the statements of a stored procedure need to be written only once)


Answers:


'What is a stored procedure' is already answered in other posts here. What I will post is one less known way of using stored procedure. It is grouping stored procedures or numbering stored procedures.

Syntax Reference

enter image description here

; number as per this

An optional integer that is used to group procedures of the same name. These grouped procedures can be dropped together by using one DROP PROCEDURE statement

Example

CREATE Procedure FirstTest 
(
    @InputA INT
)
AS 
BEGIN
    SELECT 'A' + CONVERT(VARCHAR(10),@InputA)
END
GO

CREATE Procedure FirstTest;2
(
    @InputA INT,
    @InputB INT
)
AS 
BEGIN
    SELECT 'A' + CONVERT(VARCHAR(10),@InputA)+ CONVERT(VARCHAR(10),@InputB)
END
GO

Use

exec FirstTest 10
exec FirstTest;2 20,30

Result

enter image description here

Another Attempt

CREATE Procedure SecondTest;2
(
     @InputA INT,
    @InputB INT
)
AS 
BEGIN
    SELECT 'A' + CONVERT(VARCHAR(10),@InputA)+ CONVERT(VARCHAR(10),@InputB)
END
GO

Result

Msg 2730, Level 11, State 1, Procedure SecondTest, Line 1 [Batch Start Line 3] Cannot create procedure 'SecondTest' with a group number of 2 because a procedure with the same name and a group number of 1 does not currently exist in the database. Must execute CREATE PROCEDURE 'SecondTest';1 first.

References:

  1. CREATE PROCEDURE with the syntax for number
  2. Numbered Stored Procedures in SQL Server - techie-friendly.blogspot.com
  3. Grouping Stored Procedures - sqlmag

CAUTION

  1. After you group the procedures, you can't drop them individually.
  2. This feature may be removed in a future version of Microsoft SQL Server.

Answers:


for simple,

Stored Procedure are Stored Programs, A program/function stored into database.

Each stored program contains a body that consists of an SQL statement. This statement may be a compound statement made up of several statements separated by semicolon (;) characters.

CREATE PROCEDURE dorepeat(p1 INT)
BEGIN
  SET @x = 0;
  REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
END;

Answers:


Stored procedures in SQL Server can accept input parameters and return multiple values of output parameters; in SQL Server, stored procedures program statements to perform operations in the database and return a status value to a calling procedure or batch.

The benefits of using stored procedures in SQL Server

They allow modular programming. They allow faster execution. They can reduce network traffic. They can be used as a security mechanism.

Here is an example of a stored procedure that takes a parameter, executes a query and return a result. Specifically, the stored procedure accepts the BusinessEntityID as a parameter and uses this to match the primary key of the HumanResources.Employee table to return the requested employee.

> create procedure HumanResources.uspFindEmployee    `*<<<---Store procedure name`*
@businessEntityID                                     `<<<----parameter`
as
begin
SET NOCOUNT ON;
Select businessEntityId,              <<<----select statement to return one employee row
NationalIdNumber,
LoginID,
JobTitle,
HireData,
From HumanResources.Employee
where businessEntityId =@businessEntityId     <<<---parameter used as criteria
end

I learned this from essential.com...it is very useful.


Answers:


Stored Procedure will help you to make code in server.You can pass parameters and find output.

create procedure_name (para1 int,para2 decimal)
as
select * from TableName

Answers:


In Stored Procedures statements are written only once and reduces network traffic between clients and servers. We can also avoid Sql Injection Attacks.

  • Incase if you are using a third party program in your application for processing payments, here database should only expose the information it needed and activity that this third party has been authorized, by this we can achieve data confidentiality by setting permissions using Stored Procedures.
  • The updation of table should only done to the table it is targeting but it shouldn't update any other table, by which we can achieve data integrity using transaction processing and error handling.
  • If you want to return one or more items with a data type then it is better to use an output parameter.
  • In Stored Procedures, we use an output parameter for anything that needs to be returned. If you want to return only one item with only an integer data type then better use a return value. Actually the return value is only to inform success or failure of the Stored Procedure.

Answers:


Preface: In 1992 the SQL92 standard was created and was popularised by the Firebase DB. This standard introduced the 'Stored Procedure'.

** Passthrough Query: A string (normally concatenated programatically) that evaluates to a syntactically correct SQL statement, normally generated at the server tier (in languages such as PHP, Python, PERL etc). These statements are then passed onto the database. **

** Trigger: a piece of code designed to fire in response to a database event (typically a DML event) often used for enforcing data integrity. **

The best way to explain what a stored procedure is, is to explain the legacy way of executing DB logic (ie not using a Stored Procedure).

The legacy way of creating systems was to use a 'Passthrough Query' and possibly have triggers in the DB. Pretty much anyone who doesn't use Stored Procedures uses a thing call a 'Passthrough Query'

With the modern convention of Stored Procedures, triggers became legacy along with 'Passthrough Queries'.

The advantages of stored procedures are:

  1. They can be cached as the physical text of the Stored Procedure never changes.
  2. They have built in mechanisms against malicious SQL injection.
  3. Only the parameters need be checked for malicious SQL injection saving a lot of processor overhead.
  4. Most modern database engines actually compile Stored Procedures.
  5. They increase the degree of abstraction between tiers.
  6. They occur in the same process as the database allowing for greater optimisation and throughput.
  7. The entire workflow of the back end can be tested without client side code. (for example the Execute command in Transact SQL or the CALL command in MySQL).
  8. They can be used to enhance security because they can be leveraged to disallow the database to be accessed in a way that is inconsistent with how the system is designed to work. This is done through the database user permission mechanism. For example you can give users privileges only to EXECUTE Stored Procedures rather that SELECT, UPDATE etc privileges.
  9. No need for the DML layer associated with triggers. ** Using so much as one trigger, opens up a DML layer which is very processor intensive **

In summary when creating a new SQL database system there is no good excuse to use Passthrough Queries.

It is also noteworthy to mention that it is perfectly safe to use Stored Procedures in legacy systems that already uses triggers or Passthrough Queries; meaning that migration from legacy to Stored Procedures is very easy and such migration need not take a system down for long if at all.


Answers:


How do I fix this simple CSS floating issue in IE?

I've got four div elements floated to the left. The third div is cleared.
In Firefox and Chrome the elements are positioned as expected: The first and second divs are adjacent to each other and are above the third and fourth divs which are also adjacent to each other.
IE7 on the other hand places the fourth div adjacent to the first and second divs with the third div below.

I know I can fix it by adding a br element after the second div but I'd rather not edit the markup if I don't have to. Is there a more elegant way of fixing the problem?

I've been trying to Google for a fix for a while now but haven't found one, which is rather surprising considering how elementary the problem seems. Perhaps I'm missing something obvious, is there a reference site that lists simple CSS issues like this one or am I just ignorant about basic CSS?

Edit: I've made the sample code slightly more complex after Nazgulled "solved" the problem (see the comments). There are now four divs instead of three and the third div is cleared instead of the second.

Here is the complete source code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>IE Float Test</title>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <style type="text/css">
            div
            {
                width: 100px;
                height: 100px;
                color: white;
                font-size: 3em;
                float: left;
            }

            #divone
            {
                background-color: red;
            }

            #divtwo
            {
                background-color: blue;
            }

            #divthree
            {
                background-color: green;
                clear: both;
            }

            #divfour
            {
                background-color: purple;
            }
        </style>
    </head>
    <body>
        <div id="divone">one</div>
        <div id="divtwo">two</div>
        <div id="divthree">three</div>
        <div id="divfour">four</div>
    </body>
</html>

Here is what is looks like in Chrome:
Chrome sample

Here is what is looks like in IE7:
IE Sample


Answers:


Try adding:

display:inline-block;

in #divtwo. If that works, I would of course add some conditional commenting for IE7


Answers:


I don't know if this fixes your real problem, but I fixed your sample like this:

  • Remove the float attribute from div
  • Remove the clear attribute from #divtwo
  • Add float: left to #divtwo and #divthree

This makes it look like your chrome sample both in Firefox and IE 7 (browsers I tested).


Answers:


I am unsure what your ultimate goal is here, but I would suggest enclosing all four <div>s inside a container element and applying a width to it, then removing the clear style from #divthree. Doing it this way will allow #divthree and #divfour to move below #divone and #divtwo without clearing them:

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
    'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>

<html xmlns='http://www.w3.org/1999/xhtml' >
    <head runat='server'>
        <title>IE Float Test</title>
        <meta http-equiv='Content-Type' content='text/html;charset=utf-8' />
        <style type='text/css'>
                #divone, #divtwo, #divthree, #divfour
                {
                        width: 100px;
                        height: 100px;
                        color: white;
                        font-size: 3em;
                        float: left;
                }

                #divone
                {
                        background-color: red;
                }

                #divtwo
                {
                        background-color: blue;
                }

                #divthree
                {
                        background-color: green;
                }

                #divfour
                {
                        background-color: purple;
                }

                #container {
                        width: 200px;
                        zoom: 1;
                }
        </style>
    </head>
    <body>
    <div id='container'>
        <div id='divone'>one</div>
        <div id='divtwo'>two</div>
        <div id='divthree'>three</div>
        <div id='divfour'>four</div>
    </div>
    </body>
</html>

The zoom property on #container is necessary to avoid the IE6/7 Escaping Floats Bug.

If the above solution isn't viable, you can add a <br> or <div> after #divtwo with the style clear: left;:

<div id='divone'>one</div>
<div id='divtwo'>two</div>
<br style='clear: left;' />
<div id='divthree'>three</div>
<div id='divfour'>four</div>

This is the technique used in a floated page layout example on westciv.com.


Answers:


Several months later...

I gave up on trying to solve this problem with CSS alone. This is an IE7 bug that you cannot avoid without touching your HTML.

The ultimate application of this floating pattern was in a form, where two of the divs were input elements and the other two divs were their corresponding labels. The pattern was used multiple times in a large form and I really wanted to find an elegant CSS-only solution.

I eventually ended up using the Object Oriented CSS Framework and wrapping all the elements with additional divs in order to create the desired layout, as OOCSS dictates. It was the only way to save my soul from IE7's CSS hell and OOCSS is not so bad once you complete your initial layout.


In truth, the general answer is that this is the sort of question you pose when you don't really know what you're doing with CSS. If you have to create a complex layout once in a blue moon then you probably don't know what you're doing; as was the case when I asked this question.

Although it is true that IE7 fails to render the CSS properly, it was also a case of mistaken scope on my part. CSS is not the ultimate layout language that a naive programmer would make it out to be and CSS is not truly independent of the structure of your HTML. Once again I've opted to take the easier way out by using the OOCSS framework when I should actually take the time to learn the fundamentals of CSS.

Alas, such is the consequence of deadlines.


Answers:


How can one change the timestamp of an old commit in Git?

The answers to How to modify existing, unpushed commits? describe a way to amend previous commit messages that haven't yet been pushed upstream. The new messages inherit the timestamps of the original commits. This seems logical, but is there a way to also re-set the times?


Answers:


Use git filter-branch with an env filter that sets GIT_AUTHOR_DATE and GIT_COMMITTER_DATE for the specific hash of the commit you're looking to fix.

This will invalidate that and all future hashes.

Example:

If you wanted to change the dates of commit 119f9ecf58069b265ab22f1f97d2b648faf932e0, you could do so with something like this:

git filter-branch --env-filter 
    'if [ $GIT_COMMIT = 119f9ecf58069b265ab22f1f97d2b648faf932e0 ]
     then
         export GIT_AUTHOR_DATE='Fri Jan 2 21:38:53 2009 -0800'
         export GIT_COMMITTER_DATE='Sat May 19 01:01:01 2007 -0700'
     fi'

Answers:


You can do an interactive rebase and choose edit for the commit whose date you would like to alter. When the rebase process stops for amending the commit you type in for instance:

git commit --amend --date='Wed Feb 16 14:00 2011 +0100'

Afterwards you continue your interactive rebase.

UPDATE (in response to the comment of studgeek): to change the commit date instead of the author date:

GIT_COMMITTER_DATE='Wed Feb 16 14:00 2011 +0100' git commit --amend

The lines above set an environment variable GIT_COMMITTER_DATE which is used in amend commit.

Everything is tested in Git Bash.


Answers:


A better way to handle all of these suggestions in one command is

LC_ALL=C GIT_COMMITTER_DATE='$(date)' git commit --amend --no-edit --date '$(date)'

This will set the last commit's commit and author date to 'right now.'


Answers:


Here is a convenient alias that changes both commit and author times of the last commit to a time accepted by date --date:

[alias]
    cd = '!d='$(date -d '$1')' && shift && GIT_COMMITTER_DATE='$d' 
            git commit --amend --date '$d''

Usage: git cd <date_arg>

Examples:

git cd now  # update the last commit time to current time
git cd '1 hour ago'  # set time to 1 hour ago

Edit: Here is a more-automated version which checks that the index is clean (no uncommitted changes) and reuses the last commit message, or fails otherwise (fool-proof):

[alias]
    cd = '!d='$(date -d '$1')' && shift && 
        git diff-index --cached --quiet HEAD --ignore-submodules -- && 
        GIT_COMMITTER_DATE='$d' git commit --amend -C HEAD --date '$d'' 
        || echo >&2 'error: date change failed: index not clean!'

Answers:


The following bash function will change the time of any commit on the current branch.

Be careful not to use if you already pushed the commit or if you use the commit in another branch.

# rewrite_commit_date(commit, date_timestamp)
#
# !! Commit has to be on the current branch, and only on the current branch !!
# 
# Usage example:
#
# 1. Set commit 0c935403 date to now:
#
#   rewrite_commit_date 0c935403
#
# 2. Set commit 0c935403 date to 1402221655:
#
#   rewrite_commit_date 0c935403 1402221655
#
rewrite_commit_date () {
    local commit='$1' date_timestamp='$2'
    local date temp_branch='temp-rebasing-branch'
    local current_branch='$(git rev-parse --abbrev-ref HEAD)'

    if [[ -z '$date_timestamp' ]]; then
        date='$(date -R)'
    else
        date='$(date -R --date '@$date_timestamp')'
    fi

    git checkout -b '$temp_branch' '$commit'
    GIT_COMMITTER_DATE='$date' git commit --amend --date '$date'
    git checkout '$current_branch'
    git rebase '$commit' --onto '$temp_branch'
    git branch -d '$temp_branch'
}

Answers:


Building on theosp's answer, I wrote a script called git-cdc (for change date commit) that I put in my PATH.

The name is important: git-xxx anywhere in your PATH allows you to type:

git xxx
# here
git cdc ... 

That script is in bash, even on Windows (since Git will be calling it from its msys environment)

#!/bin/bash
# commit
# date YYYY-mm-dd HH:MM:SS

commit='$1' datecal='$2'
temp_branch='temp-rebasing-branch'
current_branch='$(git rev-parse --abbrev-ref HEAD)'

date_timestamp=$(date -d '$datecal' +%s)
date_r=$(date -R -d '$datecal')

if [[ -z '$commit' ]]; then
    exit 0
fi

git checkout -b '$temp_branch' '$commit'
GIT_COMMITTER_DATE='$date_timestamp' GIT_AUTHOR_DATE='$date_timestamp' git commit --amend --no-edit --date '$date_r'
git checkout '$current_branch'
git rebase  --autostash --committer-date-is-author-date '$commit' --onto '$temp_branch'
git branch -d '$temp_branch'

With that, you can type:

git cdc @~ '2014-07-04 20:32:45'

That would reset author/commit date of the commit before HEAD (@~) to the specified date.

git cdc @~ '2 days ago'

That would reset author/commit date of the commit before HEAD (@~) to the same hour, but 2 days ago.


Ilya Semenov mentions in the comments:

For OS X you may also install GNU coreutils (brew install coreutils), add it to PATH (PATH='/usr/local/opt/coreutils/libexec/gnubin:$PATH') and then use '2 days ago' syntax.


Answers:


Just do git commit --amend --reset-author --no-edit. For older commits, you can do an interactive rebase and choose edit for the commit whose date you want to modify.

git rebase -i <ref>

Then amend the commit with --reset-author and --no-edit to change the author date to the current date:

git commit --amend --reset-author --no-edit

Finally continue with your interactive rebase:

git rebase --continue

Answers:


To change both the author date and the commit date:

GIT_COMMITTER_DATE='Wed Sep 23 9:40 2015 +0200' git commit --amend --date 'Wed Sep 23 9:40 2015 +0200'

Answers:


If you want to perform the accepted answer (https://stackoverflow.com/a/454750/72809) in standard Windows command line, you need the following command:

git filter-branch -f --env-filter 'if [ $GIT_COMMIT = 578e6a450ff5318981367fe1f6f2390ce60ee045 ]; then export GIT_AUTHOR_DATE='2009-10-16T16:00+03:00'; export GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE; fi'

Notes:

  • It may be possible to split the command over multiple lines (Windows supports line splitting with the carret symbol ^), but I didn't succeed.
  • You can write ISO dates, saving a lot of time finding the right day-of-week and general frustration over the order of elements.
  • If you want the Author and Committer date to be the same, you can just reference the previously set variable.

Many thanks go to a blog post by Colin Svingen. Even though his code didn't work for me, it helped me find the correct solution.


Answers:


if it is previous last commit.

git rebase  -i HEAD~2
git commit --amend --date=now

if you already push to orgin and can force use:

git push --force 

if you can't force the push and if it is pushed, you can't change the commit! .


Answers:


I wrote a script and Homebrew package for this. Super easy to install, you can find it on GitHub PotatoLabs/git-redate page.

Syntax:

git redate -c 3

You just have to run git redate and you'll be able to edit all the dates in vim of the most recent 5 commits (there's also a -c option for how many commits you want to go back, it just defaults to 5). Let me know if you have any questions, comments, or suggestions!

enter image description here


Answers:


If you want to get the exact date of another commit (say you rebase edited a commit and want it to have the date of the original pre-rebase version):

git commit --amend --date='$(git show -s --format=%ai a383243)'

This corrects the date of the HEAD commit to be exactly the date of commit a383243 (include more digits if there are ambiguities). It will also pop up an editor window so you can edit the commit message.

That's for the author date which is what you care for usually - see other answers for the committer date.


Answers:


Each commit is associated with two dates, the committer date and the author date. You can view these dates with:

git log --format=fuller

If you want to change the author date and the committer date of the last 6 commits, you can simply use an interactive rebase :

git rebase -i HEAD~6

.

pick c95a4b7 Modification 1
pick 1bc0b44 Modification 2
pick de19ad3 Modification 3
pick c110e7e Modification 4
pick 342256c Modification 5
pick 5108205 Modification 6

# Rebase eadedca..5108205 onto eadedca (6 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like 'squash', but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit

For all commits where you want to change the date, replace pick by edit (or just e), then save and quit your editor.

You can now amend each commit by specifying the author date and the committer date in ISO-8601 format:

GIT_COMMITTER_DATE='2017-10-08T09:51:07' git commit --amend --date='2017-10-08T09:51:07'

The first date is the commit date, the second one is the author date.

Then go to the next commit with :

git rebase --continue

Repeat the process until you amend all your commits. Check your progression with git status.


Answers:


There are already many great answers, but when I want to change date for multiple commits in one day or in one month, I don't find a proper answer. So I create a new script for this with explaintion, hope it will help someone:

#!/bin/bash

# change GIT_AUTHOR_DATE for commit at Thu Sep 14 13:39:41 2017 +0800
# you can change the data_match to change all commits at any date, one day or one month
# you can also do the same for GIT_COMMITTER_DATE

git filter-branch --force --env-filter '

date_match='^Thu, 14 Sep 2017 13+'              

# GIT_AUTHOR_DATE will be @1505367581 +0800, Git internal format 
author_data=$GIT_AUTHOR_DATE;                   
author_data=${author_data#@}                  
author_data=${author_data% +0800}                # author_data is 1505367581     

oneday=$((24*60*60))

# author_data_str will be 'Thu, 14 Sep 2017 13:39:41 +0800', RFC2822 format
author_data_str=`date -R -d @$author_data`      

if [[ $author_data_str =~ $date_match ]];
then
    # remove one day from author_data
    new_data_sec=$(($author_data-$oneday))
    # change to git internal format based on new_data_sec
    new_data='@$new_data_sec +0800'             
    export GIT_AUTHOR_DATE='$new_data'
fi
' --tag-name-filter cat -- --branches --tags

The date will be changed:

AuthorDate: Wed Sep 13 13:39:41 2017 +0800

Answers:


I created this npm package to change date of old commits.

https://github.com/bitriddler/git-change-date

Sample Usage:

npm install -g git-change-date
cd [your-directory]
git-change-date

You will be prompted to choose the commit you want to modify then to enter the new date.

If you want to change a commit by specific hash run this git-change-date --hash=[hash]


Answers:


git commit --amend --date='now'

Answers:


If commit not yet pushed then I can use something like that:

git commit --amend --date=' Wed Mar 25 10:05:44 2020 +0300'

after that git bash opens editor with the already applied date so you need just to save it by typing in the VI editor command mode ':wq' and you can push it


Answers:


How to Edit Multiple Commit Dates

Other answers aren't very convenient for editing several commit dates. I've come back to this question after a few years to share a technique.

To change the dates of the last 4 commits:

git rebase -i HEAD~4

Edit the rebase as follows, inserting exec lines to modify dates as needed:

pick 4ca564e Do something
exec git commit --amend --no-edit --date "1 Oct 2019 12:00:00 PDT"
pick 1670583 Add another thing
exec git commit --amend --no-edit --date "2 Oct 2019 12:00:00 PDT"
pick b54021c Add some tests
exec git commit --amend --no-edit --date "3 Oct 2019 12:00:00 PDT"
pick e8f6653 Fix the broken thing
exec git commit --amend --no-edit --date "4 Oct 2019 12:00:00 PDT"

Answers:


For those using Powershell

git rebase DESIRED_REF^ -i

$commitDateString = '2020-01-22T22:22:22'
$env:GIT_COMMITTER_DATE = $commitDateString
git commit --amend --date $commitDateString
$env:GIT_COMMITTER_DATE = ''

git rebase --continue

Credit to https://mnaoumov.wordpress.com/2012/09/23/git-change-date-of-commit/


Answers:


Set the date of the last commit to the current date

GIT_COMMITTER_DATE="$(date)" git commit --amend --no-edit --date "$(date)"

Set the date of the last commit to an arbitrary date

GIT_COMMITTER_DATE="Mon 20 Aug 2018 20:19:19 BST" git commit --amend --no-edit --date "Mon 20 Aug 2018 20:19:19 BST"

Set the date of an arbitrary commit to an arbitrary or current date

Rebase to before said commit and stop for amendment:

  1. git rebase <commit-hash>^ -i
  2. Replace pick with e (edit) on the line with that commit (the first one)
  3. quit the editor (ESC followed by :wq in VIM)
  4. Either:
  • GIT_COMMITTER_DATE="$(date)" git commit --amend --no-edit --date "$(date)"
  • GIT_COMMITTER_DATE="Mon 20 Aug 2018 20:19:19 BST" git commit --amend --no-edit --date "Mon 20 Aug 2018 20:19:19 BST"

Source: https://codewithhugo.com/change-the-date-of-a-git-commit/


Answers:


How to read inline styling of an element?

I'd like to know if it's possible to determine what inline styling has been attributed to an HTML element. I do not need to retrieve the value, but rather just detect if it's been set inline or not.

For instance, if the HTML were:

<div id='foo' style='width: 100px; height: 100px; background: green;'></div>

How can I determine that width, height, and background have been explicitly declared, inline?

As far as I can tell, the solution can work two ways. I can ask it if a specific attribute is set and it will tell me true or false, or it can tell me all attributes that have been set. Like so:

var obj = document.getElementById('foo');
obj.hasInlineStyle('width');  //returns true;
obj.hasInlineStyle('border'); //returns false;

//or

obj.getInlineStyles();   //returns array with values:
                       // 'width' 'height' and 'background'

I'm not interested in css attributes that are inherited via declarations in a stylesheet, only inline styles. One last thing, I have no control over the HTML source.

Thanks


Answers:


The style property of an HTML Element returns a style object which lists all the properties. Any that have a value (other than null or empty string) have been set on the inline style attribute.


Answers:


Updated to work with IE

You could try something like this

function hasInlineStyle(obj, style) {
    var attrs = obj.getAttribute('style');
    if(attrs === null) return false;
    if(typeof attrs == 'object') attrs = attrs.cssText;
    var styles = attrs.split(';');
    for(var x = 0; x < styles.length; x++) {
        var attr = styles[x].split(':')[0].replace(/^s+|s+$/g,'').toLowerCase();
        if(attr == style) {
            return true;
        }
    }
    return false;
}

So if you have an element like this:

<span id='foo' style='color: #000; line-height:20px;'></span>

That also has a stylesheet like this:

#foo { background-color: #fff; }

The function would return...

var foo = document.getElementById('foo');
alert(hasInlineStyle(foo,'color')); // true
alert(hasInlineStyle(foo,'background-color')); // false

Answers:


You may want to try doing something like:

var obj = document.getElementById('foo');
var obj_has_background = (obj.style.background != '');
var obj_has_width = (obj.style.width != '');
var obj_has_height = (obj.style.height != '');

Seems a bit long, but this is the best (and shortest) solution I could come up with.


Answers:


Are you trying to check if a certain styling attribute exists, or just want a list of the possible attributes? If you already know the attribute, then you can just use

hasStyle(obj,'width');
function hasStyle(obj, style)
{
     switch(style)
         case 'width':
              return obj.style.width ? true : false;
         case 'background':
              return obj.style.background ? true : false;
}

You can use Paolo's function to generate an array of the styles.


Answers:


Here are two functions that return local element style definitions:

function getLocalStyle(pEleId, pStyle) {
    var camelStyle = camelCase( pStyle );
    var eleStyles = document.getElementById(pEleId).style
    return eleStyles[camelStyle];
}

function camelCase(str) {
  return str
    .split('-')
    .reduce((a, b) => a + b.charAt(0).toUpperCase() + b.slice(1));
}

Usage:

var backgroundColor = getLocalStyle( pLayerName, "background-color" );

Answers:


QCompleter and QLineEdit for multiple words

Is there any way to have the QCompleter to act like an autocomplete for multiple words?

Someone has any idea how to do it?


Answers:


I don't know if I understand correctly:

QStringList wordList;
wordList << "alpha and beta" << "omega" << "omicron" << "zeta";

QCompleter *completer = new QCompleter(wordList, this);
completer->setCaseSensitivity(Qt::CaseInsensitive);

QLineEdit *lineEdit = new QLineEdit(this);
lineEdit->setCompleter(completer);

If you type alp then you get the completion "alpha and beta" which is more than one word. There is no limit.

Update after clarifications:

Seems that what is requested is starting a new autocompletion after a delimiter value. In the current case this delimiter will be a space. An equivalent example would be the tree model completer from the Qt examples. This example illustrates how to solve the same situation.


Answers:


Python Library to Generate VCF Files?

Know of any good libraries for this? I did some searches and didn't come across anything. Someone somewhere must have done this before, I hate to reinvent the wheel.


Answers:


PyCoCuMa appears to have a VCF parser built into it, and it'll generate VCard output. You might have some luck with it. I played around with it a bit; it parsed some VCF files I have lying around without any problems. You'll most likely have to poke through the source to figure out how to use it, though.

See:

http://www.srcco.de/v/pycocuma

http://pycocuma.sourcearchive.com/documentation/0.4.5-6-5/vcard_8py-source.html


Answers:


I would look at:

http://vobject.skyhouseconsulting.com/usage.html (look under 'Usage examples')

Very easy parsing and generation of both vCal and vCard.


Answers:


Sum of digits in C#

What's the fastest and easiest to read implementation of calculating the sum of digits?

I.e. Given the number: 17463 = 1 + 7 + 4 + 6 + 3 = 21


Answers:


You could do it arithmetically, without using a string:

sum = 0;
while (n != 0) {
    sum += n % 10;
    n /= 10;
}

Answers:


 public static int SumDigits(int value)
 {
     int sum = 0;
     while (value != 0)
     {
         int rem;
         value = Math.DivRem(value, 10, out rem);
         sum += rem;
     }
     return sum;
 }

Answers:


I use

int result = 17463.ToString().Sum(c => c - '0');

It uses only 1 line of code.


Answers:


I like the chaowman's response, but would do one change

int result = 17463.ToString().Sum(c => Convert.ToInt32(c));

I'm not even sure the c - '0', syntax would work? (substracting two characters should give a character as a result I think?)

I think it's the most readable version (using of the word sum in combination with the lambda expression showing that you'll do it for every char). But indeed, I don't think it will be the fastest.


Answers:


For integer numbers, Greg Hewgill has most of the answer, but forgets to account for the n < 0. The sum of the digits of -1234 should still be 10, not -10.

n = Math.Abs(n);
sum = 0;
while (n != 0) {
    sum += n % 10;
    n /= 10;
}

It the number is a floating point number, a different approach should be taken, and chaowman's solution will completely fail when it hits the decimal point.


Answers:


int num = 12346;
int sum = 0;
for (int n = num; n > 0; sum += n % 10, n /= 10) ;

Answers:


I would suggest that the easiest to read implementation would be something like:

public int sum(int number)
{
    int ret = 0;
    foreach (char c in Math.Abs(number).ToString())
        ret += c - '0';
    return ret;
}

This works, and is quite easy to read. BTW: Convert.ToInt32('3') gives 51, not 3. Convert.ToInt32('3' - '0') gives 3.

I would assume that the fastest implementation is Greg Hewgill's arithmetric solution.


Answers:


I thought I'd just post this for completion's sake:

If you need a recursive sum of digits, e.g: 17463 -> 1 + 7 + 4 + 6 + 3 = 21 -> 2 + 1 = 3
then the best solution would be

int result = input % 9;
return (result == 0 && input > 0) ? 9 : result;

Answers:


The simplest and easiest way would be using loops to find sum of digits.

int sum = 0;
int n = 1234;

while(n > 0)
{
    sum += n%10;
    n /= 10;
}

Answers:


int j, k = 1234;
for(j=0;j+=k%10,k/=10;);

Answers:


private static int getDigitSum(int ds)
{
    int dssum = 0;            
    while (ds > 0)
    {
        dssum += ds % 10;
        ds /= 10;
        if (dssum > 9)
        {                
            dssum -= 9;
        }
    }
    return dssum;
}

This is to provide the sum of digits between 0-9


Answers:


#include <stdio.h>

int main (void) {

    int sum = 0;
    int n;
    printf('Enter ir num ');
    scanf('%i', &n);

    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }

    printf('Sum of digits is %i
', sum);

    return 0;
}

Answers:


A while back, I had to find the digit sum of something. I used Muhammad Hasan Khan's code, however it kept returning the right number as a recurring decimal, i.e. when the digit sum was 4, i'd get 4.44444444444444 etc. Hence I edited it, getting the digit sum correct each time with this code:

 double a, n, sumD;
 for (n = a; n > 0; sumD += n % 10, n /= 10);
 int sumI = (int)Math.Floor(sumD);

where a is the number whose digit sum you want, n is a double used for this process, sumD is the digit sum in double and sumI is the digit sum in integer, so the correct digit sum.


Answers:


Surprised nobody considered the Substring method. Don't know whether its more efficient or not. For anyone who knows how to use this method, its quite intuitive for cases like this.

string number = '17463';
int sum = 0;
String singleDigit = '';
for (int i = 0; i < number.Length; i++)
{
singleDigit = number.Substring(i, 1);
sum = sum + int.Parse(singleDigit);
}
Console.WriteLine(sum);
Console.ReadLine();

Answers:


int n = 17463; int sum = 0;
for (int i = n; i > 0; i = i / 10)
{
sum = sum + i % 10;
}
Console.WriteLine(sum);
Console.ReadLine();

Answers:


static int SumOfDigits(int num)
{
    string stringNum = num.ToString();
    int sum = 0;
    for (int i = 0; i < stringNum.Length; i++)
    {
      sum+= int.Parse(Convert.ToString(stringNum[i]));

    }
    return sum;
}

Answers:


If one wants to perform specific operations like add odd numbers/even numbers only, add numbers with odd index/even index only, then following code suits best. In this example, I have added odd numbers from the input number.

using System;
                    
public class Program
{
    public static void Main()
    {
        Console.WriteLine("Please Input number");
        Console.WriteLine(GetSum(Console.ReadLine()));
    }
    
    public static int GetSum(string num){
        int summ = 0;
        for(int i=0; i < num.Length; i++){
            int currentNum;
            if(int.TryParse(num[i].ToString(),out currentNum)){
                 if(currentNum % 2 == 1){
                    summ += currentNum;
                }
            }
       } 
       return summ;
    }
}

Answers:


Programmatically retrieve SQL Server stored procedure source that is identical to the source returned by the SQL Server Management Studio gui?

Any pointers on how I can programmatically get exactly the identical stored procedure source from SQL Server 2005, as when I right-click on that stored procedure in SQL Server Management Studio and select modify?

I'm trying using SMO, but there are some textual differences. The procedure always has CREATE, not ALTER, and there are some differences in the header, such as missing GOs in the version I'm getting programmatically. I can fix these up, but perhaps there is a better way?

Again, I'm in SQL Server 2005, using SMSE. Using SMO via Visual Studio 8 2008.

Update: Gotten some answers that tell the basics of how to retrieve the stored procedure. What I'm looking for is retrieving the text identical (or nearly identical) to what the GUI generates.

Example: for sp_mysp, right-click in Management Studio, select modify. This generates:

    USE [MY_DB]  
    GO  
    /****** Object:  StoredProcedure [dbo].[sp_mysp]    Script Date: 01/21/2009 17:43:18 ******/  
    SET ANSI_NULLS ON  
    GO  
    SET QUOTED_IDENTIFIER ON  
    GO  
    -- =============================================
    -- Author:      
    -- Create date: 
    -- Description: 
    -- =============================================
    ALTER PROCEDURE [dbo].[sp_mysp]

I'd like to programmatically get the same thing (notice the GOs in the header, and the fact that it's an ALTER PROCEDURE. Ideally, I'd like to get this with minimal programmatic fixing up of the source retrieved.

I'd be happy to only get something that differed in the Script Date details . . .


Answers:


Use the following select statement to get all the whole definition:

select ROUTINE_DEFINITION from INFORMATION_SCHEMA.ROUTINES Where ROUTINE_NAME='someprocname'

my guess is that SSMS and other tools read this out and make changes where necessary such as changing CREATE to ALTER. As far as I know SQL stores not other representations of the procedure


Answers:


EXEC sp_helptext 'your procedure name';

This avoids the problem with INFORMATION_SCHEMA approach wherein the stored procedure gets cut off if it is too long.

Update: David writes that this isn't identical to his sproc...perhaps because it returns the lines as 'records' to preserve formatting? If you want to see the results in a more 'natural' format, you can use Ctrl-T first (output as text) and it should print it out exactly as you've entered it. If you are doing this in code, it is trivial to do a foreach to put together your results in exactly the same way.

Update 2: This will provide the source with a 'CREATE PROCEDURE' rather than an 'ALTER PROCEDURE' but I know of no way to make it use 'ALTER' instead. Kind of a trivial thing, though, isn't it?

Update 3: See the comments for some more insight on how to maintain your SQL DDL (database structure) in a source control system. That is really the key to this question.


Answers:


I agree with Mark. I set the output to text mode and then sp_HelpText 'sproc'. I have this binded to Crtl-F1 to make it easy.


Answers:


You will have to hand code it, SQL Profiler reveals the following.

SMSE executes quite a long string of queries when it generates the statement.

The following query (or something along its lines) is used to extract the text:

SELECT
NULL AS [Text],
ISNULL(smsp.definition, ssmsp.definition) AS [Definition]
FROM
sys.all_objects AS sp
LEFT OUTER JOIN sys.sql_modules AS smsp ON smsp.object_id = sp.object_id
LEFT OUTER JOIN sys.system_sql_modules AS ssmsp ON ssmsp.object_id = sp.object_id
WHERE
(sp.type = N'P' OR sp.type = N'RF' OR sp.type='PC')and(sp.name=N'#test___________________________________________________________________________________________________________________00003EE1' and SCHEMA_NAME(sp.schema_id)=N'dbo')

It returns the pure CREATE which is then substituted with ALTER in code somewhere.

The SET ANSI NULL stuff and the GO statements and dates are all prepended to this.

Go with sp_helptext, its simpler ...


Answers:


The Databse Publishing Wizard can dump the schema (and other objects) from the command line.


Answers:


You said programmatically, right? I hope C# is ok. I know you said that you tried SMO and it didn't quite do what you wanted, so this probably won't be perfect for your request, but it will programmatically read out legit SQL statements that you could run to recreate the stored procedure. If it doesn't have the GO statements that you want, you can probably assume that each of the strings in the StringCollection could have a GO after it. You may not get that comment with the date and time in it, but in my similar sounding project (big-ass deployment tool that has to back up everything individually), this has done rather nicely. If you have a prior base that you wanted to work from, and you still have the original database to run this on, I'd consider tossing the initial effort and restandardizing on this output.

using System.Data.SqlClient;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
…
string connectionString = … /* some connection string */;
ServerConnection sc = new ServerConnection(connectionString);
Server s = new Server(connection);
Database db = new Database(s, … /* database name */);
StoredProcedure sp = new StoredProcedure(db, … /* stored procedure name */);
StringCollection statements = sp.Script;

Answers:


To alter a stored procedure, here's the C# code:

SqlConnection con = new SqlConnection('your connection string');
con.Open();
cmd.CommandType = System.Data.CommandType.Text;
string sql = File.ReadAllText(YUOR_SP_SCRIPT_FILENAME);
cmd.CommandText = sql;   
cmd.Connection = con;
cmd.ExecuteNonQuery();
con.Close();

Things to note:

  1. Make sure the USER in the connection string have the right to alter SP
  2. Remove all the GO,SET ANSI_NULLS XX,SET QUOTED_IDENTIFIER statements from the script file. (If you don't, the SqlCommand will throw an error).

Answers:


I just want to note that instead of using find and replace to change create procedure to alter procedure, you are just as well to use a drop, you can put it right at the top and it does require text searching.

IF exists (SELECT * FROM sys.objects 
        WHERE object_id = OBJECT_ID(N'sp_name')
            and type in ('P','V') --procedure or view
        )
    DROP sp_name
GO

If you are sure it's there, I guess you could just drop it too, but I wouldn't recommend that. Don't forget the go, since create procedure must be the first and only statement in a batch.

Or the lazy approach:

IF OBJECT_ID(N'sp_name') is not null
    DROP sp_name
GO

Answers:


I saw a article via link. There are four methods, I just did a short summary here for helping other programmers.

  1. EXEC sp_helptext 'sp_name';

  2. SELECT OBJECT_ID('sp_name')

  3. SELECT OBJECT_DEFINITION( OBJECT_ID('sp_name') ) AS [Definition];

  4. SELECT * FROM sys.sql_modules WHERE object_id = object_id('sp_name');


Answers:


What is the maximum length of a URL in different browsers?

What is the maximum length of a URL in different browsers? Does it differ among browsers?

Does the HTTP protocol dictate it?


Answers:


WWW FAQs: What is the maximum length of a URL? has its own answer based on empirical testing and research. The short answer is that going over 2048 characters makes Internet Explorer unhappy and thus this is the limit you should use. See the page for a long answer.


Answers:


The URI RFC (of which URLs are a subset) doesn't define a maximum length, however, it does recommend that the hostname part of the URI (if applicable) not exceed 255 characters in length:

URI producers should use names that conform to the DNS syntax, even when use of DNS is not immediately apparent, and should limit these names to no more than 255 characters in length.

As noted in other posts though, some browsers have a practical limitation on the length of a URL.


Answers:


Short answer - de facto limit of 2000 characters

If you keep URLs under 2000 characters, they'll work in virtually any combination of client and server software.

If you are targeting particular browsers, see below for more details specific limits.

Longer answer - first, the standards...

RFC 2616 (Hypertext Transfer Protocol HTTP/1.1) section 3.2.1 says

The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15).

That RFC has been obsoleted by RFC7230 which is a refresh of the HTTP/1.1 specification. It contains similar language, but also goes on to suggest this:

Various ad hoc limitations on request-line length are found in practice. It is RECOMMENDED that all HTTP senders and recipients support, at a minimum, request-line lengths of 8000 octets.

...and the reality

That's what the standards say. For the reality, there was an article on boutell.com (link goes to Internet Archive backup) that discussed what individual browser and server implementations will support. The executive summary is:

Extremely long URLs are usually a mistake. URLs over 2,000 characters will not work in the most popular web browsers. Don't use them if you intend your site to work for the majority of Internet users.

(Note: this is a quote from an article written in 2006, but in 2015 IE's declining usage means that longer URLs do work for the majority. However, IE still has the limitation...)

Internet Explorer's limitations...

IE8's maximum URL length is 2083 chars, and it seems IE9 has a similar limit.

I've tested IE10 and the address bar will only accept 2083 chars. You can click a URL which is longer than this, but the address bar will still only show 2083 characters of this link.

There's a nice writeup on the IE Internals blog which goes into some of the background to this.

There are mixed reports IE11 supports longer URLS - see comments below. Given some people report issues, the general advice still stands.

Search engines like URLs < 2048 chars...

Be aware that the sitemaps protocol, which allows a site to inform search engines about available pages, has a limit of 2048 characters in a URL. If you intend to use sitemaps, a limit has been decided for you! (see Calin-Andrei Burloiu's answer below)

There's also some research from 2010 into the maximum URL length that search engines will crawl and index. They found the limit was 2047 chars, which appears allied to the sitemap protocol spec. However, they also found the Google SERP tool wouldn't cope with URLs longer than 1855 chars.

CDNs have limits

CDNs also impose limits on URI length, and will return a 414 Too long request when these limits are reached, for example:

(credit to timrs2998 for providing that info in the comments)

Additional browser roundup

I tested the following against an Apache 2.4 server configured with a very large LimitRequestLine and LimitRequestFieldSize.

Browser     Address bar   document.location
                          or anchor tag
------------------------------------------
Chrome          32779           >64k
Android          8192           >64k
Firefox          >64k           >64k
Safari           >64k           >64k
IE11             2047           5120
Edge 16          2047          10240

See also this answer from Matas Vaitkevicius below.

Is this information up to date?

This is a popular question, and as the original research is ~12 years old I'll try to keep it up to date: As of Jan 2020, the advice still stands. Even though IE11 may possibly accept longer URLs, the ubiquity of older IE installations plus the search engine limitations mean staying under 2000 chars is the best general policy.


Answers:


The HTTP 1.1 specification says:

URIs in HTTP can be represented in absolute form or relative to some
known base URI [11], depending upon the context of their use. The two
forms are differentiated by the fact that absolute URIs always begin
with a scheme name followed by a colon. For definitive information on
URL syntax and semantics, see 'Uniform Resource Identifiers (URI): Generic Syntax and Semantics,' RFC 2396 [42] (which replaces RFCs 1738 [4] and RFC 1808 [11]). This specification adopts the definitions of 'URI-reference', 'absoluteURI', 'relativeURI', 'port',
'host','abs_path', 'rel_path', and 'authority' from that
specification.

The HTTP protocol does not place any a priori limit on the length of
a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs.*
A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15).

Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths.

As mentioned by @Brian, the HTTP clients (e.g. browsers) may have their own limits, and HTTP servers will have different limits.


Answers:


Microsoft Support says 'Maximum URL length is 2,083 characters in Internet Explorer'.

IE has problems with URLs longer than that. Firefox seems to work fine with >4k chars.


Answers:


There is really no universal maximum URL length. The max length is determined only by what the client browser chooses to support, which varies widely. The 2,083 limit is only present in Internet Explorer (all versions up to 7.0). The max length in Firefox and Safari seems to be unlimited, although instability occurs with URLs reaching around 65,000 characters. Opera seems to have no max URL length whatsoever, and doesn't suffer instability at extremely long lengths.


Answers:


Sitemaps protocol, which is a way for webmasters to inform search engines about pages on their sites (also used by Google in Webmaster Tools), supports URLs with less than 2048 characters. So if you are planning to use this feature for Search Engine Optimization, take this into account.


Answers:


The longest URLs I came across are data URLs

Example image URL from Google image results (11747 characters)

data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBhQSERIUExQUFRUUFxcXFhQYFBQXGBgYFhkVGBkVFxUXHCYfGBojGRQVHy8gJCcpLCwsFh4xNTAqNSYrLCkBCQoKDgwOGg8PGiokHyQpLDUqKSwsLCksKSwpKSwsLCwpKSkpLCwpLCksKSwpLCkpLCwsLCkpKSwsLCwsLDQsLP/AABEIAM0A9gMBIgACEQEDEQH/xAAcAAACAgMBAQAAAAAAAAAAAAAABQQGAgMHAQj/xABTEAACAAQCBAcLBgsFBwUAAAABAgADBBESIQUGMUEHEyJRYYGRFBYyVHF0lKGxs9IjNEKS0dMXMzVSYmRypMHj8GOTo7LiJENzosLh8RVTgoPD/8QAGQEBAAMBAQAAAAAAAAAAAAAAAAECAwQF/8QAJxEAAgIBAwMEAgMAAAAAAAAAAAECEQMSITEEE0EiUWGBkfAyceH/2gAMAwEAAhEDE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DllZCvPvJN4rFU6hyN4Ym4y6M4rVNwrpLyWkbmN6t3v9dDCbTPCIZkxmEnDls4y/8A0COVwZ3RypeS+mSk9XJyFsIJ9ov0xzuroFxvLa112dKnMRjo3XtsT4pZZQQQvGWtl0qcoX6w61ibMSYsoowGE/KAgjIj6A2XMbYk06Ms8oyjZIoQZFwlwp2hSUcdIcZnyHKM9I6XqJeAy5gmS3ORmAYwwzKO4355c8KH1iuPxeY34/8ATEd9NXlzUKZTBfwvBZSLMMtucbnEdGpaovKRmtcjlW2XGREeu0U3R+t+GWimVeyi54y1znnbDG5td8/xJ/vB8ERRNloZo0WiuNrt/Y/4n+iPF1z/ALL/ABP9MKILCZF9sApQd1+mESa4DfJJ/wDst/0RtbXUW/En+9/0QLEPT1EqSph3mel/7t4Ig6X0+JqOOLteYreHfYrC3g9MeRJFH//Z

Answers:


In URL as UI Jakob Nielsen recommends:

the social interface to the Web relies on email when users want to recommend Web pages to each other, and email is the second-most common way users get to new sites (search engines being the most common): make sure that all URLs on your site are less than 78 characters long so that they will not wrap across a line feed.

This is not the maximum but I'd consider this a practical maximum if you want your URL to be shared.


Answers:


ASP.NET 2 and SQL Server reporting services 2005 have a limit of 2028. I found this out the hard way, where my dynamic URL generator would not pass over some parameters to a report beyond that point. This was under Internet Explorer 8.


Answers:


Limit request line directive sets the maximum length of a URL. By default, it is set to 8190, which gives you a lot of room. However other servers and some browses, limit the length more.

Because all parameters are passed on the URL line, items that were in password of hidden fields will also be displayed in the URL of course. Neither mobile should be used for real security measures and should be considered cosmetic security at best.


Answers:


It seems that Chrome at least has raised this limit. I pasted 20,000 characters into the bookmarklet and it took it.


Answers:


I have experience with SharePoint 2007, 2010 and there is a limit of the length URL you can create from the server side in this case SharePoint, so it depends mostly on, 1) the client (browser, version, and OS) and 2) the server technology, IIS, Apache, etc.


Answers:


I wrote this test that keeps on adding 'a' to parameter until the browser fails

C# part:

[AcceptVerbs(HttpVerbs.Get)]
public ActionResult ParamTest(string x)
{
    ViewBag.TestLength = 0;
    if (!string.IsNullOrEmpty(x))
    {
        System.IO.File.WriteAllLines('c:/result.txt',
                       new[] {Request.UserAgent, x.Length.ToString()});
        ViewBag.TestLength = x.Length + 1;
    }

    return View();
}

View:

<script src='//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script>

<script type='text/javascript'>
    $(function() {
        var text = 'a';
        for (var i = 0; i < parseInt(@ViewBag.TestLength)-1; i++) {
            text += 'a';
        }

        document.location.href = 'http://localhost:50766/Home/ParamTest?x=' + text;
    });
</script>

PART 1

On Chrome I got:

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36
2046

It then blew up with:

HTTP Error 404.15 - Not Found The request filtering module is configured to deny a request where the query string is too long.

Same on Internet Explorer 8 and Firefox

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
2046

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
2046

PART 2

I went easy mode and added additional limits to IISExpress applicationhost.config and web.config setting maxQueryStringLength='32768'.

Chrome failed with message 'Bad Request - Request Too Long

HTTP Error 400. The size of the request headers is too long.

after 7744 characters.

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36
7744

PART 3

Added

<headerLimits>
    <add header='Content-type' sizeLimit='32768' />
</headerLimits>

which didn't help at all. I finally decided to use fiddler to remove the referrer from header.

static function OnBeforeRequest(oSession: Session) {
    if (oSession.url.Contains('localhost:50766')) {
        oSession.RequestHeaders.Remove('Referer');
    }

Which did nicely.

Chrome: got to 15613 characters. (I guess it's a 16K limit for IIS)

And it failed again with:

<BODY><h2>Bad Request - Request Too Long</h2>
<hr><p>HTTP Error 400. The size of the request headers is too long.</p>


Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36
15613

Firefox:

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
15708

Internet Explorer 8 failed with iexplore.exe crashing.

Enter image description here

After 2505

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
2505

Android Emulator

Mozilla/5.0 (Linux; Android 5.1; Android SDK built for x86 Build/LKY45) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36
7377

Internet Explorer 11

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)
4043

Internet Explorer 10

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)
4043

Internet Explorer 9

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
4043

Answers:


Why is the Internet Explorer limit only 2K while IIS has a limit of 16K? I don't think it makes sense.

So I want to start an experiment about Ajax request URL size limits.

I have set my Tomcat HTTP connector's maxHttpHeaderSize='1048576'. And prepared a very long URL.

Then I send a request with the long URL like the following:

var url='/ajax/url-length.jsp';
jQuery.ajax(url,{data:{q:'0'.repeat(1048000-url.length-4)}});

jQuery reports done. Tomcat reports the URL requested is 1048015 bytes. It was tested with Chrome 50 and Internet Explorer 11.

So web browsers won't truncate or limit your URL intentionally when sending Ajax requests.


Answers:


On Apple platforms (iOS/macOS/tvOS/watchOS), the limit may be a 2 GB long URL scheme, as seen by this comment in the source code of Swift:

// Make sure the URL string isn't too long.
// We're limiting it to 2GB for backwards compatibility with 32-bit executables using NS/CFURL
if ( (urlStringLength > 0) && (urlStringLength <= INT_MAX) )
{
...

On iOS, I've tested and confirmed that even a 300+ MB long URL is accepted. You can try such a long URL like this in Objective-C:

NSString *path = [@'a:' stringByPaddingToLength:314572800 withString:@'a' startingAtIndex:0];
NSString *js = [NSString stringWithFormat:@'window.location.href = '%@';', path];
[self.webView stringByEvaluatingJavaScriptFromString:js];

And catch if it succeed with:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSLog(@'length: %@', @(request.URL.absoluteString.length));
    return YES;
}

Answers:


According to the HTTP spec, there is no limit to a URL's length. Keep your URLs under 2048 characters; this will ensure the URLs work in all clients & server configurations. Also, search engines like URLs to remain under approximately 2000 characters.


Answers:


Generally speaking, there is no "limit" to a URL's length. But, according to a different browser, you can keep

Microsoft Internet Explorer (Browser)

Microsoft states that the maximum length of a URL in Internet Explorer is 2,083 characters, with no more than 2,048 characters in the path portion of the URL.

Firefox (Browser)

After 65,536 characters, the location bar no longer displays the URL in Windows Firefox 1.5.x. We should stop testing after 100,000 characters.

Safari (Browser)

At least 80,000 characters will work. We should stopped testing after 80,000 characters.

Opera (Browser)

At least 190,000 characters will work. We should stopped testing after 190,000 characters. Opera 9 for Windows continued to display a fully editable, copyable and pasteable URL in the location bar even at 190,000 characters.

Apache (Server)

Early attempts to measure the maximum URL length in web browsers bumped into a server URL length limit of approximately 4,000 characters, after which Apache produces a "413 Entity Too Large" error.


Answers: