Skip to content

Instantly share code, notes, and snippets.

View jcsalterego's full-sized avatar

Jerry Chen jcsalterego

View GitHub Profile
(global-set-key (kbd "ESC M-w") 'gist-region)
(load-file "~/.emacs.d/gist.el/gist.el")
(require 'gist)
(global-set-key (kbd "ESC M-w") 'gist-region)
#!/usr/bin/env python
#
# Converts standard LDIF to a list of dicts
#
import sys
from base64 import b64decode
from pprint import pprint
SOURCE = "source.ldf"
#!/usr/bin/env python
#
# Generates OPML from Mail.app RSS Feeds
#
# Usage:
# $ python mailrss2opml.py > export.opml
#
import os
import stat
foreach ($node->taxonomy as $item) {
$parents = taxonomy_get_parents($item->tid);
$parents_used = array();
foreach ($parents as $item2) {
if ($item2->vid == 2 && !isset($parents_used[$item2->tid])) {
$parents_used[$item2->tid] = true;
}
}
var_dump(array_keys($parents_used));
#!/bin/sh
# first you'll want to create a gist then `git clone` the private url
# second you'll want to run this script in the gist's directory
while [ 1 ]; do
git commit -a -m save && git push origin master;
sleep $(echo "60 * 4" | bc);
done;
#include <iostream>
#include <vector>
using namespace std;
// prototype
vector<int> & buy();
int main ()
{
vector<int> j;
<?php
class URLConf
{
private $_conf = array();
private $_controller;
private $_method;
private $_args;
private $_default_controller;
#!/usr/bin/env python
#
"""
$ ./transmorgify.py
input: http://yahoo.com www.blah.com 13 monkey's @username blah
output: ['monkeys', 'blah']
input: Super impressive http://tr.im/lWb7 (via @jcsalterego)
output: ['Super', 'impressive', 'via']
input:
#
# How do I extract a parameter from a URL in plain Ruby?
# "http://foo.com/bar.html?a=sdfas&b=xyz Want the value of parameter a.
# - http://twitter.com/mperham/status/2019870182
#
URL = "http://foo.com/bar.html?a=sdfas&b=xyz"
paramify = lambda url: dict([kv.split("=")
for kv
in url.split("?")[1].split("&")])