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
# uses xpath to check for a form element based on the label, | |
# instead of using a css selector w/ label_for | |
# name should be the complete name in the html page. | |
# meaning Title: and not Title | |
# find the label that is name. Get the "for" of the label | |
# uses the for to check for the input with that as an id | |
Then /^I should see a "([^\"]*)" for "([^\"]*)"$/ do |type, name| | |
case type |
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 |
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 grep_routes() { | |
ruby -e "ARGV[0].split(10.chr).each{|x| puts x if !ARGV[1..-1].map{|a| x =~ /#{a}/}.include?(nil)}" "$(rake routes)" "$@" | |
} | |
# USAGE | |
# > grep_routes this | |
# > grep_routes this that the other |
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
# in spec/spec_helper.rb, add this to make it work: | |
# require 'support/be_allowed_to' | |
# RSpec.configure |config| | |
# config.include(BeAllowedToMatcher) | |
# end | |
# | |
# allows: some_user.should be_allowed_to(:edit, thing) | |
# some_user.should be_allowed_to(:edit, :things) | |
# some_user.should be_allowed_to(:edit, thing, in_this_context) | |
# along with the should_not variants |
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
# Inspired by Ryan Bates pro RailsCast "Presenters from Scratch" | |
# This is a proof of concept for 'automagically' creating presenter objects | |
# | |
# This assumes you have presenter objects that follow the convention | |
# Object => ObjectPresenter | |
# | |
# It intercepts the 'render' method in the controller, and does some | |
# introspection to see if there is a presenter defined for the class | |
# of the instance variable being looked at. If so, it makes a presenter | |
# and adds it as an instance variable |
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
Dir.chdir '/Users/avargo/Music' do | |
File.open('../Downloads/all_random.m3u', 'w+') do |file| | |
Dir.glob('**/*.{mp3,ogg,wav}').shuffle.each do |song| | |
next if File.directory?(file) | |
file.write File.join(Dir.pwd, song, "\n") | |
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
(defun input-example (text) | |
"Gets user input and prints it back. Defaults to word at point" | |
(interactive | |
(list | |
(read-string | |
(format "Text (%s): " (word-at-point)) ; prompt. It's nice to show the default value | |
nil ; initial input. This value is prefilled in the mini-buffer. Available but considered deprecated. | |
nil ; history list if you have a specific one for this | |
(word-at-point) ; Whatever this evaluates to will be the default value | |
))) |
OlderNewer