Skip to content

Instantly share code, notes, and snippets.

View matthewford's full-sized avatar

Matthew Ford matthewford

View GitHub Profile
@matthewford
matthewford / warden_hooks.rb
Created January 28, 2025 22:39
Error when current_user changes mid session - add to your initializers
# frozen_string_literal: true
class SessionLeakError < StandardError
end
Warden::Manager.after_authentication do |record, warden, opts|
request = ActionDispatch::Request.new(warden.env)
SessionActivityTracker.clear(request, opts)
warden.cookies.signed["#{opts[:scope]}.id"] = warden.session["signed_user_id"] = record.id
@matthewford
matthewford / circle.yml
Created April 14, 2016 00:31
CircleCI Config for auto deploying to convox
dependencies:
post:
- curl -Ls https://install.convox.com/linux.zip > convox.zip
- sudo unzip convox.zip -d /usr/local/bin
deployment:
staging:
branch: master
commands:
- convox login console.convox.com
- convox switch org/rack
#!/bin/bash
mkdir tmp/curl-ca-bundle
cd tmp/curl-ca-bundle
wget http://curl.haxx.se/download/curl-7.36.0.tar.gz
tar xzf curl-7.36.0.tar.gz
cd curl-7.36.0/lib/
./mk-ca-bundle.pl
echo
echo "Done! Check lib/ca-bundle.crt"
/Users/matthewford/.gem/ruby/1.9.3/gems/therubyracer-0.12.0/lib/v8/init.bundle: [BUG] Segmentation fault
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-darwin13.0.2]
-- Control frame information -----------------------------------------------
c:0055 p:-17525605849258 s:0177 b:0177 l:000176 d:000176 TOP
c:0054 p:---- s:0175 b:0175 l:000174 d:000174 CFUNC :require
c:0053 p:0010 s:0171 b:0171 l:000163 d:000170 BLOCK /Users/matthewford/.gem/ruby/1.9.3/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:251
c:0052 p:0071 s:0169 b:0169 l:000168 d:000168 METHOD /Users/matthewford/.gem/ruby/1.9.3/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:236
c:0051 p:0019 s:0164 b:0164 l:000163 d:000163 METHOD /Users/matthewford/.gem/ruby/1.9.3/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:251
c:0050 p:0035 s:0159 b:0159 l:000158 d:000158 TOP /Users/matthewford/.gem/ruby/1.9.3/gems/therubyracer-0.12.0/lib/v8.rb:4
######################################################
# Copyright (c) 2006 Matthew Ford #
# This software is licenced under the CC-GNU GPL #
# http://creativecommons.org/licenses/GPL/2.0/ #
######################################################
class ColoursAlt
pcolours = ["red","blue","green"]
Code:
https://github.com/alphagov/whitehall/tree/rails-upgrade
<cluster-user>admin</cluster-user>
<cluster-password>mypassword</cluster-password>
def self.make_utf8_clean
mappings = [ ['α', 'α'],
['ß', 'β'],
['β', 'β'],
['’', '’'],
['“', '“'],
['â€\u009D;', '”'],
['â€', '”'],
['ö', 'ö'],
['®', '®']
@matthewford
matthewford / nokogiri libxml homebrew lion
Created April 17, 2012 00:46 — forked from devpuppy/nokogiri libxml homebrew lion
How to fix: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
FIXME:
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
or
libxml_ruby.bundle: dlsym(0x10fde1900, Init_libxml_ruby): symbol not found
gem uninstall nokogiri libxml-ruby
brew update
brew uninstall libxml2
@matthewford
matthewford / fixes.md
Created April 17, 2012 00:25 — forked from thbar/fixes.md
Getting rid of nokogiri segfaults

This readme is a mixture of everything I read on SO+nokogiri wiki, which ultimately worked out for me.

Here are the steps which worked for me to get rid of segfaults with Nokogiri 1.4.4, on both Lion and Snow Leopard, with Ruby 1.8.7 (patchlevel 334 and +).

First diagnose which version of libxml2 you're using:

bundle exec nokogiri -v

If you have 2.7.3 listed somewhere, you're in bad waters (known to segfault). Install this: