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
#!/usr/bin/env ruby | |
require "rubygems" | |
require "uv" | |
class Hilite | |
BGCOLORS = {"all_hallows_eve" => {:bg => '#000000', :fg => '#ffffff'}, | |
"amy" => {:bg => '#200420', :fg => '#d1d0ff'}, | |
"blackboard" => {:bg => '#0d1021', :fg => '#f8f8f8'}, | |
"brilliance_black" => {:bg => '#0d0d0d', :fg => '#cccccc'}, | |
"brilliance_dull" => {:bg => '#0a0a0a', :fg => '#cdcdcd'}, |
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
@app = Shoes.app do | |
img0 = ask_open_file #select a first image in sequence. | |
NUM_IMGS = 5 | |
imgs = [] | |
NUM_IMGS.times do |n| | |
imgs << img0.sub(/\d+/) { |m| n } | |
end | |
background black |
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
# rb_meth_list2html.rb -- generate Ruby method list html file | |
# Author:: keyes | |
require "rbutils" | |
require "erb" | |
RUBY_REF = "http://doc.okkez.net/#{RUBY_VERSION.delete('.')}/view/" | |
USEFUL_LINKS = | |
{"Standard Library" => "#{RUBY_REF}library", | |
"RAA" => "http://raa.ruby-lang.org/", |
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
digraph G { | |
rankdir=TB | |
node [shape=plaintext, fontsize=16] | |
A -> B -> C -> D -> E [style=dotted, arrowhead=none] | |
"Ruby1.9 Class Relation Map" [shape=plaintext, fontcolor=darkgreen, style=filled, fontsize=20] | |
node [shape=Mrecord, height=1.2, width=2, style=bold]; | |
class [label = "{<0> Class\nclass |<1> Instance methods}"]; | |
basic [label="{<0> BasicObject\nclass |<1> Instance methods}"] |
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 "drb/drb" | |
DRb.start_service | |
$lists = DRbObject.new_with_uri('druby://192.168.1.3:12345') | |
Shoes.app :width => 250, :height => 300 do | |
flow do | |
@input = edit_line :width => 150 do |ed| | |
$lists[:client_line] = ed.text | |
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
require "schemed" | |
def deriv(exp, var) | |
case exp | |
when Numeric | |
0 | |
when Symbol, String | |
same_variable?(exp, var) ? 1 : 0 | |
when Sum | |
make_sum deriv(addend(exp), var), deriv(augend(exp), var) |
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 "drb/drb" | |
module Othero | |
class Board | |
include Enumerable | |
attr_reader :size | |
Size = {:small => 6, :medium => 8, :large => 10} | |
def initialize(size= :small) | |
@size = Size[size] | |
@cells = Array.new(@size){ Array.new(@size) } |
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
class String | |
def drop_char(i) | |
self[0...i] + self[i+1..-1] | |
end | |
def trans_char(i) | |
self[0...i] + self[i+1] + self[i] + self[i+2..-1] | |
end | |
def alt_char(i, char) | |
self.drop_char(i).insert(i, char) | |
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
# encoding: UTF-8 | |
require "open-uri" | |
module Enumerable | |
def take_by(nth) | |
sort_by { |elem| yield elem }.slice(0...nth) | |
end | |
end | |
class WordDictionary | |
include Enumerable |
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 "rubygems" | |
require "sinatra" | |
get '/' do | |
@year = Time.now.year | |
@ycal = cal(@year) | |
erb :index | |
end | |
get '/:year' do |year| |
OlderNewer