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
var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | |
$(function() { | |
var names, user_id; | |
if ($('#new_journal_entry').length) { | |
console.log('going for it'); | |
user_id = $('#journal_entry_friend_ids').data('user'); | |
console.log("kicking things off with " + user_id); | |
names = new Bloodhound({ | |
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), |
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 self.get_institution(financial_institution_name, ofx_client_id=nil, ssl_version=nil) | |
case financial_institution_name | |
when 'USAA' | |
FinancialInstitution.new('USAA', | |
URI.parse('https://service2.usaa.com/ofx/OFXServlet'), | |
OFX::Version.new("1.0.2"), | |
'USAA', '24591', '314074269', | |
ofx_client_id, ssl_version) |
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
OFXHEADER:100 | |
DATA:OFXSGML | |
VERSION:102 | |
SECURITY:NONE | |
ENCODING:USASCII | |
CHARSET:1252 | |
COMPRESSION:NONE | |
OLDFILEUID:NONE | |
NEWFILEUID:20140212045536 |
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
function [P1, P2] = plot_power | |
P1files = {'10_1.txt', '10_2.txt'}; | |
P2files = {'11_1.txt', '11_2.txt'}; | |
P1 = combine(P1files, 'Meter 1'); | |
P2 = combine(P2files, 'Meter 2'); | |
h = figure; | |
subplot(2,1,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
> sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL | |
NAME FSTYPE SIZE MOUNTPOINT LABEL | |
loop0 squashfs 637.8M /rofs | |
sda 223.6G | |
├─sda1 ntfs 350M System Reserved | |
└─sda2 ntfs 223.2G | |
sdb 1.8T | |
└─sdb1 ext4 1.8T BigBackup | |
sdc ext4 1.8T SecondBackup |
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 to_fdf | |
fdf = header | |
@data.each do |key, value| | |
if Hash === value | |
value.each do |sub_key, sub_value| | |
fdf << field("#{key}_#{sub_key}", sub_value) | |
end | |
else | |
fdf << field(key, value) |
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
data = <<-DATA | |
2007, 1 | |
2008, 2 | |
2009, 3 | |
2010, 4 | |
2011, 5 | |
2012, 6 | |
DATA | |
data.split("\n").each do |year, value| |
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
st = week_num.weeks.ago.beginning_of_week(start_day = :thursday) | |
weeks = [] | |
while st < Date.today | |
weeks << st | |
st = st.next_week(:thursday) | |
end | |
weeks |
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 test_the_ability_to_get_exact_transations_for_a_week | |
VCR.use_cassette('expense_test_pull') do | |
st = DateTime.parse("2014-01-30 00:00:00 UTC") | |
ed = DateTime.parse("2014-02-05 23:59:59 UTC") | |
expenses = ExpenseTracker.get_expenses_from_daily_spending(st, ed) | |
expenses.each do |e| | |
assert e[:date_posted].to_i === st.to_i..ed.to_i | |
end | |
end | |
end |
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 get_expenses_from_daily_spending(st, ed) | |
attempts = 0 | |
trans = [] | |
loop do | |
attempts = attempts + 1 | |
raise "too many attempts, api is jacked up" if attempts > 5 | |
# load transactions | |
resp = request_statement(st, ed) | |
transactions, range = resp.transactions, resp.transaction_range | |
# test if valid and break if valid |
OlderNewer