Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Joshua Pinter joshuapinter

🎯
Focusing
View GitHub Profile
@samstokes
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 http://blog.samstokes.co.uk/post/251167556/regex-style-in-ruby
View regex-groups-global.rb
if "foo@example.com" =~ /@(.*)/
$1
else
raise "bad email"
end
# => "example.com"
View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
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, "http://account.svn.beanstalkapp.com/repository/trunk"
set :scm_user, "deploy_dummy"
set :scm_password, File.read("#{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
ScottPhillips / .htaccess
Created Feb 2, 2012
Common .htaccess Redirects
View .htaccess
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@jeremy2
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
9re / ExifUtil.java
Created Mar 7, 2012
fix flipped / rotated image by getting exif orientation
View ExifUtil.java
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.os.Build;
@kconragan
kconragan / keyrepeat.shell
Last active Nov 12, 2022
Enable key repeat in Apple Lion for Sublime Text in Vim mode
View keyrepeat.shell
# 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
rduplain / MainActivity.java
Created May 8, 2012
A very simple full-screen WebView activity for Android native wrappers, as a starting point.
View MainActivity.java
package com.willowtreeapps.demo;
import android.app.Activity;
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
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.lat, location.lng].join(","),
:zoom => 15,
:size => "300x300",
:markers => [location.lat, location.lng].join(","),
:sensor => true
}.merge(options)