Skip to content

Instantly share code, notes, and snippets.

View davidkelley's full-sized avatar

David Kelley davidkelley

View GitHub Profile
@davidkelley
davidkelley / sort_by_version_number
Created July 10, 2013 13:06
Modifies the Array class in Ruby to support sorting by valid version numbers
#Modify Array prototype
class Array
#Sorts numerically descending, period
#separated occurences ie. file.10.1.2.3.git
def sort_by_version_number!
regex = /(([0-9]+\.?){4,})\./
self.sort! do |a,b|
#Get version numbers
a = Gem::Version.new(a.match(regex)[1])
b = Gem::Version.new(b.match(regex)[1])
@davidkelley
davidkelley / osx-postgresql-memory-fix
Created July 9, 2013 09:11
Commands to fix the PostgreSQL fatal shared memory bug in OS X
# Sudo system control to fix memory in current session
sudo sysctl -w kern.sysv.shmall=65536
sudo sysctl -w kern.sysv.shmmax=16777216
# Fix memory bug for future sessions
cat << 'EOF' >> /etc/sysctl.conf
kern.sysv.shmall=65536
kern.sysv.shmmax=16777216
EOF
@davidkelley
davidkelley / gist:4342647
Last active December 9, 2015 23:08
This coffeescript snippet creates a modularised event delegator for usage in conjunction with RequireJS. Backward compatibility support to IE8 only.
define [], ->
# Handles site-wide event delegations for all elements.
# @param selector The CSS-style element selector.
# @param event The event to bind to, click, hover, mouseenter, etc.
# @param handler The handler function to execute on event firing
# return void
(selector, event, handler) ->
# Define function to wrap the handler function in