Skip to content

Instantly share code, notes, and snippets.

View grega's full-sized avatar

Greg Annandale grega

View GitHub Profile
@grega
grega / Perch Custom Multisort
Created September 17, 2011 13:31
For a schedule, such as http://futureofwebapps.com/london-2011/schedule/ (run the loop for each day). Needs to sort by time & then by track, ie. 2 sessions have an 11am start, 1 is 'Track 1' the other is 'Track 2'. 'Track 1' must be listed first.
<?php
function array_push_assoc($array, $key, $value){
$array[$key] = $value;
return $array;
}
$opts = array(
'template'=>'schedule.html',
'page'=>'/page.php',
'skip-template'=>true
@grega
grega / fabfile.py
Last active April 19, 2021 13:47
Sample Fabric 'fabfile' for deploying to multiple hosts. Using: `fab deploy stage` or `fab deploy live`. Deploy to live prompts the user to confirm (with 'y' or 'n') that they actually want to deploy. Deploy tasks runs git pull & any number of utility commands (eg. asset compilation, checking / fixing folder permissions etc).
from __future__ import with_statement
from fabric.api import env, local, settings, abort, run, cd, sudo
from fabric.contrib.console import confirm
# Hosts
def stage():
env.user = 'deploy_user'
env.hosts = ['xxx.xxx.xxx.xxx:22']
global code_dir
code_dir = '/var/www/stage.website.com' # no trailing slash
@grega
grega / vbox-status-check.sh
Last active January 26, 2019 16:27
Output the total number of currently running VirtualBox VMs, along with their names. This has been written with Vagrant in mind, where VMs are named `hostname_default_xxxxxxxxx` where only the value of `hostname` is relevant/recognisable.
#!/bin/bash
machines=()
for machine in `VBoxManage list runningvms|cut -d" " -f 1`; do
machines+=("$machine")
done
if [ ${#machines[@]} -eq 1 ]; then
machinename=$(echo ${machines[@]} | cut -d'_' -f 1)
@grega
grega / shh.rb
Created March 8, 2018 15:01 — forked from robinsloan/shh.rb
Disable RTs from all the people you follow on Twitter.
require "rubygems"
require "twitter"
# get these from apps.twitter.com
CONSUMER_KEY = "foo"
CONSUMER_SECRET = "bar"
OAUTH_TOKEN = "blee"
OAUTH_TOKEN_SECRET = "baz"
TWITTER_USER = "your_username" # needs to be the one associated with keys above
@grega
grega / keybase.md
Created March 9, 2018 16:21
keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object: