Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'sinatra'
require 'redis'
# To use, simply start your Redis server and boot this
# example app with:
# ruby example_note_keeping_app.rb
#
# Point your browser to http://localhost:4567 and enjoy!
#
Patch for jQuery 1.3.2 that makes animations work correctly when
working with different window contexts in Adobe AIR (1.5).
It causes the interval to be set on the window that belongs to
the element the animation is performed on.
===
@@ -4049,8 +4049,9 @@ jQuery.fx.prototype = {
t.elem = this.elem;
class SomeJob
include Resque::Mixin::Status
def self.perform(*args)
job_status "foo"
end
end
# versus
class SomeJob
include Resque::Mixin::Async
include Resque::Mixin::Status
def self.some_long_running_method(*args)
resque_status :just_started
# ...
resque_status :halfway
class SomeJob
include Resque::Mixin::Status
def self.perform(*args)
resque_status "00/50"
# ...
resque_status "50/50"
end
end
module Resque
class Payload
def initialize(klass, &blk)
@__klass = klass
@__calls = []
instance_eval &blk
end
def method_missing(method, *args)
@__calls << { :method => method, :args => args }
# Add config.include(Matchers) to your spec_helper.rb
# ability.should allow_to(:manage, Post)
#
module Matchers
class CanCanMatcher
def initialize(action, noun)
@action, @noun = action, noun
end
@pietern
pietern / gist:304759
Created February 15, 2010 16:18 — forked from sandro/gist:204016
# ARCHFLAGS may or may not matter - I set mine up this way just in case.
~$ echo $ARCHFLAGS
-arch i386 -arch x86_64
# Be sure to compile ruby with --enable-shared
~$ rvm install 1.9.1 --debug --reconfigure -C --enable-shared=yes
# Test to ensure that --enable-shared worked
~$ ruby -e "require 'rbconfig'; puts Config::CONFIG['ENABLE_SHARED']"
yes
##
# test/spec/mini 3
# http://gist.github.com/25455
# [email protected]
# file:lib/test/spec/mini.rb
#
def context(*args, &block)
return super unless (name = args.first) && block
require 'test/unit'
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
/*
* As backward only points to a non-header node,
* it would be possible to replace the ternary statement with
* simply "x->backwards", because the condition will always be false.
*
* ...right?
*/
static void zslInsert(zskiplist *zsl, double score, robj *obj) {
...