Skip to content

Instantly share code, notes, and snippets.

@kei-s
kei-s / beer_document.rb
Created August 6, 2013 06:16
ビアドキュメント #駄洒落クラブ
puts <<🍺
\u{1F37A}
🍺
@kei-s
kei-s / face_detect.rb
Created June 10, 2013 06:07
OpenCV Face Detect sample.
require 'bundler/setup'
require 'opencv'
include OpenCV
if ARGV.length < 2
puts "Usage: ruby #{__FILE__} source dest"
exit
end
@kei-s
kei-s / deploy.rb
Created January 10, 2013 10:11
capistrano の server 一覧
@roles.each do |name, role|
role.servers.each do |server|
logger.info server.to_s, name
end
end
@kei-s
kei-s / productction.rb
Created November 14, 2012 10:54
Catch DB connection error by exception_notification
# Catch DB connection error by exception_notification(https://github.com/smartinez87/exception_notification)
Sample::Application.configure do
#...
config.middleware.insert_before ActiveRecord::ConnectionAdapters::ConnectionManagement, ExceptionNotifier,
# settings for exception_notification
end
end
@kei-s
kei-s / gist:3809475
Created October 1, 2012 04:29
Mountain Lion, homebrew, imagemagick, update

Mountain Lion, homebrew, imagemagick, update

convert -v が通るようになれば imagemagick アップデート完了なのでステップ毎にチェック。

imagemagick に関係しないものもあるかも。

  1. brew doctor で warning なくなるまで対応

    brew install autoconf fontconfig freetype libpng p11-kit とか

@kei-s
kei-s / satsubatsu.txt
Created June 8, 2012 08:02
殺伐としたTLにJavaScriptが
use strict;
class Foo
public static void main(String[] @args)
bar :: Foo -> String
def bar(self):
@args.inject(result, (function(elem) do
my $str = htmlspecialchars(elem)
result += $str
@kei-s
kei-s / channel_from_TIG_to_tig.rb
Created April 18, 2012 16:44
Channel data from TwitterIRCGateway to tig
require 'json'
require 'nokogiri'
doc = Nokogiri::XML(File.read('./Groups.xml'))
result = doc.search('Group').map{|g|
{g: g.search('Name').text, ms: g.search('Members string').map(&:text)}
}
json = {}
result.map{|g|g[:ms]}.flatten.uniq.map{|u|
@kei-s
kei-s / gist:2118838
Created March 19, 2012 16:48
spree_states.rb
japan = Spree::Country.create!(name: "Japan", iso3: "JPN", iso: "JP", iso_name: "JAPAN", id: "1", numcode: "392")
zone = Spree::Zone.create!(name: "Japan", id: "1", description: "Shipping and paying in Japan",
zone_members: [Spree::ZoneMember.new(zoneable: japan)])
# order by http://ja.wikipedia.org/wiki/ISO_3166-2:JP
%w(
北海道
青森県 岩手県 宮城県 秋田県 山形県 福島県
茨城県 栃木県 群馬県 埼玉県 千葉県 東京都 神奈川県
新潟県 富山県 石川県 福井県 山梨県 長野県 岐阜県 静岡県 愛知県
@kei-s
kei-s / gist:1693076
Created January 28, 2012 06:43
Recursive OpenStruct
class RecursiveOpenStruct < OpenStruct
def new_ostruct_member(name)
name = name.to_sym
unless self.respond_to?(name)
class << self; self; end.class_eval do
define_method(name) {
v = @table[name]
case v
when Hash
RecursiveOpenStruct.new(v)
#coding: utf-8
require "bundler"
Bundler.setup
require "twitter"
require "pit"
pit = Pit.get("june29bot", :require => {
"consumer_key" => "consumer_key",
"consumer_secret" => "consumer_secret",
"oauth_token" => "oauth_token",