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
# Based on http://stackoverflow.com/questions/2299139/retrieve-all-associations-attributes-of-an-ar-model | |
# Doesn't spelunk, doesn't name associations for easy consumption back. Good first go though. | |
# It gives the object attributes with the attributes of first cousin associations. | |
class ActiveRecord::Base | |
def attributes_with_associations | |
association_names = self.class.reflect_on_all_associations.collect { |r| r.name } | |
me = self.class.find self.id, :include => association_names | |
pairs = association_names.collect do |association_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
#!/usr/bin/env ruby | |
# This prints a table showing how much a monthly payment | |
# would need to be to pay off a loan. It takes a max and | |
# min loan amount, and how much to jump between them. I | |
# use it to dream about paying off student loans. It allows | |
# me to see what my 1 year pay-off payments are as the loan | |
# gets paid back. | |
class PaymentCalculator |
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
;; elisp | |
(setq jira-base-url "<JIRA BASE URL>" | |
jira-request-url (concat "https://" jira-base-url "/rest/api/latest/issue/") | |
jira-username "<USERNAME>" | |
jira-password "<PASSWORD>" | |
jira-credentials (base64-encode-string (concat jira-username ":" jira-password)) | |
;; this is a regex to trim things off the branch name | |
;; as is, removes: dev-, rel-, av-, dev/, rel/, av/ | |
jira-branch-trim-regex "^\\(dev\\|rel\\|\\av\\)\\(-\\|/\\)" | |
jira-auth-key (concat jira-base-url ":443")) |
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
require 'rspec/core/formatters/base_text_formatter' | |
# RSpec 2 | |
# rspec --require <path_to>/line_formatter.rb --format LineFormatter spec/ | |
# ./spec/lib/a_spec.rb:39 | |
# Success Thing#with_thing does thing | |
# | |
# ./spec/lib/a_spec.rb:45 | |
# pending Thing#does_other_thing is pending |
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 ruby | |
require 'date' | |
class Repayment | |
MONTHLY_INTEREST = (<INTEREST (5.00)> / 12 / 100) | |
def initialize(payment, principal) | |
@payment, @principal = payment, principal | |
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
#!/usr/bin/env bash | |
# Prevents force-pushing to certain branches w.o confirmation | |
# install to <repo>/.git/hooks/ | |
# chmod +x | |
protected_branches="^(master|production)" | |
current_branch=`git rev-parse --abbrev-ref HEAD` | |
push_command=`ps -ocommand= -p $PPID` | |
force_push="force|delete|-f" |
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
require 'pp' | |
require 'irb/completion' | |
IRB.conf[:AUTO_INDENT]=true | |
require 'irb/ext/save-history' | |
IRB.conf[:SAVE_HISTORY] = 100 | |
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" |
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
# ~/.bash_profile | |
# give prompt as ~/foo(branch_name*) | |
# where the * indicates uncommitted work | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
export PS1='\[\033[36;40m\]\w\[\033[0;33m\]$(parse_git_branch)\[\e[0m\]$ ' |
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 ruby | |
# console, generally inspired by rails console | |
# | |
# put in root of project, adjust file paths and the like | |
# chmod the file to be executable by you | |
# run: | |
# project_root >> ./console |
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
;; keep a single instance of Emacs I can send crap to | |
;; allows me to do things like this in my bash profile | |
;; export GIT_EDITOR=/Applications/Emacs.app/Contents/MacOS/bin/emacsclient | |
;; send files to emacs from the command line as 'emacsclient <filename>' | |
(server-start) | |
;; 2 spaces instead of 4 for javascript | |
(setq js-indent-level 2) | |
;; turn on linum for mode xxx |
OlderNewer