Skip to content

Instantly share code, notes, and snippets.

View dsingleton's full-sized avatar

David Singleton dsingleton

View GitHub Profile
#!/usr/bin/python
import sys
labels = []
values = []
for line in sys.stdin:
value, label = line.strip().split(' ')
labels.append(label)
#!/usr/bin/python
import sys
labels = []
values = []
for line in sys.stdin:
value, label = line.strip().split(' ')
labels.append(label)
<?php
$aOutput = array();
$aLines = explode("\n", file_get_contents($argv[1]));
$aKeys = explode("\t", array_shift($aLines));
foreach($aLines as $line) {
if (!trim($line)) {
<script type="text/javascript">
// Assumed prototypejs installed
function video_search(results)
{
try {
var oEmbedURL = "http://vimeo.com/api/oembed.json?"
var params = {
callback: 'video_oembed',
#counter {
width: 16px;
height: 16px;
border: 1px solid #aaa;
background: url('sprite_2col.png') 0 0 no-repeat;
}
#counter.frame_1 { background-position: 0 -17px; }
#counter.frame_2 { background-position: 0 -34px; }
# Using standard lib methods
assert redirect? "not redirected"
query_hash = CGI.parse(URI.parse(redirected_to).query)
assert query_hash.fetch(query_param, false), "'#{query_param}' param is not set, or has an empty value"
url = URI.parse(url)
params = CGI.parse(url.query || '')
params[query_param] = query_hash[query_param]
url.query = params.map{|k,v| "#{CGI::escape(k)}=#{CGI::escape(v.first)}"}.join('&')
#bufferList p.join {
background: #527DFF;
height: 16px;
position: absolute;
right: 4px;
top: 4px;
width: 16px;
overflow: hidden;
}
@dsingleton
dsingleton / jira_story_summary.bookmarklet
Created December 9, 2010 14:27
How to extract a nice Story summary from JIRA in bookmarklet JS
"* " + $('customfield_10001-val').innerHTML.trim() + " points - '''" + ($$('#issue_header_summary a')[0].innerHTML) + "''' - [" + document.location.toString() + " " + ($('key-val').innerHTML) + "]"
@dsingleton
dsingleton / php-wrap.sh
Created February 7, 2011 14:48
A simple shell script to repeatedly run a PHP script until it returns a successful code
#!/bin/bash
RES=256
while [ $RES != 0 ]
do
if [ $RES != 256 ]
then
sleep 2
fi
/usr/bin/env php $*
RES=$?
@dsingleton
dsingleton / gist:894135
Created March 30, 2011 09:43
Twitter noob user states
noob: {
dismissed: -2,
notNoob: -1,
total: 0,
invited: 1,
friendless: 2,
silent: 3,
talking: 4,
popular: 5,
lonely: 6,