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
# = Semaphore | |
# | |
# Technically a semaphore is simply an integer variable which | |
# has an execution queue associated with it. | |
# | |
# Copyright (c) 2005 Fukumoto | |
class Semaphore | |
def initialize(initvalue = 0) |
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
# Work with Roman numerals just like normal Integers. | |
class RomanNumeral < Numeric | |
include Comparable | |
# The largest integer representable as a roman | |
# numerable by this module. | |
MAX = 3999 | |
# Taken from O'Reilly's Perl Cookbook 6.23. Regular Expression Grabbag. | |
REGEXP = /^M*(D?C{0,3}|C[DM])(L?X{0,3}|X[LC])(V?I{0,3}|I[VX])$/i |
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 'facets/functor' | |
class Object | |
# Use #instance_eval with a fluid notation. | |
# | |
# class X | |
# attr :a | |
# private :a | |
# def initialize |
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
loop{7.times{|i|puts"\e[2J\e[0;3H_...\n / _ '.\n|.'(@@@@@)\n(*)/ %s \\ | |
| .o. | \n ( %s ) %s"%[i==5?"- -":"e e",(i+3)%7<4?"=":"o",i>0?"-"+ | |
(" Ho"*i)[0,9]+"!":""];puts" ( )\n"*2," ( )\n"*3,' "-"'; | |
sleep([5,3,3,4,5,1,4][i]/6.0)}} |
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
"bp6siZmijp5CiZlCiW5CgAAChpbiiZYiiZZCi5aCZ2bs".unpack("m")[0].unpack("C*").map{|x| | |
x.chr}.join.unpack("B*")[0].scan(/.{24}/){i=7;$&.scan(/..../){ | |
print"\e[3#{i-=1};1;40m ";$&.each_byte{|z|print" #"[z-?0,1]*2}};puts"\e[0m"} |
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
n=32;l="A";n.times{|y|print" "*(n-1-y),(0..y).map{|x|~y&x>0?" .":" #{l}"},$/} |
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
a=[];10.times{|n|a<<1;puts" "*(9-n)*3+"%6d"*-~n%a;n.times{|i|a[n]+=a[n-=1]}} | |
a=[];10.times{|n|a<<1;puts" "*(9-n)*3+"%6d"*(n+1)%a;n.times{|i|a[n]+=a[n-=1]}} |
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
s="\033[2J\033[0;0H _\n Quack! >(')____,\n (` =~~/\n~^~^~^~^~^`---'~^~^~^~^"; | |
(1..(1/0.0)).each{|i|s[23,6]=(i%2)==0?"Quack!":" "*6;s.tr!('>~^^~<','<^~~^>');puts s;sleep 1} |
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
"jp6iSZmkLp5ISZlEiW5C".unpack("m")[0].unpack("C*").map{|x|x.chr}.join. | |
unpack("B*")[0].scan(/.{24}/){i=7;$&.scan(/..../){print"\e[3#{i-=1};1;40m "; | |
$&.each_byte{|z|print" #"[z-?0,1]*2}};puts"\e[0m"} |
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
def pc(*args) | |
super *(args << caller[0]) | |
end |
NewerOlder