Skip to content

Instantly share code, notes, and snippets.

@jamesob
jamesob / gist:1157814
Created August 19, 2011 19:47
sshfs mnt utility
#!/usr/local/bin/python
import argparse
import os
# User configuration
# ------------------
_MNT_DIR = "~/mnt/dev" # e.g. mount at ~/mnt/dev6
# ------------------
@jamesob
jamesob / gist:1212074
Created September 12, 2011 19:01
Anonymous functions are beautiful.
/*
* concise, but cryptic for the first two minutes you see this
*/
(function ($) {
$(selector).each(function () {
// code
});
$(selector).each(function () {
@jamesob
jamesob / harvover.py
Created February 15, 2012 16:48
Left the timer running in Harvest overnight...
#!/usr/bin/python
def hrs(curr_entry, left, started):
amt_sub = (24. - left) + started
return curr_entry - amt_sub
if __name__ == '__main__':
import sys
usage = (
@jamesob
jamesob / gist:1838892
Created February 15, 2012 20:47
HOT FIRE
<?php
/**
* Internal function for mapping a section term to a node given a term name.
*/
private function map_section_from_tax(&$node, $item, $term_names) {
$term_names = new ArrWrap($term_names);
$section_tids = $term_names
->map(array($this->tax_util, 'get_term'))
->map(function ($p) { return $p->field_tref_section[LANGUAGE_NONE][0]['tid']; })
@jamesob
jamesob / jenk-conf-nyc-2012.md
Created May 17, 2012 14:02
Jenkins conference NYC, May 2012

Jenkins, NYC, May 2012

Conference page

keynote, Kohsuke Kawaguchi

  • people from all over have come; isreal, prague, LA.
  • jenkins evolved from a few shell scripts, beginning in 2004, because the creator kept embarrassing himself with faulty builds.
@jamesob
jamesob / gist:2819803
Created May 28, 2012 15:48
Scraping Chase for CC transactions
from selenium import webdriver
import time
def get_chase_amazon_driver(username, password):
"""Return a logged-in Chase Amazon card selenium driver instance."""
driver = webdriver.Firefox()
driver.get("http://www.chase.com")
time.sleep(2)
@jamesob
jamesob / gist:2848628
Created June 1, 2012 04:00
Yearly expenses
Total expenses: -26153.759856

Profile of expenses:

 rent+utils     -14160.00          ------------------------------------------------------
 lunch          -2920.00           -----------
 dinner         -2920.00           -----------
 breakfast      -1460.00           -----
 unforeseen -1423.40 -----
@jamesob
jamesob / gist:2893854
Created June 8, 2012 05:54
Cash4/Williamsburg bridge mix

Cash4/Williamsburg bridge mix

Cash4

Cash4 taunts you as you're ascending the bridge from the Brooklyn end. He's
vulgar as hell, but encouraging in a weird kind of way. His block cursive in
flat, black paint makes the other graffiti look ostentatious. He glares in the
daylight.
@jamesob
jamesob / gist:3419060
Created August 21, 2012 20:23
Hubot and Jaconda.im integration

Hubot and jaconda.im

So you want Hubot in a jaconda.im room and responding nicely, right?

How you get it

Register the bot

Get an account for your Hubot registered on both jaconda.im and Google with identical login information. I'm not sure if matching is strictly necessary; I haven't tested it.

@jamesob
jamesob / check_df.py
Created November 13, 2012 18:16
Df check
#!/usr/bin/python
"""
Script that checks to see that disk usage is below a certain threshold.
Designed to be invoked by cron.
"""
from sh import df
import re