Skip to content

Instantly share code, notes, and snippets.

@tomtaylor
tomtaylor / gist:7039271
Last active December 25, 2015 20:59
Build script for Buildbox.io, which uses parallel-tests to run multiple parallel test processes, and notifies Campfire on start, success and error.
#!/bin/bash
# Exits bash immediately if any command fails
set -e
# Will echo commands as the run
set -x
# Configure these
BUILDBOX_TEAM=""
@tomtaylor
tomtaylor / cloudfront_signer.rb
Created September 5, 2013 14:08
Class to sign private CloudFront URLs, supporting passing Cache-Control and Content-Disposition headers through to S3.
class CloudfrontSigner
def initialize(distribution, private_key, key_pair_id)
@distribution = distribution
@private_key = OpenSSL::PKey::RSA.new(private_key)
@key_pair_id = key_pair_id
end
def signed_url(path, expires_at, options = {})
# AWS operates in UNIX time
@tomtaylor
tomtaylor / base58.rb
Created April 25, 2013 06:48
Base58 encoder and decoder in Ruby, suitable for converting to/from Flickr short URLs.
module Base58
class InvalidCharacterError < RuntimeError; end
ALPHABET =
%w(
1 2 3 4 5 6 7 8 9
a b c d e f g h i
j k m n o p q r s
t u v w x y z A B
@tomtaylor
tomtaylor / gist:2982538
Created June 24, 2012 09:00
Satellite Eyes
rm -r ~/Library/Application Support/Satellite Eyes
rm ~/Library/Preferences/uk.co.tomtaylor.SatelliteEyes.plist
@tomtaylor
tomtaylor / indesign_server.wsdl
Created June 19, 2011 14:04
InDesign Server WSDL
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Service"
targetNamespace="http://localhost:80/Service.wsdl"
xmlns:tns="http://localhost:80/Service.wsdl"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:IDSP="http://ns.adobe.com/InDesign/soap/"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
%% @author Northscale <info@northscale.com>
%% @copyright 2010 NorthScale, Inc.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
mu:inception tom$ make
gcc -g -Wall -m32 -c -o inception.o inception.c
gcc -g -Wall -m32 -g -o inception inception.o -lpthread
mu:inception tom$ ./inception
Dreamer [Fischer], level [1], priority [19], policy [OTHER]
Dreamer [Cobb], level [1], priority [19], policy [OTHER]
Dreamer [Ariadne], level [1], priority [19], policy [OTHER]
Dreamer [Arthur], level [1], priority [19], policy [OTHER]
Dreamer [Eames], level [1], priority [19], policy [OTHER]
Dreamer [Saito], level [1], priority [19], policy [OTHER]
require 'rubygems'
require 'sinatra'
require 'dm-core'
require 'dm-validations'
require 'dm-timestamps'
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/messages.sqlite3")
class Message
include DataMapper::Resource
#!/usr/bin/ruby
require 'rubygems'
require 'net/http'
require 'rio'
body = Net::HTTP.get 'minneapolisfuckingrocks.blogspot.com', '/2009/01/diplo-remix-collection.html'
body.scan(/http:\/\/[a-zA-Z0-9_\.\/]*mp3{1}/).each {|link| rio(link) > rio(File.basename(link))}
class String
require 'rexml/parsers/pullparser'
def truncate_html(len = 30)
p = REXML::Parsers::PullParser.new(self)
tags = []
new_len = len
results = ''
while p.has_next? && new_len > 0