Discover gists
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 "threaded_collections" | |
threadcount = 2 | |
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] | |
tps = ThreadedCollectionProcessor.new(arr) | |
tps.process(2) { |thread_id, item| puts "Thread #{thread_id} processed item: #{item}" } |
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
# From Edge Rails | |
class Object | |
unless public_method_defined?(:present?) | |
def present? | |
!blank? | |
end | |
end | |
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
string[] ids = this.Parameters["OrderByRank"].Split(','); | |
for (int x = 0; x < ids.Length; x++) | |
{ | |
Event foundevent = ec.Find(delegate(Event e) | |
{ | |
return e.ViewID == ids[x]; | |
}); | |
if (foundevent != null) | |
foundevent.Order = -1000 + x; // start at -1000 because the default order is 0 | |
} |
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 'benchmark' | |
TIMES = 10_000_000 | |
:foo # Anal-retentivity | |
def thrice_yield | |
3.times { yield } | |
end | |
def thrice_block &block | |
3.times &block |
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
# | |
# tweet_beat.rb | |
# ShoesFest 2008 | |
# | |
# Created by Tamal White on 2008-07-25. | |
# Copyright 2008 Tamal White. All rights reserved. | |
# | |
require 'hpricot' |
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
@-moz-document domain("github.com") { | |
.userbox { | |
position: absolute; | |
right: 10px; | |
} | |
} |
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
Once upon a time a goat travelled happily through a green pasture |
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
Once upon a time it suddenly decided to flip backwards, and there went Time |
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
def parse(x) | |
$joined = 0 | |
$counter = 0 | |
# INITIALIZE VARIABLES | |
upmynick = $irc_nick | |
mynick = upmynick.downcase | |
nick = "" | |
chan = "" |
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 'logger' | |
log = Logger.new(STDOUT) | |
threads = [] | |
10.times do | |
threads << Thread.new do | |
loop do | |
log.info("foo") |