Skip to content

Instantly share code, notes, and snippets.

View nathanaelkane's full-sized avatar

Nate Kane nathanaelkane

  • Brisbane, Australia
View GitHub Profile
@nkpart
nkpart / fuzzy_window_select.tmux.conf
Last active August 29, 2015 13:56
Selecta + Tmux
# Creates a new window to run selecta over list-windows, then selects the result.
bind-key g new-window -n "__SELECTA__" "tmux list-windows | grep -v __SELECTA__ | selecta | sed s/:.*// | xargs -I {} tmux select-window -t {}"
# The same in a split (this is probably better). 21 is how high selecta is by default, 1 line for the prompt, 20 for results
bind-key g split-window -l 21 "tmux list-windows | selecta | sed s/:.*// | xargs -I {} tmux select-window -t {}"
@hackling
hackling / Explanation.md
Last active August 29, 2015 14:09
How to use FIND and SED together

Combining both find and sed to find and replace words

Example script

find app db spec -type f \( -name '*.rb' -o -name '*.sql' \) -exec sed -i '' -e 's/dollar_value/budget_value/g' {} \;

This script:

  • searches in the app, db, and spec directories
  • it only looks at file types that are either .rb or .sql files
@mbbx6spp
mbbx6spp / page.coffee
Created April 13, 2010 21:59
jQuery API usage example in CoffeeScript translated to Javascript.
# Creative Commons Attribution-Share Alike 3.0 United States License
# http://creativecommons.org/licenses/by-sa/3.0/us/
# By Susan Potter <http://geek.susanpotter.net>
(($) ->
editSubmitHandler: (evt) ->
form: $(this)
data: form.serialize()
url: form.attr('action')
$.getJSON(url, data, (data, resp) ->
$('#notice').html(data['html'])
@txus
txus / serialize_matcher.rb
Created February 24, 2011 10:05
RSpec matcher for serialized ActiveRecord columns
# RSpec matcher to spec serialized ActiveRecord attributes.
#
# Usage:
#
# describe Post do
# it { should serialize(:data) } # serialize :data
# it { should serialize(:registers).as(Array) } # serialize :registers, Array
# it { should serialize(:options).as(Hash) } # serialize :options, Hash
# end
@kevbuchanan
kevbuchanan / rspec_jasmine.md
Last active July 27, 2016 14:53
A basic comparison of RSpec and Jasmine tests.

RSpec vs Jasmine

A very basic intro to Jasmine tests for those familiar with RSpec

let/before

  let(:post) { Post.new("My Title", "My Content") }
 var post
@jamiew
jamiew / heroku_unicorn_logger_fix.rb
Created March 28, 2012 15:25
Fix Heroku cedar app logging with Rails 3.1 and Unicorn
# config/environments/production.rb
# We're on Heroku, just output straight to STDOUT
# This is required because we're using Unicorn: https://github.com/ryanb/cancan/issues/511#issuecomment-3643266
config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get(ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'INFO')
Capybara.add_selector :record do
xpath { |record| XPath.css("#" + ActionController::RecordIdentifier.dom_id(record)) }
match { |record| record.is_a?(ActiveRecord::Base) }
end
@henrik
henrik / big_decimal_inspect.rb
Created August 20, 2013 11:52
Better BigDecimal#inspect. Great with tests. By @aalin.
class BigDecimal
def inspect
format("#<BigDecimal:%x %s>", object_id, to_s('F'))
end
end
@simonbaird
simonbaird / gist:663503
Created November 5, 2010 01:16
Little bash script to nuke a branch in git
#
# https://gist.github.com/663503
#
# Use this to clean your repo by removing old branches.
# It will remove the branch on local and on origin.
#
# Usage:
# $ nuke_branch some_old_branch_you_dont_need
#
# Note we use -d not -D for teh safety.
@leshill
leshill / Procfile
Created November 28, 2011 20:01
Unicorn config for cedar stack on Heroku.
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb