Skip to content

Instantly share code, notes, and snippets.

Kevin Watt inspire22

Block or report user

Report or block inspire22

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@inspire22
inspire22 / gist:1346179
Created Nov 7, 2011
nginx rewrite for page_cached rails 3.1 assets redirect
View gist:1346179
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
inspire22 / gist:1008576
Created Jun 5, 2011
typhoeus segmentation fault
View gist:1008576
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
inspire22 / gist:998274
Created May 30, 2011
sanitize replace & with & on whitelisted elements
View gist:998274
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
inspire22 / gist:987950
Created May 24, 2011
Slow Sunspot indexing
View gist:987950
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.new(result)
=> #<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
--------------------------------------------------------------------------------
View machinist compatibility for Cranky Factory
class ActiveRecord::Base
def self.make(*args)
kl = ActiveSupport::Inflector.underscore(to_s)
Factory.build(kl, *args)
end
def self.make!(*args)
kl = ActiveSupport::Inflector.underscore(to_s)
Factory.create(kl, *args)
View login_controller.rb
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 = ::OpenID::SReg::Request.new
sregreq.request_fields(["email"], true)
You can’t perform that action at this time.