Skip to content

Instantly share code, notes, and snippets.

View TwP's full-sized avatar
🛰️
Spacing Out

Tim Pease TwP

🛰️
Spacing Out
View GitHub Profile
require 'rubygems'
require 'servolux'
require 'logger'
server = Servolux::Server.new('Basic', :interval => 1, :logger => Logger.new(STDOUT)) {
puts "running #{Time.now}"
}
server.startup
server.join
STDOUT.sync = true
require 'rubygems'
require 'servolux'
require 'logger'
require 'beanstalk-client'
module JobProcessor
def before_executing
STDOUT.sync = true
require 'enumerator'
module Kernel
def interruptible_select( rd, wr = nil, er = nil, timeout = nil )
t = Thread.current
t[:select_signal_pipe] = IO.pipe if t[:select_signal_pipe].nil?
p = t[:select_signal_pipe]
p.first.read_nonblock rescue nil
require 'rubygems'
require 'servolux'
require 'logger'
require 'beanstalk-client'
module JobProcessor
def before_executing
STDOUT.puts "[C] #$$ before_executing"
@beanstalk = Beanstalk::Pool.new(['localhost:11300'])
end
# This module defines a class method called "descendants" that will return a
# list of all classes that inherit from the current class.
#
# Array.descendants
# Hash.descendants
# ActiveRecord::Base.descendants
#
module Descendants
def descendants
ary = []
require 'rubygems'
require 'mongo'
connection = Mongo::Connection.new
database = connection.db 'oddball'
collection = database.create_collection('foo', :capped => true, :size => 10 * 1024 * 1024)
docs = []
100.times {|n| docs << {'count' => n, 'time' => Time.now.utc.to_s}}
@TwP
TwP / tmp.js
Created January 29, 2010 03:51
function good_to_go(video) {
video.on_event(function(time) {
$('#time-display').text(time);
});
// at this point in time, our callback function is registered and "prev"
// is null
video.seek(42);
// now we have set the video time - unless we happen to _exactly_ nail the
class FastOpenObject
def method_missing( symbol, *args, &block )
eigenclass = class << self; self; end
eigenclass.class_eval <<-__
def #{symbol}
@#{symbol} ||= Hash.new {|h,k| h[k] = Hash.new(0)}
end
# A time interval represents a period of time between two instants.
# Intervals are inclusive of the start instant and exclusive of the end.
# The end instant is always greater than or equal to the start instant.
#
# Intervals have a fixed duration (or length) seconds. This is the
# difference between the start and end instants.
#
# Methods that are passed an interval as a parameter will treat +nil+ as a
# zero length interval at the current instant in time.
#
# Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
require 'logging-rails'
Rails::Initializer.run do |config|