Skip to content

Instantly share code, notes, and snippets.

View justin808's full-sized avatar
💭
Hiring!

Justin Gordon justin808

💭
Hiring!
View GitHub Profile
@justin808
justin808 / .tmux.conf
Last active January 12, 2022 19:57
My tmux conf file for tmux 1.9a
set-option -g default-shell /bin/zsh
# https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
# http://brentvatne.github.com/tmux-copy-paste/
# this next command takes the current buffer and puts it on the OS clipboard
#bind Y run "tmux save-buffer - | reattach-to-user-namespace pbcopy"
#
# I don't understand why the next would be useful
# bind P run "tmux paste-buffer"
bind y copy-mode
def run_command_raise_if_error(command)
puts "Executing: #{command}"
result = %x[#{command}]
raise "rake task failed..........\n#{result}" if result.include?('rake aborted!')
end
def run_rake_command_raise_if_error(command)
run_command_raise_if_error("bundle exec rake #{command}")
end
@justin808
justin808 / .rspec
Created March 10, 2014 08:05
Normal .rspec file
--color
--require spec_helper
--require rspec/instafail
--format RSpec::Instafail
--backtrace
--format documentation
@justin808
justin808 / Guardfile
Created March 10, 2014 08:02
Guard rspec setup with Zeus and parallel-rspec
group :spec do
guard('rspec', all_on_start: false,
all_after_pass: false,
run_all: { parallel: true, parallel_cli: '-n 4' },
cmd: 'zeus rspec',
notification: true,
failed_mode: :keep) do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch("spec/spec_helper.rb") { "spec" }
@justin808
justin808 / typeahead_helper.rb
Created March 10, 2014 07:55
Capybara, Poltergeist, typeahead.js
def fill_in_autocomplete(selector, value)
script = %Q{ $('#{selector}').val('#{value}').focus().keypress() }
page.execute_script(script)
end
def choose_autocomplete(text)
expect(page).to have_css(".tt-suggestion p", text: text, visible: false)
script = %Q{ $('.tt-suggestion:contains("#{text}")').click() }
page.execute_script(script)
end
@justin808
justin808 / database_cleaner.rb
Created March 10, 2014 07:53
Database Cleaner setup for Rails and Capybara
RSpec.configure do |config|
config.add_setting(:seed_tables)
config.seed_tables = %w(seed_table_1 seed_table_2)
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation, except: config.seed_tables)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
@justin808
justin808 / Gemfile
Created March 10, 2014 07:43
Testing gems for Rails, Capybara, Poltergeist, Rspec
# http://soupmatt.com/fixing-bundlewithout-on-heroku-cedar
# Hack to make heroku work. Works b/c on heroku, the ENV['HOME'] will be 'app'
# and this will then return test, which heroku knows to exclude
def hg(g)
(ENV['HOME'].gsub('/', '') == 'app' ? 'test' : g)
end
group :test, hg(:ci) do
gem 'simplecov', require: false
@justin808
justin808 / spec_helper.rb
Last active August 29, 2015 13:57
spec_helper.rb What @railsonmaui uses for testing. See my gist of gems for testing.
# IMPT:
# Configure ENV['LOG_LEVEL'] to be one of DEBUG, INFO, WARN, ERROR, FATAL
# figure out where we are being loaded from
if $LOADED_FEATURES.grep(/spec\/spec_helper\.rb/).any?
begin
raise "foo"
rescue => e
puts <<-MSG
===================================================
@justin808
justin808 / Rakefile
Last active December 17, 2015 05:39
Addition to Octopress Rakefile to rename blog postings to correspond to dates. Does not change the title part. It will print which files change. If any posts changed that had external references to them (tweets, etc.), then you need to put in an alias. Note, this applies to using org-mode files. Be sure to remove the line for org_posts_dir if yo…
# Based on blog post http://www.ewal.net/2012/09/08/octopress-customizations/
# Modified to option of either all or no drafts, and also to use org-mode files
desc "Redate files in the posts directory if the filename does not match the post date in the YAML front matter. Note, URLs based on 'date' metadata, so this shouldn't break any links"
task :redate_posts do
redate_posts true, source_dir, posts_dir, org_posts_dir
end
desc "Redate files in the posts directory, skipping drafts, if the filename does not match the post date in the YAML front matter. Note, URLs based on 'date' metadata, so this shouldn't break any links"
task :redate_posts_no_drafts do
redate_posts false, source_dir, posts_dir, org_posts_dir
@justin808
justin808 / Rakefile
Last active October 21, 2023 16:15
Rake tasks to rename Octopress posts to correspond to metadata, for org-mode as well. In Octopress, the meta is used for the blog post date.
org_posts_dir = "org_posts" # directory under source
# From http://www.ewal.net/2012/09/08/octopress-customizations/
# Modified to have default flag of true to include drafts
desc "Rename files in the posts directory if the filename does not match the post date in the YAML front matter"
task :rename_posts do
rename_posts_in_dir "#{source_dir}/#{posts_dir}", "markdown"
# remove next line if you're you're not using org-mode
rename_posts_in_dir "#{source_dir}/#{org_posts_dir}", "org"