Skip to content

Instantly share code, notes, and snippets.

View gist:73663

Cable management in the living room

Attach two cable hooks to the back of each table leg. Run all cables through these, signal on one side and power on the other.

Get an end table for next to the couch and give it the same treatment as the table, except for the cable modem, router, mac and drive. Get a UPS for the mac so it doesn't keep dying in the middle of the day.

View example calories file
# command-line calorie tracker
# - everything is a recipe
# - recipes can contain other recipes
# - resolve recipes as far as possible
# - if a recipe doesn't resolve, report it as the given name
# - unit conversions via recipes
# - each dated entry has one or more recipes
# recipe: count unit label(?) equivalent(?)
# equivalent: '=' recipe(s /,/)
View capture-tweets.pl
#!/usr/bin/env perl
use strict;
use warnings;
use Try::Tiny;
use IO::File;
use JSON::XS qw/ decode_json /;
use File::Slurp qw/ read_file /;
View gist:605504
#!/usr/local/bin/perl58 -w
use strict;
my @replacements = qw/
alter
table
add
View gist:605519
# <-Foo> => random singular element from @Foo, hyphenated
# <^Foo> => random singular element from @Foo, capitalized
# <&Foo> => random singular element from @Foo with the first word capitalized
# <.Foo> => random singular element from @Foo, with the first word lowercased
# <!Foo> => random singular element from @Foo, ALLCAPS
# <*Foo> => random singular element from @Foo with articles stripped
# <,Foo> => random singular element from @Foo with spaces replaced with underscores
# <+Foo> => random singular element from @Foo with spaces replaced with plusses
View gist:705447
select (
select
date_trunc('day', date_page_requested)
from
ua_user_page_requests
where
page_request_no = x.page_request_no
) as day,
@peterkeen
peterkeen / balance_sheet.pl
Created Dec 31, 2010
Calculates month-over-month and year-over-year balances using ledger and SQLite
View balance_sheet.pl
#!/usr/bin/env perl
use strict;
use warnings;
use DBI;
my ($year, $month, $day) = get_date();
my @balances = (
@peterkeen
peterkeen / gist:808562
Created Feb 2, 2011
Add this to your [aliases] section in ~/.gitconfig
View gist:808562
alias = "!sh -c '[ $# = 2 ] && git config --global alias.\"$1\" \"$2\" && exit 0 || echo \"usage: git alias <new alias> <original command>\" >&2 && exit 1' -"
View gist:840678
$ cat run
cat run
#!/bin/sh
nohup bash -c 'while true; do sleep 10; done' </dev/null &> sleeper.log &
echo $! > /tmp/sleeper.pid
;
$ sudo ./run
sudo ./run
[sudo] password for pak:
@peterkeen
peterkeen / gist:1025209
Created Jun 14, 2011
SQLAlchemy Session from DBAPI Connection
View gist:1025209
def session_from_connection(conn):
def passthrough_conn():
return conn
# note that the url here doesn't matter, but it has to parse correctly as a url
engine = create_engine('postgresql://foo@bar/abc', creator=passthrough_conn)
session = Session(bind=engine)