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 "date" | |
class Diary | |
def self.all | |
@all ||= [] | |
end | |
attr_reader :date, :body | |
def initialize(date, body) | |
@date = Date.parse(date) |
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
module Dochood | |
Dochood = Struct.new(:name, :desc, :owner, :kind) do | |
def self.doc | |
@doc ||= [] | |
end | |
def initialize(*args) | |
super | |
Dochood.doc << self | |
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 "RMagick" | |
image_file = 'yellow.png' | |
img = Magick::ImageList.new(image_file).scale(0.4) | |
colors = {} | |
img.rows.times do |y| | |
img.columns.times do |x| |
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 "open-uri" | |
require "rss" | |
require "json" | |
#require "yaml" | |
module Enumerable | |
def thread_with(delay=0) | |
mem = [] | |
map do |*item| | |
sleep delay |
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 Creature | |
@@counter = 0 | |
def initialize(name) | |
@name = name | |
@@counter += 1 | |
end | |
def self.count | |
"You have #{@@counter} creatures." | |
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 | |
# A Liquid tag for Jekyll sites that allows embedding Gumroad Overlay link. | |
# by: Kyo Endo | |
# Source URL: https://gist.github.com/ | |
# | |
# Example usage: {% gumroad RjRO Title of Link %} | |
module Jekyll | |
class GumroadTag < Liquid::Tag | |
def initialize(tag_name, text, token) |
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 | |
# A Liquid tag for table. | |
# by: Kyo Endo | |
# Source URL: https://gist.github.com/ | |
# | |
# Example usage: | |
# {% table border='solid 1px' cellpadding=3px align=center %} | |
# title aturhor price | |
# "Programming Ruby" "Charlie Ace" $18.05 |
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 "colorable" | |
cs = Colorable::Colorset[:hsb] | |
layouts = %w(dot circo fdp sfdp neato twopi osage patchwork) | |
ns = [*:A..:Z] | |
nodes shape:'circle', style:'filled' | |
layouts.each do |layout| | |
global layout:layout | |
route ns.first => ns.drop(1) |
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 "./invader" | |
ika_map = | |
[ | |
[5, 6], | |
[4..7], | |
[3..8], | |
[2, 3, 5, 6, 8, 9], | |
[2..9], | |
[4, 7], |
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 "colorable" | |
cs = Colorable::Colorset[:rgb] | |
global layout:'osage' | |
nodes shape:'circle', style:'filled', penwidth:5 | |
100.times do |i| | |
node i.to_id, label:'', width:1.4, fillcolor:"#{cs.next.hex}bb" | |
end |