Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Arnell voidlock

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am voidlock on github.
  • I am alexarnell (https://keybase.io/alexarnell) on keybase.
  • I have a public key whose fingerprint is 8615 B97E F682 CA68 1006 1617 523D 3531 7451 C916

To claim this, I am signing this object:

View snippet.rb
module Merb
class Worker
# :api: private
attr_accessor :thread
class << self
# ==== Returns
# Merb::Worker:: instance of a worker.
#
View snippet.rb
class Photo
include DataMapper::Resource
has n, :taggings
has n, :tags, :through => :taggings, 'taggings.deleted_at' => nil
end
class Tag
include DataMapper::Resource
View file.rb
require 'benchmark'
require 'logger'
logger = Logger.new("/dev/null")
logger.level = Logger::INFO
puts "Inspecting 1,000,000 item array"
array = []
1.upto(1_000_000) {|i| array << i}
View file.rb
require 'benchmark'
require 'logger'
require 'date'
logger = Logger.new("/dev/null")
logger.level = Logger::INFO
array = []
1.upto(10) {|i| array << i}
View file.rb
require 'benchmark'
require 'logger'
logger = Logger.new("/dev/null")
logger.level = Logger::INFO
puts "Simple Strings"
Benchmark.bmbm do |x|
x.report("string form") {
100_000.times do
View file.rb
logger.info "some message"
logger.info { "some message" }
View file.rb
require 'benchmark'
require 'logger'
logger = Logger.new("/dev/null")
logger.level = Logger::INFO
puts "Small string substition"
array = []
1.upto(10) {|i| array << i}
View file.rb
require 'benchmark'
require 'logger'
logger = Logger.new("/dev/null")
logger.level = Logger::INFO
puts "Inspecting 1,000 item array"
array = []
1.upto(1_000) {|i| array << i}
View gist:289104
require "rubygems"
require "redis"
redis = Redis.new
redis.delete "foo" # cleanup
puts "SETNX COMMAND:"
puts "Should be true:"
puts redis.set_unless_exists("foo", 1)
puts
You can’t perform that action at this time.