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
#!/bin/env ruby | |
# encoding: utf-8 | |
# | |
# Rubyで行列式の計算練習しまくるためのツール | |
# ruby ./det.rb で起動 | |
# | |
# Author: kimoto | |
# http://ja.wikipedia.org/wiki/%E3%82%AF%E3%83%A9%E3%83%A1%E3%83%AB%E3%81%AE%E5%85%AC%E5%BC%8F | |
# 正直Rubyなら、標準で入ってるMatrixクラス使えば行ける。この関数は不要 |
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
#!/bin/env ruby | |
# encoding: utf-8 | |
# Author: kimoto | |
class Array | |
def sum | |
self.inject(0){|total,i| | |
total += i | |
} | |
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
#!/bin/env ruby | |
# encoding: utf-8 | |
# Author: kimoto | |
require 'sinatra' | |
require 'erubis' | |
require 'dm-core' | |
require 'dm-migrations' | |
require 'dm-timestamps' | |
# Models |
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
#!/bin/env ruby | |
# encoding: utf-8 | |
# Author: kimoto | |
require 'dm-core' | |
require 'dm-migrations' | |
require 'dm-validations' | |
require 'dm-timestamps' | |
require 'sinatra' | |
require 'erubis' |
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
#!/bin/env ruby | |
# encoding: utf-8 | |
# Author: kimoto | |
require 'data_mapper' | |
class Channel | |
include DataMapper::Resource | |
property :id, Serial | |
property :name, String | |
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
#!/bin/env ruby | |
# encoding: utf-8 | |
def random | |
[1,2,3,4,5,6].sample | |
end | |
last_val = -1 # last time value | |
cnt = 0 # repeated cnt | |
max_cnt = -1 # max repeated cnt |
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
#!/bin/env ruby | |
# | |
# Usage: cfg_diff.rb dirA/autoexec.cfg dirB/autoexec.cfg | |
# | |
require 'kconv' | |
require 'active_support/all' | |
# 末尾にsuffixを付加するだけの関数 | |
def add_suffix(path, suffix) | |
if path !~ /#{suffix}$/ | |
path += suffix |
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
#!/bin/env ruby | |
# | |
# create table tinyurl( | |
# id INT(11) NOT NULL AUTO_INCREMENT, | |
# shorturl VARCHAR(64) NOT NULL, | |
# url TEXT NOT NULL, | |
# PRIMARY KEY(id), | |
# UNIQUE(shorturl) | |
# ); | |
# |
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
#!/bin/env ruby | |
# encoding: utf-8 | |
# Author: kimoto | |
require 'memcache' | |
def benchmark(desc, &proc) | |
puts ">>> #{desc}" | |
start = Time.now | |
begin | |
proc.call |
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
// この.popファイルは集団の特性を定義します。 | |
// そしてこれはtf_populator entityによって操作します (tf_populatorというentityがMapに存在しているらしい | |
// | |
// 集団はひとつかそれ以上のPopulatorによって構成されます。 | |
// すべてのPopulatorは.popファイル内で同時に実行されます。一部の状態を除いて。 | |
// たとえば、もしあなたが3つのPeriodicSpawn populators、それらすべては | |
// 同時に沸くことになります | |
// | |
// 一般的に、Populatorは一つのSpawnerを含みます。Spawnerが発動されたときに | |
// それは世界に1つかそれ以上のエンティティが湧きます (何が起きるかはSpawnerの種類によると) |