Skip to content

Instantly share code, notes, and snippets.


Joshua Pinter joshuapinter

View GitHub Profile
samstokes / regex-groups-global.rb
Created Nov 18, 2009
How to extract groups from a regex match in Ruby without globals or temporary variables. Code snippets supporting
View regex-groups-global.rb
if "" =~ /@(.*)/
raise "bad email"
# => ""
View capybara cheat sheet
=Clicking links and buttons=
click_link('Link Text')
click('Link Text') # Click either a link or a button
click('Button Value')
View gist:640634
set :application, "application"
set :deploy_to, "/var/www/application"
set :deploy_via, "remote_cache"
set :scm, :subversion
set :repository, ""
set :scm_user, "deploy_dummy"
set :scm_password,"#{ENV['HOME']}/.application_deployment_password").strip
View external_resource.rb
module ExternalResource
# TODO: handle: Timeout::Error (time's up!):
# Requires a block with the HTTPClient.get call or what-have-you
# see InvitationRequestsController for details
def self.load( name = "" )
retries = 12
total = retries
ScottPhillips / .htaccess
Created Feb 2, 2012
Common .htaccess Redirects
View .htaccess
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php
#Redirect an entire site:
Redirect 301 /
#Redirect an entire site to a sub folder
Redirect 301 /
jeremy2 / database.yml.erb
Created Mar 6, 2012
Engine Yard custom Chef Recipe for generating database.yml configuration file
View database.yml.erb
# This file should be in .../cookbooks/database/templates/default/database.yml.erb
<%= @environment %>:
adapter: <%= @adapter %>
database: <%= @database %>
username: <%= @username %>
password: <%= @password %>
host: <%= @host %>
9re /
Created Mar 7, 2012
fix flipped / rotated image by getting exif orientation
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.os.Build;
kconragan /
Last active Nov 12, 2022
Enable key repeat in Apple Lion for Sublime Text in Vim mode
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
rduplain /
Created May 8, 2012
A very simple full-screen WebView activity for Android native wrappers, as a starting point.
package com.willowtreeapps.demo;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
mcasimir / static_map_helper.rb
Created May 24, 2012
Google Maps Static map helper for Ruby on Rails
View static_map_helper.rb
module StaticMapHelper
def static_map_for(location, options = {})
params = {
:center => [, location.lng].join(","),
:zoom => 15,
:size => "300x300",
:markers => [, location.lng].join(","),
:sensor => true