Skip to content

Instantly share code, notes, and snippets.

Avatar

Travis Dahlke travisdahlke

View GitHub Profile
View genesis_public_key
0493501e5e56d04d536e2756649222383e40c082d59547f51516bf5a425f705d1335b34e15b7e824a7ff7089c86a5c46b00bcbad3ed9c4c18d19b598d45221ee45
View index.html
<!DOCTYPE html>
<html >
<head>
<title>deco</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="MNt1KcKC+OArhq5ZheeoEGzsYX/OzEPvLFI9XrIL2N03Fuimu2oISR9+I23+2eTxljGnh1/OnyZ70LBZMR7MZA==" />
<title>Deco</title>
<meta name="twitter:card" content="summary" />
View ledger2beancount.py
#!/usr/bin/python
import ledger
import sys
import re
def account_name(post):
account = post.account.fullname().replace(" ","").replace("(","").replace(")","").replace("'","")
return re.sub(r'\:(\d)',r':X\1', account)
View keybase.md

Keybase proof

I hereby claim:

  • I am travisdahlke on github.
  • I am travisd (https://keybase.io/travisd) on keybase.
  • I have a public key whose fingerprint is 1D08 EC6D 3564 9388 EB17 3193 AB2B F207 D73E E5F8

To claim this, I am signing this object:

@travisdahlke
travisdahlke / gist:7107244
Last active Dec 26, 2015
Ruby variable scoping can be tricky sometimes. Ruby will initialize the local variable 'foo' even though that line is never executed. Since it's now in the local scope, the method 'foo' doesn't get run during the second if.
View gist:7107244
class Thing
def foo
"foo"
end
def bar
puts foo
if foo.nil?
foo = "bar"
end
View conditional_array.rb
# This option has the most clarity, but I generally hate local variables in a
# method, preferring to use tap.
def calculated_foo
available_foos = []
available_foos << bar
available_foos << baz.qux if baz
available_foos.max
end
# It's a little less clear, unless you know what tap is, and `end.max` is
@travisdahlke
travisdahlke / mongo_add_test.js
Created Mar 19, 2013
Mongo 2.4 $add nulls test
View mongo_add_test.js
use agg_test;
test_add = function() {
var t = db.things;
t.drop();
t.insert({a: 2, b: 3});
var total1 = t.aggregate({$project:{total:{$add:["$a","$b"]}}}).result[0].total;
print("a + b = " + total1);
var total2 = t.aggregate({$project:{total:{$add:["$a","$b","$c"]}}}).result[0].total;
print("a + b + c = " + total2);