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
@cherring
cherring / gist:6618953
Last active December 23, 2015 10:09
Validation Test
# TO test that a model needs a name
user = User.build # Or however you make models in tests
user.first_name = nil
user.should_not be_valid
<xml>
<legList>
<propositionNumber></propositionNumber>
<selectionList></selectionList>
</legList>
<legList>
<propositionNumber></propositionNumber>
<selectionList></selectionList>
</legList>
</xml>
Traceback (most recent call last):
File "./sublime_plugin.py", line 175, in on_load
File "./sublime_plugin.py", line 154, in run_timed_function
File "./sublime_plugin.py", line 174, in <lambda>
File "./syntax_highlighting.py", line 24, in on_load
NameError: global name 'set_syntax' is not defined
ActiveRecord::Base.class_eval do
alias :update_attribute, :update_column
end
@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()
@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: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})")
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"
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
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 **