Skip to content

Instantly share code, notes, and snippets.

View 844196's full-sized avatar

Masaya Takeda 844196

  • ใปใ‚“ใซใ‚ƒใ‚‰็”ฃๆฅญ
  • Sapporo, Japan
  • 02:24 (UTC +09:00)
  • X @efumaxay
View GitHub Profile
@844196
844196 / nyanpasu.php
Created April 7, 2016 16:37
้€”ไธญ
<?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__
ใ†ใ‚“ใ€‚ใจใฆใ‚‚ๅฎ‰ๅฎšใ—ใฆใพใ™ใ‚ˆ๏ผ
ใŠๅฐปใ‚’็ชใๅ‡บใ•ใชใ„ใ‚ˆใ†ใซใ€ใพใฃใ™ใ็ซ‹ใกใพใ™ใ€‚
ใŠ็–ฒใ‚Œใ•ใพใงใ—ใŸใ€‚ๆฏŽๆ—ฅใคใฅใ‘ใฆใ€่บซไฝ“ใฎใ‚†ใŒใฟใ‚’ๆ”นๅ–„ใ—ใพใ—ใ‚‡ใ†ใ€‚
ใ‹ใ‹ใจใ‚’ๆŠผใ—ใฆๅฐพ้ชจใ‚’ๆ–œใ‚ไธŠใซใ€‚
ใใ‚Œใ„ใชๅงฟๅ‹ขใงใ™๏ผ
ใใ‚Œใ„ใชๅ‹•ใใงใ™ใ€‚ใจใฆใ‚‚ๅฎ‰ๅฎšใ—ใฆใพใ™ใ‚ˆ๏ผ
ใ“ใฎๆ™‚ใ€่…ฐใ‚‚ใ„ใฃใ—ใ‚‡ใซๅ‹•ใ‹ใ™ใ“ใจใ‚’ๆ„่ญ˜ใ—ใพใ—ใ‚‡ใ†ใ€‚
ใใฎใพใพใฎๅงฟๅ‹ขใงใ€ใ‚†ใฃใใ‚Šๅ‘ผๅธใ—ใพใ—ใ‚‡ใ†ใ€‚
ๆฎบไบบ =-> ใ—ใŸใ“ใจ { ใ—ใŸใ“ใจ =~ /ๆฎบไบบ/ }
ๆฎบไบบใ˜ใ‚ƒใชใ„ใ‚„ใค =-> ใ—ใŸใ“ใจ { ๆฎบไบบ.(ใ—ใŸใ“ใจ).! }
ใใฎๅญไฝ•ใ—ใŸใ‚“ใ ใ‚ใ†ใญ๏ผŸ =-> ใ—ใŸใ“ใจ {
case ใ—ใŸใ“ใจ
when ๆฎบไบบ
'ใ‚ขใƒ›ใ‹๏ผใ‚€ใ—ใ‚ๆ€’ใ‚Œใ‚‹ใ‹๏ผ'
when ๆฎบไบบใ˜ใ‚ƒใชใ„ใ‚„ใค
'ๅบƒใ„๏ผ'
end