Skip to content

Instantly share code, notes, and snippets.

View 844196's full-sized avatar

Masaya Takeda 844196

  • 株式会社ヴァジラ・アヌッタラ ヒタ アビヴッディ精密機器工業
  • Sapporo, Japan
  • 09:04 (UTC +09:00)
  • X @efumaxay
View GitHub Profile
<?php
class Renge {
public function __construct($params = ['seed' => NULL, 'delimiter' => NULL]) {
$this->seed = $params['seed'];
$this->delimiter = $params['delimiter'];
}
public function encode($string) {
$table = $this->convert_table(['for' => 'encode']);
foreach ($this->unpack_U($string) as $char) {
class C
attr_accessor :age
def initialize(&block)
instance_eval(&block)
end
def name(string)
@name = string
end
require 'open_jtalk'
require 'tmpdir'
require 'readline'
class Talk
def start
tmpdir = Dir.mktmpdir('syaberu.rb')
while string = Readline.readline('> ', true)
say(string, tmpdir)
end
@844196
844196 / logger_exapmle.rb
Created March 8, 2016 23:09
loggerライブラリ使用例
# ロガーライブラリをロード
require 'logger'
module AwesomeGem
# ロガーを定義
# ログは標準エラー出力(STDERR)へ出力される
@@log ||= Logger.new(STDERR).tap do |log|
# ログに記録されるアプリケーション名
log.progname = 'AwesomeGem'
require 'n_cipher/argument_validation'
class Configuration
include NCipher::ArgumentValidation
def initialize(hash, &block)
hash.each(&method(:set_attribute))
hash.each(&method(:define_accessor))
define_reseter(hash)
yield(self) if block_given?
@844196
844196 / .rb
Created February 27, 2016 17:09
require 'n_cipher/argument_validation'
class Configuration
include NCipher::ArgumentValidation
def initialize(hash)
hash.each_pair(&method(:define_accessor))
define_singleton_method(:reset) { initialize(hash); self }
end
#!/usr/bin/env ruby
require 'optparse'
require 'logger'
Version = 'v0.1.0'
Release = '2016-02-07'
Signal.trap(:INT) { exit(1) }
logger = Logger.new(STDERR)
@844196
844196 / 0_parse_trainer.rb
Created January 31, 2016 10:24
文末の文字を意識して!
require 'pp'
data = DATA.each_with_object(Struct.new(:speaker, :quote)).map {|line, quote|
r = line.split("\t").map {|pair| pair.chomp.split(':') }.to_h
quote.new(r['speaker'], r['quote'])
}
pp data
.group_by {|row| row.quote[-1] }
.map {|group| group[1].map!(&:quote); group }
@844196
844196 / trainer_say.rb
Last active January 31, 2016 09:39 — forked from keepoff07/trainer_say.txt
あなたのおもしろテキストに2行追加するだけで「○○say」に!
puts DATA.map(&:chomp).sample
__END__
うん。とても安定してますよ!
お尻を突き出さないように、まっすぐ立ちます。
お疲れさまでした。毎日つづけて、身体のゆがみを改善しましょう。
かかとを押して尾骨を斜め上に。
きれいな姿勢です!
きれいな動きです。とても安定してますよ!
この時、腰もいっしょに動かすことを意識しましょう。
そのままの姿勢で、ゆっくり呼吸しましょう。
@844196
844196 / あいちんおっぱいおっきいかわいい.rb
Last active January 29, 2016 14:31
殺さないでください
殺人 =-> したこと { したこと =~ /殺人/ }
殺人じゃないやつ =-> したこと { 殺人.(したこと).! }
その子何したんだろうね? =-> したこと {
case したこと
when 殺人
'アホか!むしろ怒れるか!'
when 殺人じゃないやつ
'広い!'
end