Skip to content

Instantly share code, notes, and snippets.

View gaving's full-sized avatar
🎯
Focusing

Gavin Gilmour gaving

🎯
Focusing
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<title>SCOPE API Demo</title>
<link rel="stylesheet" media="screen" href="css/style.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.0/backbone-min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.min.js"></script>
<script type="text/javascript" src="js/backbone.poller.min.js"></script>
@gaving
gaving / conn
Created February 12, 2014 11:47
conn() {
(
echo "host \t 22 \t 3306 \t 8010"
for host in "$@"
do
echo -en "\n$host \t"
nc -w 2 -z $host 22 && echo -n "Y" || echo -n "N"
echo -en "\t"
nc -w 2 -z $host 3306 2>&1 && echo -n "Y" || echo -n "N"
echo -en "\t"
@gaving
gaving / clone
Created May 15, 2014 14:12
clone.sh
x_clone() {
SRC_HOST=${${1#*@}%/*}
SRC_USER=${${1%@*}%:*}
SRC_PASS=${${1%@*}#*:}
SRC_DATA=${${1#*/}}
DEST_HOST=${${2#*@}%/*}
DEST_USER=${${2%@*}%:*}
DEST_PASS=${${2%@*}#*:}
DEST_DATA=${${2#*/}}
class Dashing.Alert extends Dashing.Widget
ready: ->
onData: (data) ->
@accessor 'isHigh', ->
@get('level') in ['SEVERE', 'CRITICAL']
@gaving
gaving / mcp.zsh
Created October 22, 2014 10:36
copy mysql data less painfully
mcp() {
for i in mysqldump xargs pv; do
[[ ! -x `which $i 2>/dev/null` ]] && echo "$i is required to run." && return 1
done
_usage() {
echo "Usage: [--f/--n] user:pass@serverA/databaseA user:pass@serverB/databaseB [table]";
}
if [ $1 ]; then
#!/usr/bin/env bash
[[ ! -f 'config.sh' ]] && echo "'config.sh' not found. Create from config.sh.example." && exit
source config.sh
CURRENT_PATH=$(dirname $0)
SCHEMA_DIR=$CURRENT_PATH/structure
MIGRATION_DIR=$CURRENT_PATH/migrations
LOG_DIR=$CURRENT_PATH/logs
require 'coffee-script/register'
gulp = require 'gulp'
coffee = require 'gulp-coffee'
gutil = require 'gulp-util'
jasmine = require 'gulp-jasmine'
watch = require 'gulp-watch'
gulp.task 'build', ->
gulp.src('./src/*.coffee')
switch-site() {
if [[ $HOST == *gon* ]] then
SWITCH=${HOST/gon/gye}
else
SWITCH=${HOST/gye/gon}
fi
LBUFFER="ssh $SWITCH"
zle accept-line
}
zle -N switch-site
q() {
/bin/mysql --unbuffered --skip-column-names --raw -A -B -e "$@"
}
images() {
(
for i in {1..$(q "select MAX(photoid) from photos")}; \
echo -n $i && q "select photo from photos where photoid=${i}" | magick - info:-
) | sort -h -k 7 | tail -n 10
}
source ~/Sandbox/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source ~/Sandbox/zsh-history-substring-search/zsh-history-substring-search.zsh
source ~/Sandbox/zsh-autosuggestions/autosuggestions.zsh
fpath=(~/Sandbox/zsh-completions/src $fpath)
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
zle-line-init() {