Skip to content

Instantly share code, notes, and snippets.

views/cat/permissions/edit
models/cat/permissins.rb
controller
authorize! :historical_valuations, @company
app/models/ability.rb
menu items
_menu_bar.haml
report_center.haml
@tdowling
tdowling / gist:38a1c5c600ca78e7f55e
Created October 30, 2014 22:22
Commit message to add branch name and newlines to pre-commit hook on osx
#!/bin/bash
BRANCH_NAME=$(git branch | grep '^*' | sed 's/^* //')
sed -i "" "1s/^/$BRANCH_NAME \\"$'\n'"\\"$'\n'"https:\/\/jira.company.com\/browse\/$BRANCH_NAME/" $1
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@tdowling
tdowling / introrx.md
Last active August 29, 2015 14:03 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@tdowling
tdowling / gist:9666572
Last active August 29, 2015 13:57
option transactions on the same day
SELECT aa1.activity,
aa2.activity,
aa1.date,
aa1.account_id
FROM account_activities aa1
RIGHT JOIN account_activities aa2 ON aa1.account_id = aa2.account_id
AND aa1.date = aa2.date
AND aa1.fund_id = aa2.fund_id
AND aa1.activity <> aa2.activity
JOIN funds f ON aa1.fund_id = f.id
@tdowling
tdowling / .psqlrc
Created October 8, 2013 20:47 — forked from bidulock/.psqlrc
-- Include the hostname in the prompt, and add a * when in a transaction
-- The default PROMPT2 doesn't make it obvious enough nothing has been sent to the server yet
\set PROMPT1 '%M:%/%R%x%# '
\set PROMPT2 '> '
-- Always be in a transaction. It's safer this way
\set AUTOCOMMIT off
-- Turn the pager on always. This is best used with "export PAGER=less -S -F -X" added to your .bashrc
\pset pager always
@tdowling
tdowling / copy a db in postgres
Last active December 12, 2015 07:09
Copy a database in postgres
/usr/lib/postgresql/9.2/bin/pg_dump -U sofi -n public -h yyc-sofidb01 sofi_production > /tmp/tavis-full.sql; echo 'grant all on database sofi_dev to sofi;' >> /tmp/tavis-full.sql;
sudo su - postgres;
kill `ps -f -U postgres | grep sofi | grep -v grep | awk '{print $2}'` ; dropdb sofi_dev ; createdb sofi_dev ; psql -d sofi_dev -1 -f /tmp/tavis-full.sql