Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am dan-hoerr on github.
  • I am danhoerr (https://keybase.io/danhoerr) on keybase.
  • I have a public key ASBAijOAWXxye_gYNXx-c_r2xeoMIS5jLq29JotC0aIF9Ao

To claim this, I am signing this object:

@autumn-hoerr
autumn-hoerr / gist:a7801d91d0c985ff5b0c
Created August 15, 2015 15:11
installing custom kext
sudo chmod -R 755 <extensionpath>
sudo chown -R root:wheel <extensionpath>
sudo kextcache -m /System/Library/Caches/com.apple.kext.caches/Startup/Extensions.mkext /System/Library/Extensions
#http://stackoverflow.com/questions/4655194/simple-filtering-out-of-common-words-from-a-text-description
common = {}
STOPWORDS.each{|w| common[w] = true}
stopped = q.gsub(/\b\w+\b/){|word| common[word.downcase] ? '': word}.squeeze(' ')
return stopped
STOPWORDS = %w{ a
able
about
above
@autumn-hoerr
autumn-hoerr / wget_archive
Last active January 3, 2016 16:48
wget for archive.org
wget -e robots=off --mirror --domains=staticweb.archive.org,web.archive.org <URL>
@autumn-hoerr
autumn-hoerr / jquery.coffee
Created October 15, 2013 20:47
Load different versions of jQuery based off HTML5 BP body classes w. Modernizr.load
Modernizr.load
test: document.getElementsByTagName("body")[0].className.match( new RegExp('(\\s|^)lt-ie9(\\s|$)' ))
yep: "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"
nope: "//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"
complete : ->
Modernizr.load
test: true
yep: ["/javascripts/plugins.js", "/javascripts/main.js"]
@autumn-hoerr
autumn-hoerr / order by number of associated records
Last active December 24, 2015 13:09
order a model by the number of an associated records it has
scope :order_by_activities, joins(:activities).select('users.id, users.name, count(activities) as total_activities').group('users.id').order('total_activities desc')
@autumn-hoerr
autumn-hoerr / order by associated scope
Created October 3, 2013 00:45
order a model by the sum of an associated model in rails using pg
# http://stackoverflow.com/questions/10526012/order-players-on-the-sum-of-their-association-model
scope :order_by_distance, joins(:activities).select('users.id, users.name, sum(activities.miles) as total_distance').group('users.id').order('total_distance desc')
@autumn-hoerr
autumn-hoerr / relative_position.coffee
Created August 5, 2013 21:35
relatively position two elements that aren't related.
when "top" then @modal_element.css
'top' : @trigger_element.offset().top - (@modal_height + @padding)
'left' : @trigger_offset.left - (@modal_width/2 - @trigger_width/2)
when "top-left" then @modal_element.css
'top' : @trigger_element.offset().top - (@modal_height + @padding)
'left' : @trigger_offset.left
when "top-right" then @modal_element.css
'top' : @trigger_element.offset().top - (@modal_height + @padding)
ol, .item_list ol
margin-left: 68px
padding: 0
counter-reset: item
li
display: block
position: relative
padding: 0 0 .75em .75em
&:before
content: counter(item)
@autumn-hoerr
autumn-hoerr / BreakpointEvents
Created August 29, 2012 15:22
Breakpoint custom events
#Coffeescript Breakpoint Event Broadcaster
#requires coffeescript, underscore.js, jQuery, throttledresize event (https://github.com/louisremi/jquery-smartresize)
#to initialize: breakpoint = new BreakpointEvent([480,600])
#pass array of breakpoints you want to watch
class BreakpointEvent
#we're going to fire a custom event when the page goes past certain breakpoints
#this should prevent multiple objects doing lots of logic on throttledresize; they
#can just listen for a particular breakpoint event
#passed arguments will fire as "breakpoint" + argument e.g. new BreakpointEvent([480]) would announce a "breakpoint480" event