Skip to content

Instantly share code, notes, and snippets.

View joker1007's full-sized avatar

Tomohiro Hashidate joker1007

View GitHub Profile
class Guardable
def initialize(obj)
@obj = obj
end
def method_missing(method_name, *args, &block)
return @obj if @obj.nil?
@obj.send(method_name, *args, &block)
end
gulp = require('gulp')
plumber = require('gulp-plumber')
util = require('gulp-util')
sass = require('gulp-ruby-sass')
rimraf = require('gulp-rimraf')
uglify = require('gulp-uglify')
minifyCSS = require('gulp-minify-css')
streamify = require('gulp-streamify')
size = require('gulp-size')
tap = require('gulp-tap')
#!/usr/bin/env ruby
require 'pp'
BASE_TABLE = [
%w(a b c d e),
%w(f g h i j),
%w(k l m n o),
%w(p q r s t),
%w(u v w x y),
#!/usr/bin/env ruby
require 'pp'
require 'rspec-power_assert'
class Point
attr_reader :row, :col
def initialize(row, col)
@row, @col = row, col
# @param [Hash] options Any of :log, :env, :pwd, :command, :stdout_log, :stderr_log, :spawn_options, :spawn_checker, :timeout
def spawn_process(options = {})
env = options[:env] || {}
command = options[:command]
stdout_log = options[:stdout_log] ? [options[:stdout_log], 'w'] : :out
stderr_log = options[:stderr_log] ? [options[:stderr_log], 'w'] : :err
pwd = options[:pwd]
spawn_options = {
:out => stdout_log,
:err => stderr_log,
@joker1007
joker1007 / cache_by_request.rb
Last active August 29, 2015 14:09
Rackミドルウェアとして動作する1リクエスト毎に勝手に消える超簡易キャッシュストア
class CacheByRequest
def self.read(key)
if Thread.current[:cache_by_request]
Thread.current[:cache_by_request].read(key)
else
raise "before CacheByRequest::Store initialization"
end
end
def self.write(key, val)
@joker1007
joker1007 / calculator.rb
Created January 17, 2015 06:25
神奈川Ruby会議01
require 'bundler/setup'
require 'tapp'
class Operator
def initialize(left, right)
@left = left
@right = right
end
end
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import java.io.File;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.poi.POITextExtractor;
import org.apache.poi.extractor.ExtractorFactory;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.xmlbeans.XmlException;
class TestObject
def initialize(name)
@name = name
@children = []
end
def add_child(child)
@children << child
self
end