Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
#
# Textmate command for inserting a random string
#
# Input: none
# Output: Insert as text
# based on: http://stackoverflow.com/questions/88311/how-best-to-generate-a-random-string-in-ruby
o = [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten;
#!/usr/bin/env sh
# Input: Entire Document
# Output: Replace Document
java -jar ~/bin/yuicompressor-2.4.2.jar $TM_FILEPATH
@robballou
robballou / import_to_mongo.py
Created December 16, 2010 21:31
Import delicious bookmark XML to mongodb
#!/usr/bin/env python
"""
Python script to copy a delicious XML file into a mongodb.
Essentially saves all attributes from the XML as-is, but I do make the following changes:
- Added a "tags" attribute to the saved document that separates the tags into a list
- Converted the "time" attribute to a datetime
// send an asynch request to http://localhost/some.json (a JSON file)
NSURL *url = [NSURL URLWithString:@"http://localhost/some.json"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
/*
Got data from the web service
*/
- (void)requestFinished:(ASIHTTPRequest *)request {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// Use when fetching text data
NSString *responseString = [request responseString];
// parse the response
SBJsonParser *parser = [SBJsonParser new];
@robballou
robballou / channels.sh
Created February 25, 2011 15:59
Find the number of channels in an audio file
#!/bin/bash
#
# Usage:
# ./channels.sh [filename]
#
echo "$1: " `ffmpeg -i "$1" 2>&1 | awk '/[[:digit:]] channels?/ {print "Channels:",$7}'`
@robballou
robballou / gist:929564
Created April 19, 2011 20:31
Example python of how to add DNS entries to Amazon's Route 53 with the boto library
from boto.route53.connection import Route53Connection
# your amazon keys
key = ""
access = ""
if __name__ == '__main__':
zones = {}
route53 = Route53Connection(key, access)
@robballou
robballou / sha.py
Created May 31, 2011 21:06
Hash strings using a number of different algorithms
#!/usr/bin/env python
"""
Output hash for a string
If not string is specified, then prompt for one (good for passwords). By default
the script will use SHA1, but you can specify any of the following:
--all (or -a)
--base64 (or -b)
@robballou
robballou / gist:1040490
Created June 22, 2011 16:36
Rotatelib EC2 example
import datetime
import rotatelib
"""
When you call list_archives or remove_items with an ec2snapshots argument, the library
will look in your environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
If you do not want to use environment variables, you can pass those in as keyword args
(aws_access_key_id and aws_secret_access_key).
"""
# your merge test command
svn merge --dry-run -r 100:HEAD http://example.com/svn/repo/trunk .
# go ahead and run it after everything looks ok...
^--dry-run ^^