Skip to content

Instantly share code, notes, and snippets.

View JamesFerguson's full-sized avatar

James Ferguson JamesFerguson

View GitHub Profile
@JamesFerguson
JamesFerguson / output.sh
Created February 12, 2018 00:05
Bundling blake-admin
jim@The-Ocean-2 /Users/jim/codez/Blake/blake-admin ruby-2.1.2 develop
⚡ bundle (02-12 10:58)
The git source `git://github.com/blake-education/winnow.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
The git source `git://github.com/binarylogic/authlogic.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
The git source `git://github.com/kovyrin/db-charmer.git` uses the `git` protocol, which transmits data without encryption. Disable this war
@JamesFerguson
JamesFerguson / stacktrace.txt
Created September 6, 2017 05:02
mysql.sock stacktrace
jim@The-Ocean /Users/jim/codez/Blake/wf-teacher ruby-2.1.2 develop
⚡ rails c (09-06 14:58)
bundle exec rails c
WARNING: Nokogiri was built against LibXML version 2.9.2, but has dynamically loaded 2.9.4
/Users/jim/codez/Blake/wf-teacher/vendor/bundle/gems/mysql2-0.3.21/lib/mysql2/client.rb:70:in `connect': Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (Mysql2::Error)
from /Users/jim/codez/Blake/wf-teacher/vendor/bundle/gems/mysql2-0.3.21/lib/mysql2/client.rb:70:in `initialize'
from /Users/jim/codez/Blake/wf-teacher/vendor/bundle/gems/activerecord-4.0.13/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
from /Users/jim/codez/Blake/wf-teacher/vendor/bundle/gems/activerecord-4.0.13/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `mysql2_connection'
from /Users
@JamesFerguson
JamesFerguson / params in nested traits.rb
Last active December 1, 2015 00:22
Trait calling trait with params, Factory Girl
FactoryGirl.define do
factory :currency do
name Forgery::Currency.description
sequence(:short_name) { |sn| "#{Forgery::Currency.code}#{sn}" }
symbol '$'
end
factory :price do
full_price { 6000 }
discount_price { 3000 }
@JamesFerguson
JamesFerguson / email_validator.rb
Created November 4, 2011 00:34 — forked from jcf/email_validator.rb
Rails 3 Email Validator
require 'mail'
class EmailValidator < ActiveModel::EachValidator
attr_reader :record, :attribute, :value, :email, :tree
def validate_each(record, attribute, value)
@record, @attribute, @value = record, attribute, value
@email = Mail::Address.new(value)
@tree = email.__send__(:tree)
@JamesFerguson
JamesFerguson / 56e55726c8cdc920f48c97187c7fe8b9d2baddc6.diff
Created January 31, 2011 23:06
Diff of one line patch to devise making its remember_scope_token cookie HttpOnly by default
diff --git a/test/integration/rememberable_test.rb b/test/integration/rememberable_test.rb
index 14e66fb..295fab0 100644
--- a/test/integration/rememberable_test.rb
+++ b/test/integration/rememberable_test.rb
@@ -54,6 +54,7 @@ class RememberMeTest < ActionController::IntegrationTest
test 'remember the user before sign in' do
user = create_user_and_remember
get users_path
assert_response :success
@JamesFerguson
JamesFerguson / environment.rb
Created December 21, 2010 00:26
A monkey patch to make devise's rememberable module set the remember_#{scope}_token cookie httponly to prevent xss vulnerabilities.
# config/environment.rb
# ...
Dir[Rails.root + 'lib/monkey_patches/**/*.rb'].each { |file| require file }
# ...