This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( function( window, undefined ) { | |
// normally variables & functions start with a lowercase letter but with modules, that is not the case. | |
// The general tradition is to start them with a capital letter instead. | |
function MyModule() { | |
// `this` refers to the instance of `MyModule` when created | |
this.myMethod = function myMethod() { | |
alert( 'my method' ); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MyModule = ( function( window, undefined ) { | |
// this object is used to store private variables and methods across multiple instantiations | |
var privates = {}; | |
function MyModule() { | |
this.myMethod = function myMethod() { | |
alert( 'my method' ); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
error_reporting(0); | |
$server = "localhost"; | |
$port = 3306; | |
$username = "csv_test"; | |
$password = "test"; | |
$db = "test_db"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.urlParam = function (name) { | |
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); | |
if (results === null) { | |
return null; | |
} | |
return results[1] || 0; | |
}; | |
var PID = $.urlParam("PID"); //123456 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var has_focus; | |
$(window).focus(function () { | |
has_focus = true; | |
document.title = "focus"; | |
}).blur(function () { | |
has_focus = false; | |
document.title = "no focus" | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Checks if a Collection already exists. | |
* Returns true if Collection exists, otherwise it returns false. | |
* | |
* @param $collection | |
* | |
* @return bool | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$callback = $_GET['callback']; | |
$json = json_encode(['foo' => 'bar'], JSON_FORCE_OBJECT); | |
if ($callback) { | |
header('Content-Type: text/javascript'); | |
echo $callback.'('; | |
echo $json; | |
echo ');'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).on('keyup', function (e) { | |
switch (e.keyCode) { | |
/*left*/ | |
case 37: | |
console.log('left'); | |
break; | |
/*right*/ | |
case 39: | |
console.log('right'); | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
ul { | |
counter-reset: foo; | |
} | |
li:before { | |
counter-increment: foo; | |
content: 'Count: ' counter(foo); | |
} | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PI = 3.1415926535; | |
function foo(a = 123, b = '') { | |
return PI | |
} | |
function bar(a, b, c, ...x) { | |
return x.length; |
OlderNewer