Find files with specified pattern on Linux

grep -rnw '/path/' -e 'pattern'

  • -r or -R is recursive
  • -n is line number
  • -w stands for match the whole word

Git add file name with space

Your project may contain some files or folders which contain space in filename. By default, you can not use git add for those files. However, adding single quotes can resolve this problem. Try the following:

git add 'file name or folder name with space'

Difference between equality(==) and identity(===) in PHP

Double equals(==) compares the values of variables for equality, type casting as necessary. Triple equals(===) checks if 2 variables are of the same TYPE and have the same value.
A full explanation of the differences are available in PHP Manual
1 === 1: true
1 == 1: true
1 === “1”: false //1 is an integer, “1” is a string
1 == “1”: true //“1” gets casted to an integer, which is 1
“foo” === “foo”: true //both operands are strings and have the same value
Note: two instances of the same class do NOT match the === operator
$a = new stdClass();
$a->foo = “bar”;
$b = clone $a;
var_dump($a === $b); //bool(false)

IE Conditional Comment

When develop a website, you should take care of anything that IE can throw at you without the use of hacks. Hacks are dangerous, since they are based on non-standard exploits and you can’t trust how they’re going to behave on the future browsers. Thus the solution for this problem is the conditional stylesheet or conditional comment. One important thing is that IE 10 and up don’t support conditional comment

Conditional comment operators

Operator Description
IE represents Internet Explorer; if a number value is also
specified, it represents a version vector
lt less than operator
lte less than or equal to
gt greater than
gte greater than or equal to
! the NOT operator
() subexpression operator
& the AND operator
| the OR operator
true evaluates to true
false evaluates to false


Target everything except IE

<!--[if !IE]>
  <link rel="stylesheet" type="text/css" href="not-ie.css" />

Target IE7 only

<!--[if IE 7]>
  <link rel="stylesheet" type="text/css" href="ie7.css" />

Target IE8 and lower

<!--[if lte IE 8]>
  <link rel="stylesheet" type="text/css" href="ie8.css" />

These conditional comments don’t have to be used only for CSS. You could load JavaScript, or even use them to display the specific content of your site.

Asynchronous And Synchronous Ajax Calls

In jQuery ajax call, there’s an option called async. Let’s look at below example:

    url: your_url,
    type: "POST",
    async: true,
    dataType: "json"

By default, all requests are sent asynchronously(this is set to true by default). If you need synchronous requests, set this option to false
Setting async to false means that the statement you are calling has to complete before the next statement in your function call be called. If you set async to true then that statement will execute and the next statement will be called regardless of whether the async statement has completed yet.
Note that cross-domain requests and dataType: "jsonp"requests do not support synchronous operation. Also as of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success().
Try something like this

    url: target,
    contentType:'application/json; charset=utf-8',
    type: 'POST',
    dataType: 'json',
    async : false,
    success : function(){
    error: function(){

Double Slashes In A Url

Many developers was wondering about the following line

<script src="//"></script>

What does the “double slashes” do or is this line of code correct?

It’s a relative URL without a scheme(http or https) according to RFC 3986: “Uniform Resource Identifier (URI): Generic Syntax”, Section 4.2. It’s useful when switching between http and https, because you won’t need to explicitly specify the scheme. It’s also supported in all web browsers.

More detailed, the two forward slashes are described as a common shorthand for whatever protocol being used

z-index Property

What is z-index

z-index is a css property that specifies the stack order of an element.  The stack order is based on the defined value. If an element has higher z-index, it’s in front of a lower z-index element. The default value is 0.
Note: z-index only works on positioned elements(absolute, relative, fixed)


tag {
    z-index: value;


Property Value Example Description
z-index auto z-index: auto; Sets the stack order equal to its parents. This is default
number z-index: 10; Sets the stack order of the element. Negative numbers are allowed
inherit z-index: inherit; nherits this property from its parent element

Browser Support

Most browser fully supports z-index property. IE7 doesn’t support the value “inherit”, IE8 requires !Doctype

Property compatible_ie compatible_firefox compatible_chrome compatible_safari compatible_opera
version 4.0 3.0 1.0 1.0 4.0


img {
    position: relative;
    left: 0px;
    bottom: 0px;
    z-index: 99;