Skip to content

Instantly share code, notes, and snippets.

View smerrill's full-sized avatar
🤖
Attention is all you need

Steven Merrill smerrill

🤖
Attention is all you need
View GitHub Profile
#!/bin/bash
# Variables definitions
DBNAME="tony_local_test"
MYSQL_COMMON="-uroot -D$DBNAME"
SQL_QUERY="SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '$DBNAME' AND ENGINE='MyISAM';"
ALTER_TABLE_QUERY=""
# Build up one giant SQL string.
for i in `mysql $MYSQL_COMMON --skip-column-names -s -e "$SQL_QUERY"`; do
def verify(a:String) = {(10 - a.reverse.tail.zip(Stream.continually(List(2, 1)).flatten).foldLeft(0)((sum, vals) => sum + (vals._1.toString.toInt * vals._2).toString.toList.foldLeft(0)(_+_.toString.toInt)) % 10).toString.last.toString.toInt == a.last.toString.toInt}
@smerrill
smerrill / load_vcl_clear_cache.sh
Created December 8, 2010 18:50
Load a new VCL file, replace the running configuration, and set all cache to be purged.
OLD_CFG=`varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082 "vcl.list" | grep active | awk '{print $3}'`
NEW_CFG="vcl-"`date +%s`
varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082 "vcl.load $NEW_CFG /etc/varnish/default.vcl"
varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082 "vcl.use $NEW_CFG"
varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082 "vcl.discard $OLD_CFG"
varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082 "purge req.url ~ .*"
@smerrill
smerrill / varnish-esi-watch.sh
Created January 3, 2011 20:00
Watch Varnish's transactions go by for ESI blocks in Drupal.
varnishlog -x 'CLI' -x 'WorkThread' -x 'Debug' -o TxURL '^/esi/block/'
#!/bin/bash
# Remove all the mysql 5.1.56 commands from your Homebrew installation.
ls -aFl $(brew --prefix)/bin/mysql* | grep 56 | awk {'print $9'} | tr -d '@' | xargs rm
https://gist.github.com/941137
!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$
!.*/(CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$
@smerrill
smerrill / emulate-xsel-os-x.sh
Created April 26, 2011 16:10
Make X11 apps that expect xsel work with the OS X clipboard.
# Mimic xsel simply for the benefit of X11 apps.
xsel() {
if [[ $@ == "-ib" ]]; then
command pbcopy;
elif [[ $@ == '-ob' ]]; then
command pbpaste;
else
command xsel "$@";
fi
}
@smerrill
smerrill / gist:955566
Created May 4, 2011 16:57
Play / Pause Amazon Cloud Player
tell application "System Events"
set frontmost_app to item 1 of (get name of processes whose frontmost is true)
end tell
tell application "Google Chrome"
activate
set i to 0
repeat with t in (tabs of (first window))
set i to i + 1
if title of t is "Amazon Cloud Player" then