Skip to content

Instantly share code, notes, and snippets.

View warmwaffles's full-sized avatar
🛠️
Code Wrestling

Matthew Johnston warmwaffles

🛠️
Code Wrestling
View GitHub Profile
@warmwaffles
warmwaffles / m
Last active August 29, 2015 14:05
Minitest runner without a lot of cruft
#!/usr/bin/env ruby
# Put in ~/bin as ~/bin/m and make it executable
$LOAD_PATH.unshift('lib', 'spec', 'test')
ARGV.each do |path|
if File.directory?(path)
dir = path.gsub(/\/+\Z/, '')
Dir.glob("#{dir}/**/*_{spec,test}.rb").each { |f| load(f) }
@warmwaffles
warmwaffles / unicorn.rb
Last active August 29, 2015 14:05
Do you need a way to run unicorn like you would with webrick?
require 'fileutils'
APP_PATH = FileUtils.pwd()
APP_PID_PATH = 'tmp/pids/unicorn.pid'
APP_PORT = ENV['PORT']
APP_SOCKET = "/tmp/unicorn_#{APP_PORT}.sock"
working_directory(APP_PATH)
listen(APP_SOCKET, :backlog => 64)
@warmwaffles
warmwaffles / kanye_ipsum.md
Created September 17, 2014 01:06
For when you need quick filler text

The problem I have with the paparazzi is if they’re right in front of you and you’re like, “Can you please not take a picture of me?” And they’re like, “Dude I’m not really taking a picture,” and they just keep on doing it like they’re talking to me like I’m stupid and stuff, and then, with arm sprints, I’m going to grab the camera, that just happens, and you don’t expect that to happen with a celebrity, cause you think they’re like a museum animal and stuff, but it’s like, don’t shoot the animals, then, maybe, I don’t know.

I feel like if a rapper disses me, they're just trying to get a rise out of me and get me to play in their field to find some way that they can beat me. I feel

# Signs a URI with your appSID and Key.
# * :url describes the URL to sign
# * :appSID holds the appSID value
# * :key holds the key value
def self.sign(url, AppSID, AppKey)
url = URI.escape(url)
parsedURL = URI.parse(url)
urlToSign =''
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout>
<Pattern>[%thread] [%-5level] [%logger{1}] - %msg%n</Pattern>
</PatternLayout>
</Console>
<File name="Application" fileName="logs/app.log">
<PatternLayout>
// Original Source: http://pastes.archbsd.net/graphitemaster/50_loc_avl_bsearch_tree
// http://www.reddit.com/r/tinycode/comments/2ouzo9/50_loc_avl_binary_search_tree_in_c/
#include <stdlib.h>
#define H(C,N) ((C)->c[N] ? (C)->c[N]->h : 0)
typedef struct node_s {
int k;
int h;
struct node_s *c[2];
@warmwaffles
warmwaffles / pg.sh
Last active August 29, 2015 14:11 — forked from cjolly/pg.sh
newpg=9.3.2
oldpg=9.2.4 # set this to your current PG version
# Stop current Postgres server
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
# Backup current db
mv /usr/local/var/postgres/ /usr/local/var/postgres-$oldpg
# Homebrew
class EnableUuidExtension < ActiveRecord::Migration
def up
execute %Q{CREATE EXTENSION "uuid-ossp"}
end
def down
execute %Q{DROP EXTENSION "uuid-ossp"}
end
end
#!/usr/bin/env ruby
# Put this on your path or in <app>/bin/m and then execute individual tests
# with `bin/m path/to/test`
$LOAD_PATH.unshift('lib', 'spec', 'test')
ARGV.each do |path|
if File.directory?(path)
dir = path.gsub(/\/+\Z/, '')
class Presenter
def initialize(object)
@object = object
end
def method_missing(method_name, *args, &blk)
if @object.respond_to?(method_name)
@object.__send__(method_name, *args, &blk)
else
super