Skip to content

Instantly share code, notes, and snippets.

View rmulligan's full-sized avatar

Ryan Mulligan rmulligan

  • Tacoma, Washington
View GitHub Profile
@rmulligan
rmulligan / keybase.md
Last active September 2, 2020 23:16
Identity

Keybase proof

I hereby claim:

  • I am rmulligan on github.
  • I am ryanmulligan (https://keybase.io/ryanmulligan) on keybase.
  • I have a public key ASAMK2TOkHU-5gwl22_lnIk1hau2AKIM3Hy7oXYjbWB5sgo

To claim this, I am signing this object:

@rmulligan
rmulligan / redis-server
Last active August 29, 2015 13:57
redis-server init.d
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@rmulligan
rmulligan / example.rb
Last active August 29, 2015 13:57
Example for Sal
require "./student"
require "set"
counter = 0
students = Set.new # Sets only have unique values, so you don't have to worry about duplicate students
File.open("passwd", "r") do |infile| # Change this file to /etc/passwd or wherever your file is
while (line = infile.gets)
if line.match(/\/home\/students/) # Ignore lines that aren't students
student_attrs = line.split(":") # Create array of attributes split on the colon
@rmulligan
rmulligan / dynamic_dispatch.rb
Last active August 29, 2015 13:56
Dynamic Dispatch on Eigenclass for Regex matched callers
def method_missing(name, *args)
if name =~ /^get_stores_by_/
eigenclass = class << self; self; end # flatten scope
eigenclass.class_eval do
define_method(name) do |*args|
query = "#{@base_url}/store/#{name.to_s.camelize(:lower)}.json?"
args[0].collect do |key, value|
if value.is_a? Array
value.each {|v| query << "#{key.to_s.camelize(:lower)}=#{v.to_s}&"}
else