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
( 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
<? | |
$http_codes = array( | |
100 => 'Continue', | |
101 => 'Switching Protocols', | |
102 => 'Processing', | |
200 => 'OK', | |
201 => 'Created', | |
202 => 'Accepted', | |
203 => 'Non-Authoritative Information', |
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 | |
$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
<?php | |
$function_filedate = new Twig_SimpleFunction( | |
'fileDate', | |
/** | |
* @param $file_path | |
* This function generates a new file path with the last date of filechange | |
* to support better better client caching via Expires header: | |
* i.e: |
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 date = new Date(); | |
var daysToDeletion = 120; | |
var deletionDate = new Date(date.setDate(date.getDate() - daysToDeletion)); | |
printjson(deletionDate); | |
var db = db.getSiblingDB('db') | |
db.getMongo().setSlaveOk(); | |
printjson(db.messages.find({insertDate : {$lt : deletionDate}}).count()); |
OlderNewer