Skip to content

Instantly share code, notes, and snippets.

View philtr's full-sized avatar

Phillip Ridlen philtr

View GitHub Profile
@philtr
philtr / screencapture.rb
Created January 30, 2014 05:03
Save screenshot of a web page headlessly
require 'headless'
require 'selenium-webdriver'
Headless.ly(dimensions: "1920x1200x24") do
driver = Selenium::WebDriver.for :firefox
driver.navigate.to('http://hellohappy.org/beautiful-web-type/')
driver.save_screenshot('tmp/screenshot.png')
end
@philtr
philtr / environment.rb
Last active December 24, 2015 07:49
Environment variable Ruby interface.
module Environment
class Grabber
include Environment
end
module_function
def get(key)
ENV[key.to_s.upcase]
@philtr
philtr / en-US.yml
Last active December 16, 2015 17:19
Inject app name from settings to be available for all translations as an interpolation.
en-US:
welcome: "Welcome to %{app_name}!"
goodbye: "See ya later, %{name}. Come back to %{app_name} soon!"
@philtr
philtr / heroku-toolbelt-no-sudo.sh
Last active December 11, 2015 13:38
Install the Heroku toolbelt without sudo (for Hombrew users). Modified from https://toolbelt.heroku.com/install.sh
# Nevermind. Use Hombrew.
brew install heroku-toolbelt
@philtr
philtr / rbenv_init.zsh
Last active December 10, 2015 21:48
Speed up rbenv load time by 1,000,000x (not really, but a lot)
#
# RBEnv
#
eval "$(rbenv init --no-rehash -)"
rbenv rehash > /dev/null 2<&1 &!
@philtr
philtr / gist:4268962
Created December 12, 2012 15:59
12/12/12 - 01/01/01
1.9.3p327 :010 > helper.distance_of_time_in_words(Date.parse("Dec 12, 2012"), Date.parse("Jan 1, 2101"))
=> "about 88 years"
@philtr
philtr / reverse_tunnel.bash
Created October 17, 2012 16:15
Set up a reverse tunnel for a local server
# -n - associate standard input with /dev/null
# -N - just set up the tunnel and don't prepare a command stream
# -T - Don't allocate a psedo-tty on the remote system.
# -R - use a reverse tunnel
#
# [local port]:[local host]:[remote port] [remote host]
ssh -nNT -R 5000:local.mydomain.com:80 remote.server.host
@philtr
philtr / grid.sass
Created September 21, 2012 13:39
easy grids with sass and bourbon
// http://thoughtbot.com/bourbon
@import 'bourbon'
$gw-colmumn: 65
$gw-gutter: 20
@for $columns from 1 through 12
.grid-#{$columns}
width: grid-width($columns)
.offset-#{$columns}
@philtr
philtr / postgresql.rb
Created September 8, 2012 15:28
Homebrew - PostgreSQL 9.2 RC 1 Formula
# To upgrade or install PostgreSQL do following:
#
# brew unlink postgresql
# brew install https://raw.github.com/gist/3284212/ce728f1700665926be7a54987f31584dd9a3ca03/postgresql.rb
#
require 'formula'
class Postgresql < Formula
homepage 'http://www.postgresql.org/'
@philtr
philtr / client.rb
Created April 16, 2012 20:12
Acts as Whateverable
# app/models/client.rb
class Client < ActiveRecord::Base
acts_as_whateverable
# ...
end