Skip to content

Instantly share code, notes, and snippets.

Matt Weppler mweppler

Block or report user

Report or block mweppler

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mweppler
mweppler / n_instruction_programs.rb
Created Oct 3, 2011
A programming language has 10 different instructions. How many five-instruction programs can be written in this language if no instruction is repeated? How many seven-instruction programs?
View n_instruction_programs.rb
#!/usr/bin/ruby
def factorial n
f = n
for i in (n - 1).downto(1)
f *= i
i -= 1
end
return f
end
View titlize.rb
def titlize(the_title)
system("echo '#{the_title.downcase.gsub!(' ', '-')}' | pbcopy")
end
@mweppler
mweppler / link_helper.rb
Created Sep 5, 2013
wip - liquid tag plugin to build links...
View link_helper.rb
View cache.coffee
store = {}
store.setdefault = (key, def) ->
@[key] = def unless @[key]
@[key]
namespace = 'pcache'
formatKey = ->
[].slice.call(arguments).join '.'
@mweppler
mweppler / cache.rb
Last active Dec 17, 2015
Ruby implementation of the python Cache class from Box CRE "The 'One' Thing" by Peter Potrebic
View cache.rb
#!/usr/bin/env ruby
# Ruby implementation of the python Cache class from Box CRE "The 'One' Thing" by Peter Potrebic
$store = {}
$namespace = 'rcache'
class Cache < Object
def initialize(cache_name)
View namespacer.coffee
do () ->
namespacer = (ns, obj) ->
if not typeof ns == "string" or not ns.length
throw new Error '[namespacer] Invalid namespace'
namespace = @
namespace = namespace[part] = namespace[part] or {} for part in ns.split '.'
namespace[attr] = obj[attr] for attr of obj if typeof obj == 'object'
namespace
@['namespacer'] = @['ns'] = namespacer
@mweppler
mweppler / fsmsim.rb
Last active Dec 15, 2015
Fsm Simulator from Udacity CS262 implemented in ruby...
View fsmsim.rb
# FSM Simulation
edges = {
[1, 'a'] => 2,
[2, 'a'] => 2,
[2, '1'] => 3,
[3, '1'] => 3
}
accepting = [3]
@mweppler
mweppler / site-manager.rb
Last active Dec 13, 2015
THIS IS STILL A WORK IN PROGRESS... If this is the first time running site-manager use the --setup switch I got tired of manually setting up a new site that I have to work on. I use Pow for RoR, rack/sinatra apps, static html sites, and proxy to apache via port 81 for anything else. This script makes a few assumptions about your environment, and…
View site-manager.rb
#!/usr/bin/env ruby
###############################################################################
# Required Application Libraries #
###############################################################################
%w{ rubygems optparse ostruct socket yaml }.each { |lib| require lib }
###############################################################################
@mweppler
mweppler / drop_tables.sh
Created Nov 29, 2012
Drop mysql tables in given database
View drop_tables.sh
#!/bin/bash
USER="$1"
PASS="$2"
DB="$3"
if [ $# -ne 3 ]
then
echo "Usage: $0 {MySQL-User-Name} {MySQL-User-Password} {MySQL-Database-Name}"
echo "Drops all tables from a MySQL"
exit 1
You can’t perform that action at this time.