Skip to content

Instantly share code, notes, and snippets.

View thermistor's full-sized avatar
🏠
Working from home

Weston Triemstra thermistor

🏠
Working from home
View GitHub Profile
@thermistor
thermistor / turbodev.rb
Created September 7, 2013 01:45
turbodev!
# Extracted from http://git.io/HeGfdA
# Full credit to https://github.com/SamSaffron
#
# Middleware that causes static asset requests to bypass rails altogether. This
# can make requests a lot faster. From 4.5s to 1.5s in some apps. Only relevant
# in development environments as production already does this.
#
# Put this file in lib/middleware and add the following code to your
# development.rb environment file:
#
def valid_msp_number(msp_number)
weights = [0, 2, 4, 8, 5, 10, 9, 7, 3, 0]
total = 0
weights.to_enum.with_index(1).each do |weight, i|
total = total + msp_number[i-1].to_i * weight.to_i
end
a = total / 11
b = a * 11
c = total - b
result = 11 - c
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name=$inputline
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url=$inputline
@thermistor
thermistor / gist:4064149
Created November 13, 2012 05:35 — forked from ebidel/gist:3723309
Spotlight bookmarklet
// Save this in a bookmarklet and click it on a page:
javascript:(function(){function d(a,c){document.body.style.webkitClipPath="circle("+a+"px, "+c+"px, "+b+"px)"}var b=90;window.addEventListener("mousemove",function(a){d(a.pageX,a.pageY)});window.addEventListener("mousewheel",function(a){if(a.shiftKey){a.preventDefault();var c=a.wheelDeltaY;b+=-c;b=0<c?Math.max(90,b):Math.min(b,window.innerHeight/2);d(a.pageX,a.pageY)}})})();
// Or paste this in the console and mouse over the page.
// SHIFT+mousewheel scroll makes the circle bigger/smaller.
(function() {
var radius = 90; // px
@thermistor
thermistor / kill_test_servers.sh
Created November 6, 2012 17:59 — forked from trodrigues/kill_test_servers.sh
kill script for phantom, buster, selenium
#!/bin/bash
# just call with ./kill_test_servers.sh buster-server|selenium|phantom
function get_buster_server_pid(){
echo `ps aux|grep buster-server|grep node|awk '{ print $2 }'`
}
function get_selenium_server_pid(){
echo `ps aux|grep selenium|grep java|awk '{ print $2 }'`
}
@thermistor
thermistor / OPTIONS.rb
Created September 18, 2012 17:10 — forked from ajturner/OPTIONS.rb
make Rails respond to an HTTP OPTIONS method request
# Add to routes.rb
# Needed for responding to OPTIONS http method
map.connect '*path',
:controller => 'home',
:action => 'options_for_mopd',
:conditions => {:method => :options}
# in home_controller.rb
@thermistor
thermistor / index.html
Created August 17, 2012 04:52 — forked from anonymous/index.html
This is just an experiment! There are certainly better ways to show an image of a MacBook, but none as fun as this :)
<i class="macbook"></i>
set :user, 'application'
set :application, 'nayada'
set :deploy_to, "/#{user}/rails/#{application}-git"
ssh_options[:paranoid] = false
ssh_options[:port] = 389
role :app0, "94.127.68.83", :primary => true
namespace :deploy do
@thermistor
thermistor / chef_solo_bootstrap.sh
Last active October 6, 2015 13:28 — forked from wadtech/chef_solo_bootstrap.sh
Bootstrap Chef Solo for Ubuntu 12.04 LTS
#!/usr/bin/env bash
apt-get -y update
apt-get -y upgrade
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.bz2
tar -xvjf ruby-2.0.0-p195.tar.bz2
cd ruby-1.9.3-p327/
./configure --prefix=/usr/local
make
@thermistor
thermistor / deploy.rb
Created June 26, 2012 23:47 — forked from ryanb/deploy.rb
Check to see if you have changes in head which have not been pushed before deploying
namespace :deploy do
desc "Make sure there is something to deploy"
task :check_revision, :roles => :web do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
end