Skip to content

Instantly share code, notes, and snippets.

View cherring's full-sized avatar
💭
Why do we even need this?

Chris Herring cherring

💭
Why do we even need this?
View GitHub Profile
require 'steak'
require 'capybara'
require 'capybara/dsl'
require 'rack/test'
RSpec.configure do |config|
def app
Capybara.app
end
config.include Capybara
@cherring
cherring / helper.js
Created June 7, 2011 00:14 — forked from jobwat/helper.js
Resize text font-size to fit in parent element width
Helpers.updateResizeInput = function(el, text){
if(el.localName == "input" || el[0].localName == "input"){ // inputs are a pain
el.parent().prepend('<span id="test" />');
var theSpan = $('span#test', el.parent());
theSpan.value = text;
Helpers.updateResizeInput(theSpan, text);
el.css('font-size', theSpan.css('font-size'));
el.css('margin-top', theSpan.css('margin-top'));
el[0].value = text;
theSpan.remove();
================================================================
= Trusting an .rvmrc file means that whenever you cd into this =
= directory, RVM will run this .rvmrc script in your shell. =
= =
= If the contents of the file change, you will be re-prompted =
= to review the file and adjust its trust settings. You may =
= also change the trust settings manually at any time with =
= the 'rvm rvmrc' command. =
= =
= Now that you have examined the contents of the file, do you =
@cherring
cherring / d.rb
Created September 13, 2011 05:37
Using libdevil to thumbnail and watermark
# Gem: http://rubygems.org/gems/devil
# Library: http://openil.sourceforge.net/
# Images for use with this: http://dl.dropbox.com/u/363740/images.zip
# To install on snow leopard with homebrew:
# 1. brew install devil
# 2. gem install devil
# 3. ???
# 4. Profit!
sroot /Developer/SDKs/MacOSX10.7.sdk -x c -c /dev/null 2>&1, NSLocalizedFailureReason=Invalid argument}
2011-10-17 22:11:05.485 xcodebuild[27904:4103] Warning: Couldn't discover the 'gcc-4.2' compiler's built-in search paths and preprocessor definitions for language dialect 'c'.
Compiler: /Developer/usr/bin/gcc-4.2
Reason: /Developer/usr/bin/gcc-4.2 -v -E -dM -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -x c -c /dev/null 2>&1
=== BUILD NATIVE TARGET PSMTabBarControlFramework OF PROJECT PSMTabBarControl WITH THE DEFAULT CONFIGURATION (Release) ===
Check dependencies
Unsupported compiler 'GCC 4.2' selected for architecture 'x86_64'
** BUILD FAILED **
def should_see(content_array)
content_array.each { |text| page.should have_content(text) }
end
def should_not_see(content_array)
content_array.each { |text| page.should_not have_content(text) }
end
def should_be_on(page)
current_path = URI.parse(current_url).path
Spork.prefork do
require 'cucumber/rails'
require 'factory_girl_rails'
require 'factory_girl/step_definitions'
require 'database_cleaner'
require 'database_cleaner/cucumber'
Capybara.default_selector = :css
Capybara.default_driver = :selenium
Capybara.server_port = "9887"
Capybara.default_host = "http://www.lvh.me"
@cherring
cherring / gist:1872841
Created February 21, 2012 01:36
Set sequences with a rake task
namespace :db do
desc "Set Sequences to the correct value"
task :set_sequences => [:environment] do
tables = ActiveRecord::Base.connection.tables
tables.reject! { |t| t =~ /schema_migrations/ }
tables.each do |table|
max_id = table.classify.constantize.maximum(:id) || 1
puts "Setting id sequence for #{table} to #{max_id}"
ActiveRecord::Base.connection.execute("select setval('#{table}_id_seq', #{max_id})")
@cherring
cherring / sessions_controller.rb
Created May 29, 2012 23:18
Hacked create for devise API login
def create
resource = warden.authenticate!(:scope => resource_name, :recall => "new")
respond_to do |format|
format.html do
sign_in_and_redirect(resource_name, resource)
set_flash_message :notice, :signed_in
end
format.xml do
sign_in(resource_name, resource)
render :create
@cherring
cherring / gist:3081616
Created July 10, 2012 06:41
~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/syntax_highlighting.py
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()