This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'redis' | |
def random_data | |
r = rand(2) | |
if r == 0 | |
return rand(10000) | |
elsif r == 1 | |
return "x"*rand(520) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = require("redis").createClient(), | |
util = require("util"); | |
client.set("some key", "A value with Unicode: ☕"); | |
client.get("some key", function (err, reply) { | |
// a wise user also checks for errors | |
console.log("Reply: " + reply); | |
client.quit(function(err, reply) { | |
console.log("Quit: " + reply); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this scopes the contents to the current spec | |
// doesn't matter if callback is fired way later than timeout | |
it "should work" | |
var contents | |
fs.readFile('foo', function(err, c){ | |
contents = c | |
}) | |
wait(-{ | |
contents.should.eql 'bar' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |