Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
while true
do
num=$(ec2-describe-instances | grep running | wc -l | awk '{print $1}')
echo $num
[[ $num < 15 ]] && say yo yo yo yo yo yo yo yo
sleep 300
done
@csexton
csexton / page.json
Created March 7, 2014 18:50
Mike Amundsen's Pagination Suggestion from the json+collection mailing list
// sample paging
{
"collection" :
{
"version" : "1.0",
"href" : URI,
"links" : [
{"href" : "...", "rel" : "first"},
{"href" : "...", "rel" : "previous"},
{"href" : "...", "rel" : "next"},
{
  "users": [{
    "id": "1",
    "name": "Guille",
    "posts": { "href": "http://example/posts" },
    "links": {
      "posts": [1,2,3,4,5]
    }
 }]
#define AppDelegate (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
@csexton
csexton / jbuilder.rb
Created March 14, 2014 04:35
Extend the jbuilder api to support JSON API conventions
class Jbuilder
def links! model, *args
args.each do |arg|
if model.reflections[arg].collection?
_set_value arg, model.send(arg).map(&:id)
else
_set_value arg, model.send(arg).id
end
end
end
@csexton
csexton / post-receive
Created April 15, 2014 04:22
radbot.git/hooks/post-receive
#!/bin/bash
echo "Deploying radbot, yo"
GIT_WORK_TREE=/var/radbot git checkout -f
echo "Bundling like a boss"
cd /var/www/radbot && bundle update
echo "Restarting radbot"
#!/bin/bash
cd /Users/csexton
# Rsync to Dreamhost
OPTIONS="-e ssh --relative --compress --archive --delete-excluded --progress --human-readable "
SERVER="backup.remote:cs-dewback"
rsync $OPTIONS Projects Pictures Documents $SERVER \
--exclude="OmniFocus Backups" \
--exclude="*vmwarevm" \
require 'rspec'
require 'rspec/autorun'
def pack_size(desc)
if (desc.match(/([\d]+)[\s]pack/i))
$1.to_i
else
1
end
end
def pack_size(desc)
if (desc.match(/([\d]+)[\s]pack/i){ |m| pack_count = m[:pack_count].to_i }
$1.to_i
else
1
end
end
def pack_size(desc)