Skip to content

Instantly share code, notes, and snippets.

View faceleg's full-sized avatar

Michael Robinson faceleg

  • Auckland, New Zealand
View GitHub Profile
@faceleg
faceleg / sdFATLinks.js
Created July 29, 2012 20:45 — forked from seyDoggy/sdFATLinks.js
jQuery for adding Font Awesome icons to toolbar 1
@faceleg
faceleg / debouncer.js
Created September 6, 2012 02:01
JS Debouncer
/**
* Debouncer function to prevent multiple calls from a repeatedly called event
* @link http://stackoverflow.com/a/4298672/187954
* @link https://gist.github.com/3649866
* @param {Function} callback A callback to execute when timeout is reached with no subsequent calls.
* @param {Integer|null} timeout A custom timeout or null for 200
* @return {Function} The debouncer function.
*/
function eventDebouncer(callback, timeout) {
timeout = timeout || 200;
@faceleg
faceleg / ajax-run-data-scripts.html
Last active December 12, 2015 02:58
Template for jQuery ajax handler that runs scripts contained in the returned data.
<form action="" method="post">
<input type="text" name="name" />
<button type="submit">Submit</button>
</form>
<div id="result"></div>
<script type="src/javascript">
$.ajax({
type: 'POST',
url: location.href,
@faceleg
faceleg / countries-alphabetised.js
Created February 3, 2013 20:21
Alphabetised array of countries
[
'Afghanistan', 'Albania', 'Algeria', 'American Samoa' , 'Andorra', 'Angola', 'Anguilla',
'Antarctica', 'Antigua and Barbuda', 'Antilles, Netherlands', 'Argentina', 'Armenia',
'Aruba', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain', 'Bangladesh',
'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bermuda' , 'Bhutan', 'Bolivia',
'Bosnia and Herzegovina', 'Botswana', 'Brazil', 'British Indian Ocean Territory',
'British Virgin Islands' , 'Brunei Darussalam', 'Bulgaria', 'Burkina Faso', 'Burundi',
'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Cayman Islands' , 'Central African Republic',
'Chad', 'Chile', 'China', 'Christmas Island', 'Cocos (Keeling) Islands', 'Colombia',
'Comoros', 'Congo', 'Cook Islands', 'Costa Rica', 'Cote D\'Ivoire', 'Croatia', 'Cuba',
@faceleg
faceleg / mod_pagespeed
Last active December 15, 2015 12:09
Example mod_pagespeed configuration
ModPagespeed on
AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
ModPagespeedFileCachePath "/var/mod_pagespeed/www.website.com/cache/"
ModPagespeedGeneratedFilePrefix "/var/mod_pagespeed/www.website.com/cache/"
ModPagespeedEnableFilters combine_css,rewrite_css,inline_css
ModPagespeedEnableFilters combine_javascript,rewrite_javascript,inline_javascript
ModPagespeedEnableFilters extend_cache
ModPagespeedEnableFilters inline_images,recompress_images,resize_images
HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install ekg2 2>&1 ⏎
==> Downloading http://pl.ekg2.org/ekg2-0.3.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/ekg2-0.3.1.tar.gz
tar xf /Library/Caches/Homebrew/ekg2-0.3.1.tar.gz
==> ./configure --disable-debug --disable-dependency-tracking --prefix=/usr/local/Cellar/ekg2/0.3.1 --without-python --without-perl --with-readline=/usr/local/Cellar/readline/6.2.4 --without-gtk --enable-unicode false
./configure --disable-debug --disable-dependency-tracking --prefix=/usr/local/Cellar/ekg2/0.3.1 --without-python --without-perl --with-readline=/usr/local/Cellar/readline/6.2.4 --without-gtk --enable-unicode false
configure: WARNING: you should use --build, --host, --target
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-saf
@faceleg
faceleg / convert_db_name.sh
Created May 13, 2013 21:32
Export a database and change the name used in all tables, triggers and routines
#!/bin/bash
if [ $# != 4 ]; then
echo "Usage: $0 <database_name> <new_database_name> <mysql_username> <mysql_password>"
exit 1;
fi
DATABASE_NAME=$1
NEW_DATABASE_NAME=$2
USERNAME=$3
PASSWORD=$4
@faceleg
faceleg / largest_files.sh
Created May 13, 2013 22:21
Find largest files or directories in the current directory. Warning: this command can render the machine unresponsive while processing.
for X in $(du -s * | sort -nr | cut -f 2); do du -hs $X ; done | head -n 20
@faceleg
faceleg / dump_db.sh
Last active May 4, 2016 22:32
Dump tables, triggers and routines to separate files
#!/bin/bash
# MySQL executables
MYSQL="/usr/bin/mysql"
MYSQLDUMP="/usr/bin/mysqldump"
# Other executables
GZIP="$(which gzip)"
# Validate arguments