Skip to content

Instantly share code, notes, and snippets.

View README.MD

graph TD; A-->B; A-->C; B-->D; C-->D;

View Sort the Ruby files in your project by number of has_many
#Sort the Ruby files in your project by number of has_many
ack " has_many " -c | awk -F ":" '{print $2,$1}' | grep -v "0" | sort -rn
View Count the lines of Ruby code in your app
#Count the lines of Ruby code in your app
find . -iname "*.rb" -type f -exec cat {} \; | wc -l
View Sort the Ruby files in your project by LOC
#Sort the Ruby files in your project by LOC
find . -iname "*.rb" -type f -exec wc -l {} \; | sort -rn
View init.lua
require "window_management"
require "sleep_management"
hs.loadSpoon("SpoonInstall")
spoon.SpoonInstall:andUse("CircleClock")
-- spoon.SpoonInstall:andUse("ClipboardTool",
-- {
-- config = { show_in_menubar = false, },
-- hotkeys = { toggle_clipboard = { { "cmd", "shift" }, "v" } },
@shageman
shageman / bar.rake
Created Feb 8, 2012
Testing rake tasks
View bar.rake
File: lib/tasks/bar.rake
class BarOutput
def self.banner text
puts '*' * 60
puts " #{text}"
puts '*' * 60
end
def self.puts string
puts string
@shageman
shageman / extract_persistence.sh
Last active Dec 2, 2015
Extraction of persistence engine out of ticketee sample app
View extract_persistence.sh
#!/bin/bash --login
ensure() {
"$@" || exit 1
}
cd r4ia_examples/ticketee;
git checkout . && git clean -fd
@shageman
shageman / application.js
Created Sep 1, 2012
Rails environment indicator
View application.js
<% if Rails.env != 'production' %>
document.addEventListener("DOMContentLoaded", function() {
$('body').append($('<div>').css({
display: 'block',
position: 'fixed',
left: '20px',
top: '500px',
'-webkit-transform': 'rotate(-90deg)',
'-moz-transform': 'rotate(-90deg)',
'-o-transform': 'rotate(-90deg)',
@shageman
shageman / object_creation_methods.rb
Last active Oct 6, 2015
ObjectCreationMethods a la Jeff Dean
View object_creation_methods.rb
#lives in spec/support/object_creation_methods.rb
# Source: https://pivotallabs.com/users/jdean/blog/articles/1900-rolling-your-own-object-creation-methods-for-specs
module ObjectCreationMethods
def new_post(overrides = {})
defaults = {:title => "Some title #{counter}"}
Post.new { |post| apply(post, defaults, overrides) }
end
@shageman
shageman / the_class_that_is_true_but_never_in_the_same_way.rb
Created Mar 9, 2012
Why a question mark method should return the true object or the false object
View the_class_that_is_true_but_never_in_the_same_way.rb
require 'rspec/core'
class TheClassThatIsTrueButNeverInTheSameWay
def initialize(truthiness)
@truthiness = truthiness
end
def truthy?
@truthiness ? Time.now : false
end