This file contains hidden or 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
| 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 |
This file contains hidden or 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 '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}} |
This file contains hidden or 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 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 = [] |
This file contains hidden or 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 'servolux' | |
| require 'logger' | |
| require 'beanstalk-client' | |
| module JobProcessor | |
| def before_executing | |
| STDOUT.puts "[C] #$$ before_executing" | |
| @beanstalk = Beanstalk::Pool.new(['localhost:11300']) | |
| end |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| STDOUT.sync = true | |
| require 'rubygems' | |
| require 'servolux' | |
| require 'logger' | |
| require 'beanstalk-client' | |
| module JobProcessor | |
| def before_executing |
This file contains hidden or 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 'servolux' | |
| require 'logger' | |
| server = Servolux::Server.new('Basic', :interval => 1, :logger => Logger.new(STDOUT)) { | |
| puts "running #{Time.now}" | |
| } | |
| server.startup | |
| server.join |
This file contains hidden or 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
| function! AckSnippets(search) | |
| let ft = &ft | |
| if ft == 'objc' || ft == 'cpp' || ft == 'cs' | |
| ft = 'c' | |
| elseif ft == 'xhtml' | |
| ft = 'html' | |
| endif | |
| let dirs = join(split( | |
| \ globpath(g:snippets_dir, ft)."\n". |
This file contains hidden or 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 'servolux' | |
| require 'thread' | |
| q = Queue.new | |
| ary = [] | |
| 3.times do | |
| piper = Servolux::Piper.new 'rw' |
This file contains hidden or 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
| # Convert a string to a numeric value | |
| class String | |
| # Convert the string into a numeric value. If the string does not | |
| # represent a valid Integer or Float, then the string itself is returned. | |
| # | |
| # "10".numeric #=> 10 | |
| # "1.0".numeric #=> 1.0 | |
| # "foo".numeric #=> "foo" | |
| # |