This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def some_anonymous_function(arg1, arg2): | |
print "%s %s" % (arg1, arg2) | |
def some_named_function(func, arg1, arg2): | |
func(arg1, arg2) | |
some_named_function(some_anonymous_function, arg1, arg2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ irb | |
irb | |
>> a = 1 | |
a = 1 | |
=> 1 | |
>> a[0] | |
a[0] | |
=> 1 | |
>> a[1] | |
a[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> foo = { 'a': 1, 'b': 2 } | |
>>> foo.update({'b': 444444, 'c': 3}); | |
>>> foo | |
{'a': 1, 'c': 3, 'b': 444444} | |
>>> dict(bar='baz', **foo) | |
{'a': 1, 'c': 3, 'b': 444444, 'bar': 'baz'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2011/07/05 * Eat At Joe's | |
Expenses:Dinner $50.00 | |
Liabilities:Credit Card | |
; :reimbursable: | |
2011/07/06 * Drink At Fred's | |
Expenses:Drinks $25.00 | |
Liabilities:Credit Card | |
; :reimbursable: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias = "!sh -c '[ $# = 2 ] && git config --global alias.\"$1\" \"$2\" && exit 0 || echo \"usage: git alias <new alias> <original command>\" >&2 && exit 1' -" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use DBI; | |
my ($year, $month, $day) = get_date(); | |
my @balances = ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select ( | |
select | |
date_trunc('day', date_page_requested) | |
from | |
ua_user_page_requests | |
where | |
page_request_no = x.page_request_no | |
) as day, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# <-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 |