Skip to content

Instantly share code, notes, and snippets.

View jimryan's full-sized avatar

Jim Ryan jimryan

View GitHub Profile
@jimryan
jimryan / gist:5287776
Last active December 15, 2015 16:18
Capybara fill_in with SublimeText snippet
<snippet>
<content><![CDATA[
fill_in '${1:field}', with: '${2:text}'
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>fiw</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.ruby</scope>
<description>Capybara fill_in snippet</description>
</snippet>
@jimryan
jimryan / gist:5287837
Created April 1, 2013 21:18
Capybara expect(page).to have_content SublimeText snippet
<snippet>
<content><![CDATA[
expect(page).to have_content '${1:content}'
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ephc</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.ruby</scope>
</snippet>
@jimryan
jimryan / deploy.rb
Created June 28, 2013 18:54
Use git user.name config value for New Relic deploy user in Capistrano
# Set New Relic user to git user name if it's set
`git config --global user.name`.strip.tap do |user|
set(:newrelic_user, user) unless user.empty?
end
<?php
/*
Plugin Name: PHP Sucks
Description: Missing PHP functions
Version: 1.0
*/
namespace PHPSucks {
class Arr {
static function reject($fcn, $arr) {
$('article div img').each(function(){scale = $(this).width()/this.naturalWidth;$(this).replaceWith($('<iframe src="'+$(this).attr('src')+'.html'+'" scrolling="no" style="width:'+100/scale+'%;height:'+100/scale+'%;position:absolute;left:0;top:0;transform: scale('+scale+');transform-origin:0 0">'));})
@jimryan
jimryan / post-checkout
Last active April 12, 2016 17:11
Save and restore the state of your Rails development and test databases as you work on different branches
#!/usr/bin/env ruby
require 'yaml'
# If this was a branch checkout
if ARGV[2] == '1'
def dump(database_name, branch_name)
print "Saving state of #{database_name} on '#{branch_name}' branch..."
if system(%[pg_dump -c -f "#{@dump_folder}/#{database_name}-#{branch_name}" #{database_name}])
@jimryan
jimryan / gist:3837269
Created October 5, 2012 00:14
GCP Authenticator Script
#!/bin/bash
echo -n "Client ID: "
read client_id
echo -n "Client secret: "
read client_secret
echo -n "Redirect URI: "
read redirect_uri
@jimryan
jimryan / settings.rb
Last active March 24, 2017 01:37
Restore lederman-rails-settings global Settings
# Restores lederman-rails-settings 1.x global Settings interface
class Settings < ActiveRecord::Base
serialize :value
def self.[](var)
find_by_var(var).try :value
end
def self.[]=(var, value)
setting = find_or_initialize_by(var: var)