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
# Ping with timestamp | |
ping google.com | while read pong; do echo "$(date): $pong"; done | |
# Ping to file | |
ping google.com >> ping.txt | |
# Ping with timestamp to file | |
ping google.com | while read pong; do echo "$(date): $pong"; done >> ping.txt |
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
// Serialize all our form elements with a value, including disabled | |
$.fn.serializeAllForm = function () { | |
return $.param( | |
$.makeArray( | |
$(':input[value!=""]', this) | |
) | |
); | |
} |
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 | |
// Multiple ways of registering a function for execution on shutdown | |
// Class method | |
public function __construct() { | |
register_shutdown_function(array($this, 'scriptFailure')); | |
} | |
// Non-class method | |
register_shutdown_function('scriptFailure'); |
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
# View live logs | |
tail -f FILE | |
# View live logs which only matches our IP | |
tail -f FILE | grep --line-buffered IP_ADDRESS |
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
# Save all lines after line number X (1000000), from one file into another | |
tail -n +1000001 error_log > error_log_trimmed |
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() { | |
try { | |
var $_console$$ = console; | |
Object.defineProperty(window, "console", { | |
get: function() { | |
if ($_console$$._commandLineAPI) | |
throw "Sorry, for security reasons, the script console is deactivated"; | |
return $_console$$ | |
}, | |
set: function($val$$) { |
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 | |
/** | |
* Recursive function to work through the data | |
* | |
* http_build_query in php 5 will screw up array serialisation by encoding the square brackets | |
* and make it incompatible for passing to an URL's GET segment or sending through post data manually | |
* | |
* Thanks to Marco K. (link below), A version intended for php < 5 actually encodes the data correctly | |
* |
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 | |
$data = array(); | |
foreach ($products as $product) { | |
$data[$product->make][$product->variant.' - '.$product->material][] = $product; | |
} |
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
#!/bin/bash | |
# Post checkout runs during branch switching | |
# Used to copy over a branch specific config.js file | |
branch="$(git rev-parse --abbrev-ref HEAD)" | |
config='mobile/assets/js/config.js' | |
# Check if our file exists |
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 delay = (function() { | |
var timer = 0; | |
return function(callback, ms) { | |
clearTimeout(timer); | |
timer = setTimeout(callback, ms); | |
}; | |
})(); | |
// Set a delay before doing something else - ie, wait until they've stopped typing | |
delay(function() { |