Skip to content

Instantly share code, notes, and snippets.

View inspire22's full-sized avatar

Kevin Watt inspire22

View GitHub Profile
inspire22 / gist:1346179
Created November 7, 2011 21:03
nginx rewrite for page_cached rails 3.1 assets redirect
I page_cache files with rails 3.1 - but with the new assets pipeline, old .css and .js files are removed at deployment, so the page_cached files point to broken versions.
Hacking it to keep old versions would be one solution, the other is to have nginx serve the current version of the assets file if it can't find the one requested:
location ~* ^/assets {
if (!-f $request_filename) {
rewrite ^/assets/(.*)-(.*)\.(.*) /assets/$1.$3 last;
inspire22 / gist:1008576
Created June 5, 2011 02:01
typhoeus segmentation fault
i was getting a similar one before, so installed a new libcurl, then reinstalled typheous from rubygems (it said recompiling native code when doing so)
/u/apps/newap/shared/bundle/ruby/1.9.1/gems/typhoeus-0.2.4/lib/typhoeus/multi.rb:21: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
-- control frame ----------
c:0101 p:---- s:0496 b:0496 l:000495 d:000495 CFUNC :multi_perform
c:0100 p:0019 s:0493 b:0493 l:000492 d:000492 METHOD /u/apps/newap/shared/bundle/ruby/1.9.1/gems/typhoeus-0.2.4/lib/typhoeus/multi.rb:21
c:0099 p:0067 s:0490 b:0490 l:000489 d:000489 METHOD /u/apps/newap/shared/bundle/ruby/1.9.1/gems/typhoeus-0.2.4/lib/typhoeus.rb:57
inspire22 / gist:998274
Created May 30, 2011 00:17
sanitize replace & with & on whitelisted elements
my processor:
OK_FLASH = /^http:\/\/(?:www\.)?youtube\.com\/v\/|^http:\/\/(?:\w+\.)?grooveshark\.com\/songWidget.swf/
# how to easily replace @ reload without reloading full server?
T_YOUTUBE = lambda do |env|
node = env[:node]
node_name = env[:node_name]
parent = node.parent
return nil unless (node_name == 'param' || node_name == 'embed') &&
inspire22 / gist:987950
Created May 24, 2011 00:52
Slow Sunspot indexing
Lots of sub-threads just waiting, not sure what that's about, but I've just left them in there for now :)
ree-1.8.7-2011.03 :008 > printer =
=> #<RubyProf::GraphPrinter:0x96189d4 @result=#<RubyProf::Result:0xad6608c>, @options={}, @output=nil, @thread_times={79214460=>36893488144.865, 90989120=>0.01, 90990320=>0.01, 93838600=>18446744072.0571, 91000760=>0.010327887, 93839750=>18446744072.0581, 90998280=>0.01}>
ree-1.8.7-2011.03 :009 > printer.print(STDOUT, 0)
Thread ID: 79214460
Total Time: 36893488144.865
%total %self total self wait child calls Name
class ActiveRecord::Base
def self.make(*args)
kl = ActiveSupport::Inflector.underscore(to_s), *args)
def self.make!(*args)
kl = ActiveSupport::Inflector.underscore(to_s)
Factory.create(kl, *args)
require 'openid'
require 'openid/consumer'
require "openid/store/filesystem"
require 'openid/extensions/sreg'
class LoginController < ApplicationController
def create
response = openid_consumer.begin(params[:openid_url])
sregreq =
sregreq.request_fields(["email"], true)