layout | title | prev_section | next_section | permalink |
---|---|---|---|---|
docs |
コレクション |
variables |
datafiles |
/docs/collections/ |
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
#election.rb | |
require "gviz" | |
header, *candidates = DATA.readlines.map(&:split) | |
Graph do | |
global layout:'fdp' | |
nodes shape:"plaintext", style:"filled", fillcolor:"white" | |
node :election, shape:'doublecircle', label:"2014年\n東京都知事選挙", fillcolor:'orange' |
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
# Gviz sample: | |
# Graphviz Example: Undirected Graph Clusters | Graphviz - Graph Visualization Software | |
# http://www.graphviz.org/content/fdpclust | |
require "gviz" | |
Graph(:G, :graph) do | |
global layout:'fdp' | |
node :e | |
subgraph(:clusterA) do | |
route :a => :b |
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 Filter | |
class << self | |
def filters | |
@filters ||= {} | |
end | |
def add(name, &code) | |
filters[name] = code | |
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
# use benchmark_suite | |
# https://github.com/evanphx/benchmark_suite | |
# -*- encoding: utf-8 -*- | |
require 'benchmark/ips' | |
class Character < Struct.new(:name, :level, :point) | |
def to_s | |
"%s:\tlv:%d\tpt:%d" % values | |
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
require "./onetime" | |
module CoreExt | |
refine String do | |
def ~ | |
margin = scan(/^ +/).map(&:size).min | |
gsub(/^ {#{margin}}/, '') | |
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
class ProcCompressor | |
def initialize(n) | |
@proc = proc.curry(n+1) | |
end | |
def <<(arg) | |
@proc = @proc[arg] | |
Proc===@proc ? self : @proc | |
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 "named_emoji" | |
class Symbol | |
def ~ | |
to_s | |
.split | |
.map { |w| NamedEmoji.emojis[w.intern.downcase] || w } | |
.join(" ") | |
end | |
end |
OlderNewer