Skip to content

Instantly share code, notes, and snippets.

# copy this to ~/.bashrc
_complete_ssh_hosts () {
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`
grep "^host " ~/.ssh/config | \
awk '{print $2}'
`
COMPREPLY=( $(compgen -W "${comp_ssh_hosts}" -- $cur))
#!/usr/bin/env python
import os
import feedparser
import pprint
import subprocess
TED_FEED = "http://feeds.feedburner.com/tedtalks_video"
def need_to_download(entries):
for entry in entries:
#! /bin/bash
### BEGIN INIT INFO
# Provides: riak
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@roder
roder / pbcopy.rb
Created August 18, 2010 05:27 — forked from defunkt/pbcopy.rb
def pbcopy(string)
pasteBoard = NSPasteboard.generalPasteboard
pasteBoard.declareTypes([NSStringPboardType], owner: nil)
pasteBoard.setString(string, forType: NSStringPboardType)
end
#!/bin/bash
# This utility is useful for extracting the field names from a SQL to CSV export
#
# csvheadpivot will scan the current working directory for CSV files. When it
# encounters a CSV file the utility assumes the CSV file has a header row and
# any CSV files with more than one row has data.
#
# When encountering a CSV with data, the utility will grab the header row and
# pivot it to a single column.
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@roder
roder / client.html
Created December 3, 2010 01:47
Toy server
<html>
<head></head>
<body>
<p><textarea cols=100 rows=25 id="output"></textarea></p>
</body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var client = new function() {
var lastid=0;
@roder
roder / gist:726561
Created December 3, 2010 03:57
Garbage Collection Trace
(toy)$ node --trace-gc ToyServer.js
Scavenge 1.0 -> 1.0 MB, 1 ms.
Scavenge 1.9 -> 1.8 MB, 0 ms.
Toy Server initialized at port 8000
Scavenge 2.1 -> 2.1 MB, 1 ms.
Mark-sweep 2.1 -> 1.8 MB, 3 ms.
Mark-compact 1.8 -> 1.8 MB, 8 ms.
Scavenge 2.5 -> 2.1 MB, 0 ms.
Scavenge 2.6 -> 2.2 MB, 0 ms.
Scavenge 2.8 -> 2.4 MB, 0 ms.
Example = fun(Arg) ->
case Arg of
ohai ->
io:format("OHAI!~n");
foo ->
io:format("Foo!~n");
bar ->
io:format("Bar!~n");
_EverythingElse ->
io:format("~p~n",[_EverythingElse])
@roder
roder / xmlsqlite.py
Created December 16, 2010 04:49
Convert XML files into SQLite
#!/usr/bin/env python
from optparse import OptionParser
from xml.dom.minidom import parse
import os
import sqlite3
datatypeMap = {
'integer': 'INT',
'datetime': 'DATETIME',