Skip to content

Instantly share code, notes, and snippets.

View shanemcd's full-sized avatar

Shane McDonald shanemcd

  • (Ansible (Red Hat (IBM)))
  • Jersey City
View GitHub Profile
@shanemcd
shanemcd / gist:4718496
Created February 5, 2013 22:59
Prevent scrolling
body{
overflow: hidden;
}
@shanemcd
shanemcd / gist:4717435
Created February 5, 2013 20:36
loop through a hash and apply different tooltips to multiple elements
icons =
preview: "Print Preview"
edit: "Edit Question"
comment: "Comment"
trash: "Delete"
for icon, text of icons
$(this.el).find(".#{icon}-image").tooltip
title: text
for f in *.yaml; do mv $f `basename $f .yaml`.yml; done;
class Instruments2.Views.FilterQuestionSets extends Backbone.View
template: JST['folders/filter']
id: "filter-question-sets"
className: "clearfix"
events:
"keyup input[type=text]": "filter"
@shanemcd
shanemcd / gist:4269738
Created December 12, 2012 17:21
Require all (most) fields in Rails model
validates_presence_of(self.column_names - ["id", "created_at", "updated_at"])
@shanemcd
shanemcd / gist:4259171
Created December 11, 2012 15:03
modules
module Foobar
def self.foo
puts 'foo'
end
end
module Foobar
def self.bar
puts 'bar'
end
@shanemcd
shanemcd / gist:4217247
Created December 5, 2012 16:41
Clean up $PATH - removes duplicate directories
echo "$PATH" | /usr/bin/awk -v RS=':' -v ORS=":" '!a[$1]++'
@shanemcd
shanemcd / gist:4177528
Created November 30, 2012 18:20
FizzBuzz
(1..100).to_a.map { |i|
if (i % 3 == 0 ) && (i % 5 == 0)
i = "fizzbuzz"
elsif i % 3 == 0
i = "fizz"
elsif i % 5 == 0
i = "buzz"
else
i = i
end
@shanemcd
shanemcd / gist:4066669
Created November 13, 2012 16:11
Benchmarks when removing duplicate items from array
require 'benchmark'
arr1 = (1..5000).to_a
arr2 = (1..10000).to_a
a = arr1.zip(arr2).flatten # 10000 items, 5000 duplicates
# with #uniq
puts Benchmark.measure { a.uniq }
# Total time
- Start Redis
redis-server /usr/local/etc/redis.conf
- Start Resque
rake resque:work QUEUE="*"
- Start Rails last