Skip to content

Instantly share code, notes, and snippets.

View thbar's full-sized avatar

Thibaut Barrère thbar

View GitHub Profile
module Kernel
def self.fork
raise NotImplementedError
end
end
# after doing a piston import ... under vendor/gems for a specific bleeding-edge gem
config.gem: Unpacked gem resque in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem resque in vendor/gems not in a versioned directory. Giving up.
rake aborted!
# after doing a piston import ... under vendor/gems for a specific bleeding-edge gem
config.gem: Unpacked gem resque in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem resque in vendor/gems not in a versioned directory. Giving up.
rake aborted!
require 'erb'
data = { :version => RUBY_PLATFORM }
class Hash
def method_missing(method,*args)
if (keys.include?(method) && args.empty?)
self[method]
else
super
* install ironruby in c:\ironruby (msi installer)
* install rspec:
igem install rspec
* copy the binaries:
copy C:\ironruby\Lib\ironruby\gems\1.8\bin\spec C:\ironruby\bin\ispec
copy C:\ironruby\lib\ironruby\gems\1.8\bin\spec.bat C:\ironruby\bin\ispec.bat
# Thinking-sphinx 1.1.3 didn't already support model.sphinx_attributes['@geodist']
# Here's a work-around in case you need something that works
# after your search:
@items.each_with_geodist do |item,geodist|
item.geodist_sphinx_cache = geodist
end
# on your model:
# here's what I used to get HopToad to work with Rails Metal
class Gateway
def self.call(env)
begin
# fake error trigger
if env["PATH_INFO"] =~ /^\/push\/error/
puts "Raising..."
raise "Test error!"
end
def apply(input0:float[], output0:float[], sampleFrames:int)
output0[0] = @a1 * input0[0] + @a2 * @ih1_1 + @a3 * @ih1_2 - @b1*@oh1_1 - @b2*@oh1_2
output0[1] = @a1 * input0[1] + @a2 * input0[0] + @a3 * @ih1_1 - @b1*output0[0] - @b2*@oh1_1
sample = 2
while sample < sampleFrames
output0[sample] = @a1*input0[sample] + @a2*input0[sample-1] + @a3*input0[sample-2] - @b1*output0[sample-1] - @b2*output0[sample-2]
sample += 1
end
# White-list based approach to only log what's relevant
# in Resque Hoptoad notifications.
#
# Disclaimer: this is provided as-is. Write your own tests.
# I can't be held responsible if this code still logs sensitive
# information into HopToad or contains bugs or whatever.
#
# This assume a single Hash arg for the Job. Example of use:
Resque::Failure::SensitiveHoptoad.configure do |config|
Dir["**/*.jar"].
reject { |e| e =~ /^mobile/ }.
each do |f|
puts "======= #{f} ==========="
system("jar -tf #{f} | grep JSGPanel")
end