Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
git revert
Reverts the changes made in a specific commit by creating a new commit that undoes those changes.
echo "This is the initial content." > myfile.txt
add and commit file
git add myfile.txt
git commit -m "Initial commit"
make changes
echo "This is the modified content." > myfile.txt
git add myfile.txt
git commit -m "Modified myfile.txt"
revert last commit
git revert HEAD
or we can use specifying with the commit ID
git revert 4c04ecc
git log will return
 Revert "added file 4" --- Commit name

    This reverts commit 4c04eccff32e195ac0df17b1543f7f81de32d938. --- Commit id
by Luka Tatarishvili
12 months ago
0
Git
commands
3
JSONP 
is a technique to get data from server without cross-domain issues. JSONP does not use the
XMLHttpRequest
, instead it uses
<script>
tag.
window.onload = function() {
  var s = document.createElement("script");
  s.src = "https://www.w3schools.com/js/demo_jsonp.php";
  document.write(s.outerHTML);
};

// This function will run after the content is fully loaded from the server
function myFunc(myObj) {
  document.write(myObj.name + " is " + myObj.age + " and he lives in " + myObj.city);
} 
Requesting a content from another domain can cause problems, due to cross-domain policy.
<script>
tag does not have this problem and that is the reason why it uses the tag instead of using
XMLHttpRequest
object. ... Content of the remote
demo_jsonp.php
file
myFunc({"name":"John", "age":30, "city":"New York"});
by Valeri Tandilashvili
3 years ago
0
JSON
JavaScript
JS JSON
3
This example demonstrates that a final method cannot be overridden in a child class
class myClass {
    final function myFunction() {
        echo "Parent";
    }
}
// ERROR because a final method cannot be overridden in child classes.
class myClass2 extends myClass {
    function myFunction() {
        echo "Child";
    }
}
The above code will generate the following error:
Fatal error: Cannot override final method myClass::myFunction() in /home/user/scripts/code.php on line 9
by Valeri Tandilashvili
3 years ago
0
PHP
3
class Say {
    public function let() {
        echo 'Let' . " ";
        return $this;
    }
    public function me() {
        echo 'Me' . " ";
        return $this;
    }
    public function tell() {
        echo 'Tell' . " ";
        return $this;
    }
    public function you() {
        echo 'You' . " ";
        return $this;
    }
    public function something() {
        echo 'Something' . " ";
    }
}
$phrase = new Say;
$phrase->let()->me()->tell()->you()->something();
by Valeri Tandilashvili
4 years ago
0
PHP
OOP
PHP Object Oriented Programming (OOP)
3
It is not possible to use
$this
inside static methods
class Greeting {
    public $nonStatic = 'some value';
    
    public static function hello() {
        return $this->nonStatic;
    }
}

// echo Greeting::hello();

$obj1 = new Greeting();
echo $obj1->hello();
After executing the above code, following error will be generated:
Fatal error:  Uncaught Error: Using $this when not in object context
by Valeri Tandilashvili
4 years ago
0
PHP
OOP
PHP Object Oriented Programming (OOP)
3
To replace an HTML element, the element.
replaceChild
(newNode, oldNode) method is used. JS
window.onload = function() {
    let p = document.createElement("p");
    p.innerHTML = "This is new";

    // Replaces the first p with the new one
    let parent = document.getElementById("demo");
    parent.replaceChild(p, document.getElementById("p1"));
};
HTML
<div id="demo">
	<p id="p1">This is a paragraph.</p>
	<p id="p2">This is another paragraph.</p>
</div>
Note: The code above creates a new paragraph element that replaces the existing
p1
paragraph
by Valeri Tandilashvili
3 years ago
0
JavaScript
DOM
3
removeChild CODE
To remove an HTML element, we can select the parent of the element and use the
removeChild
(node) method JS
window.onload = function() {
    var parent = document.getElementById("demo");
    parent.removeChild(document.getElementById("p1"));
};
HTML
<div id="demo">
    <p id="p1">This is a paragraph.</p>
    <p id="p2">This is another paragraph.</p>
</div>
by Valeri Tandilashvili
3 years ago
0
JavaScript
DOM
3
insertBefore method CODE
element.
insertBefore
(node1, node2) inserts
node1
as a child before
node2
JS
function myFunction() {
  // Creates new list item
  let newItem = document.createElement("li");
  newItem.innerHTML = "Water";
  
  // Puts list item into myList before "tea" item
  let list = document.getElementById("myList");
  list.insertBefore(newItem, document.getElementById("tea"));
}
HTML
<ul id="myList">
  <li>Coffee</li>
  <li id="tea">Tea</li>
  <li>Cocacola</li>
</ul>

<p>Click the button to insert an item to the list.</p>

<button onclick="myFunction()">Try it</button>
by Valeri Tandilashvili
3 years ago
0
JavaScript
DOM
3
class Foo {
    
    public function __call($function, $arguments)
    {
        return "$function has been called with arguments: " . implode(', ', $arguments); 
    }
    
    // public function fireFunction($one, $two, $three) {
    //     return "pre-defined method";
    // }
}
$foo = new Foo();
echo $foo->fireFunction(5, 47, "third argument");
__call
is invoked when the method is inaccessible (when it's not public or does not exist at all)
by Valeri Tandilashvili
4 years ago
0
PHP
OOP
PHP Object Oriented Programming (OOP)
3
All style attributes can be accessed using the style object of the element. JS
//calling the function in window.onload to make sure the HTML is loaded
window.onload = function() {
    var x = document.getElementById("demo");
    x.style.color = '#6600FF';
    x.style.width = '100px';
};
HTML
<div id="demo" style="width:400px">Some text inside this DIV</div>
Note: All CSS properties can be set and modified using JavaScript. We cannot use dashes (-) in the property names: these are replaced with
camelCase
versions, where the compound words begin with a capital letter. For example: the
background-color
property should be referred to as
backgroundColor
.
by Valeri Tandilashvili
3 years ago
0
JavaScript
DOM
3
Results: 1578