Skip to content

Instantly share code, notes, and snippets.

View ohnishiakira's full-sized avatar

Akira Ohnishi ohnishiakira

View GitHub Profile
#!/usr/bin/env ruby
require "fileutils"
class ScatteredFile
attr_writer :filelist
def initialize(file_template)
@file_template = file_template
@filelist = []
enum A : String, EnumProtocol {
case AAA, BBB
}
protocol EnumProtocol {
func desc() -> String
}
extension EnumProtocol {
func desc() -> String { return self.rawValue } // Value of type 'Self' has no member 'rawValue'
# config.yml.liquid
in:
  type: file
  path_prefix: /Users/akira/sketch/embulk/sample/try1/csv/sample_
  decoders:
  - {type: gzip}
  parser:
    charset: UTF-8
    newline: CRLF
#!/usr/bin/env ruby
module StringRefine
refine String do
def refine_test
self.upcase
end
end
end
@ohnishiakira
ohnishiakira / all-installed-rails-new.sh
Last active August 29, 2015 14:12
インストールされている全てのrailsでrails newする
#!/bin/bash
if [[ -z "$1" ]]; then
echo "[error] app_name required." >&2
echo "Usage:" >&2
echo " bash $0 app_name args..." >&2
exit 1
fi
app_name=$1
#!/usr/bin/env ruby
@hoge = "@fuga"
@fuga = "@hoge"
puts "#@hoge"
puts eval "#@hoge"
puts eval eval "#@hoge"
puts eval eval eval "#@hoge"
# =>
$ \pry --no-plugins
[1] pry(main)> RUBY_VERSION
"2.1.2"
[2] pry(main)> Pry::VERSION
"0.10.1"
[3] pry(main)> def class; end
:class
[4] pry(main)> class Hoge; end
/Users/akira/.rvm/gems/ruby-2.1.2/gems/coderay-1.1.0/lib/coderay/scanner.rb:150:in `initialize': undefined method `normalize' for nil:NilClass (NoMethodError)
from /Users/akira/.rvm/gems/ruby-2.1.2/gems/coderay-1.1.0/lib/coderay.rb:269:in `new'
@ohnishiakira
ohnishiakira / find_parallel.sh
Created May 28, 2014 15:29
とにかく並列で処理したい
parallel=
xargs_type=
para_func=
function find_parallel() {
echo test | gparallel --gnu echo >/dev/null 2&>/dev/null && parallel="gparallel --gnu" && para_func="_parallel"
if [[ -z "$parallel" ]]; then
echo test | parallel --gnu echo >/dev/null 2&>/dev/null && parallel="parallel --gnu" && para_func="_parallel"
fi
#
# tw ( http://shokai.github.io/tw/ ) から fluentd を経由して Elasticsearch に投入する
#
# tw 単体で起動すると↓みたいな JSON が出力される
# $ tw --stream --format=json
# {"id":000000000000000000,"user":"XXXX","text":"test test test","time":"2014-03-20 01:00:00 +0900","fav_count":null,"rt_count":null}
#
$ tw --stream --format=json | fluent-cat twitter.timeline
module SequelAutoTableLoader
def method_missing(name, *args, &block)
if name =~ /^#{self.class.const_get(:TABLE_PREFIX)}_/
table_class_name = name.to_s.split(/_/).map(&:capitalize).join
table_name = [table_class_name[0].downcase, table_class_name[1..-1]].join
unless instance_variable_defined? "@#{name}"
instance_variable_set(
"@#{name}",
self.class.const_get(table_class_name).send(