Skip to content

Instantly share code, notes, and snippets.

View spikegrobstein's full-sized avatar

spike grobstein spikegrobstein

View GitHub Profile
@spikegrobstein
spikegrobstein / get_version.sh
Created November 2, 2010 19:16
Prints the version of a .app or .bundle in OSX
#! /bin/bash
##
# returns the version of the OSX application that's passed to the script
# can determine if you're passing a bundle or an application (.bundle | .app | .component)
# and figure out the proper info
#
# written by Spike Grobstein
# spike.grobstein@wmg.com
# 2010/11/02
@spikegrobstein
spikegrobstein / random_pw
Created November 2, 2010 23:23
random password generator for OSX
#! /bin/bash
##
# spit out random password. default length of 32 characters
# usage:
# ./random_pw <pw_length>
##
COUNT=$1
DEFAULT_COUNT=32
@spikegrobstein
spikegrobstein / throughput.rb
Created November 9, 2010 01:11
shows current throughput (per second) on the selected interface
# usage:
# netstat -I bond0 -w 1 -b | ruby throughput.rb
# shows throughput on selected interface (OSX only)
def parse_line(line)
column_titles = [ :packets_in, :errs_in, :bytes_in, :packets_out, :errs_out, :bytes_out, :colls ]
columns = line.split(/\s+/)
columns.shift
columns = columns.collect { |c| c.to_i }
@spikegrobstein
spikegrobstein / gist:669444
Created November 9, 2010 17:29
rot13 implementation in brainfuck (codegolf example code)
+[,+[-[>+>+<<-]>[<+>-]+>>++++++++[<-------->-]<-[<[-]>>>+[<+<+>>-]<[>+<-]<[<++>
>>+[<+<->>-]<[>+<-]]>[<]<]>>[-]<<<[[-]<[>>+>+<<<-]>>[<<+>>-]>>++++++++[<-------
->-]<->>++++[<++++++++>-]<-<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<<<<+>>>>++++[<++++++++
>-]>-]<<-<-]>[<<<<[-]>>>>[<<<<->>>>-]]<<++++[<<++++++++>>-]<<-[>>+>+<<<-]>>[<<+
>>-]+>>+++++[<----->-]<-[<[-]>>>+[<+<->>-]<[>+<-]<[<++>>>+[<+<+>>-]<[>+<-]]>[<]
<]>>[-]<<<[[-]<<[>>+>+<<<-]>>[<<+>>-]+>------------[<[-]>>>+[<+<->>-]<[>+<-]<[<
++>>>+[<+<+>>-]<[>+<-]]>[<]<]>>[-]<<<<<------------->>[[-]+++++[<<+++++>>-]<<+>
>]<[>++++[<<++++++++>>-]<-]>]<[-]++++++++[<++++++++>-]<+>]<.[-]+>>+<]>[[-]<]<]
!input goes here
<?php
//Use this to tunnel a file through json for crossdomain access.
try {
$uri = $_GET['uri']; // the URI that we're fetching
$callback = $_GET['_callback']; // the callback that's used with jsonp (optional)
if (is_null($_GET['uri'])) {
throw new Exception('Bad URI');
@spikegrobstein
spikegrobstein / uri_to_absolute.js
Created December 10, 2010 01:43
convert uri from href/src attribute to absolute-absolute URI given the relative servername and attribute value
function uri_to_absolute(server_name, uri) {
if (uri.match(/^#/)) {
return uri;
}
var m = server_name.match(/^((.+?\/\/[^\/]+)(.*))/);
var server_name = (m) ? m[2] : server_name;
var path = (m) ? m[3] : '';
@spikegrobstein
spikegrobstein / gist:1033390
Created June 18, 2011 18:45
reddit bookmarklet for images
javascript:%20var%20x%20=%20$(%22div.content%20div.entry%20a.title%22).each(function()%20{var%20href%20=%20$(this).attr(%22href%22);var%20title%20=%20$(this).text().toLowerCase();if%20(title.indexOf(%27[m]%27)%20>=%200%20&&%20title.indexOf(%27[f]%27)%20<%200)%20{%20return;%20}if%20((!$(this).hasClass(%22drowsapMorphed%22))%20&&%20($(this).next(%22.drowsapMorphed%22).length%20==%200)%20&&%20href%20&&%20(href.indexOf(%27imgur%27)%20>=%200%20||%20href.indexOf(%27jpeg%27)%20>=%200%20||%20href.indexOf(%27jpg%27)%20>=%200%20||%20href.indexOf(%27png%27)%20>=%200))%20{var%20ext%20=%20(href.indexOf(%27imgur%27)%20>=%200%20&&%20href.indexOf(%27jpg%27)%20<%200%20&&%20href.indexOf(%27png%27)%20<%200)%20?%20%27.jpg%27:%20%27%27;var%20img%20=%20$(%22<a%20class=%27drowsapMorphed%27%20href=%27%22%20+%20href%20+%20%22%27%20target=%27blank%27%20style=%27display:block%27><img%20style=%27display:block;max-width:780px;%27%20src=%27%22%20+%20href%20+%20ext%20+%20%22%27%20/></a>%22);$(this).after(img);}});
@spikegrobstein
spikegrobstein / gist:1115098
Created July 30, 2011 01:49
benchmarking static vs objects in JS
function build_static() {
var Frontrunner = (function(){
var FR = null;
var name = "spike";
return {
init: function() {
FR = this;
return this;
},
@spikegrobstein
spikegrobstein / fork_example.c
Created November 25, 2011 05:12
code for sam
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#define DEFAULT_PROCESS_COUNT 4
int process_count = DEFAULT_PROCESS_COUNT;
void do_work(int pid);
@spikegrobstein
spikegrobstein / pgpool.sh
Created January 13, 2012 22:47
pgpool init script for centos
#!/bin/sh
#
# pgpool - the postgres replication daemon.
#
# chkconfig: 2345 64 36
# description: start and stop the pgpool daemon
### BEGIN INIT INFO
# Provides: pgpool