This file contains hidden or 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
# Delete emails from the queue where the addresses or TO or FROM; | |
mailq | tail -n +2 | awk 'BEGIN { RS = "" } / name@domain\.co\.uk$/ { print $1 }' | tr -d '*!' | postsuper -d - | |
mailq | tail -n +2 | awk 'BEGIN { RS = "" } / domain\.co\.uk$/ { print $1 }' | tr -d '*!' | postsuper -d - | |
mailq | tail -n +2 | awk 'BEGIN { RS = "" } / MAILER-DAEMON@mail\.domain\.com$/ { print $1 }' | tr -d '*!' | postsuper -d - | |
# Find all IP addresses against the sasl_username and put them into iplist.txt | |
grep "[email protected]" /var/log/mail.log | sort -u > iplist.txt | |
# Go through all the IPs and delete the emails from the queue | |
grep -wFf /iplist.txt | cut -f 6 -d ' ' | cut -f 1 -d ':' | postsuper -d - |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |