Skip to content

Instantly share code, notes, and snippets.

View benwoodward's full-sized avatar
💭
Working on spoken.app

Ben Woodward benwoodward

💭
Working on spoken.app
View GitHub Profile

SASS Modules

Goals

  • modularity
  • encapsulation
  • predictability
  • extensibility
  • integrability
  • explicitness
[difftool "Kaleidoscope"]
cmd = ksdiff --partial-changeset --relative-path \"$MERGED\" -- \"$LOCAL\" \"$REMOTE\"
[diff]
tool = Kaleidoscope
[difftool]
prompt = false
[mergetool "Kaleidoscope"]
cmd = ksdiff --merge --output \"$MERGED\" --base \"$BASE\" -- \"$LOCAL\" --snapshot \"$REMOTE\" --snapshot
trustExitCode = true
[mergetool]
class ActiveAdmin::Views::Pages::Base < Arbre::HTML::Document
def build_page_content
build_flash_messages
div :id => "active_admin_content", :class => (skip_sidebar? ? "without_sidebar" : "with_sidebar") do
build_sidebar unless skip_sidebar?
build_main_content_wrapper
end
end
@benwoodward
benwoodward / postgres_role.sh
Created March 1, 2013 18:47
Create a new role in postgres
createuser -s -U $USER
@benwoodward
benwoodward / .irbrc
Created February 14, 2013 11:41
Locate and open (in TextMate) at location of method source. http://pragmaticstudio.com/blog/2013/2/13/view-source-ruby-methods
# source_for(Person.new, :update)
def source_for(object, method)
location = object.method(method).source_location
`mate #{location[0]} -l #{location[1]}`
location
end
@benwoodward
benwoodward / gist:4539890
Last active December 11, 2015 03:48
Useful Git snippets

Edit historical commit

git-checkout 0f0d8a27622e7bf7f008983c4b8ee23bfb9843ab
editor path/to/file
git-add path/to/file
git-commit --amend -v
git-rebase --onto HEAD 0f0d8a27622e7bf7f008983c4b8ee23bfb9843ab master
@benwoodward
benwoodward / list.rb
Created October 1, 2012 15:21
An expensive transaction in acts_as_list
# This has the effect of moving all the lower items up one.
def decrement_positions_on_lower_items(position=nil)
return unless in_list?
position ||= send(position_column).to_i
acts_as_list_class.unscoped.update_all(
"#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} > #{position}"
)
end
@benwoodward
benwoodward / vim_tips.md
Created August 30, 2012 23:20
Vim commands worth remembering ..

change / delete to a character

ct[char] # e.g. ct" to delete to the next " and go into insert mode dt[char] # dt" to delete up to next "

change inner-word, delineate with "

ci"

delete after-word, delineate with parens

da)

Some useful references;

@benwoodward
benwoodward / _index.html.haml
Created August 25, 2012 12:59
Ruby on Rails Sortable/Reorderable lists on STI models using ranked_model, Twitter Bootstrap and inherited_resources
%h1= "Listing " + "#{resource_name}s"
.btn-group.pull-right
= link_to "All #{resource_name(item: resource_class.superclass)}s", polymorphic_path([:admin, resource_class.superclass]), class: 'btn'
= link_to "Add #{resource_name}", new_resource_path, class: 'btn-primary btn'
%br
%br
%table.table.table-bordered.table-striped#sortable{:data => {update_url: polymorphic_path([:sort, :admin, resource_class])}}
@benwoodward
benwoodward / irb
Created May 9, 2012 12:21
Find method definition in Ruby
p ModelName.method(:method_name).source_location