Skip to content

Instantly share code, notes, and snippets.

View fukayatsu's full-sized avatar
🏠
Working from home

Atsuo Fukaya fukayatsu

🏠
Working from home
View GitHub Profile
@fukayatsu
fukayatsu / gist:8817319
Last active August 29, 2015 13:56
MacOSX(10.9.1 configure ipv6: automatically) + Ruby(2.1.0) + redis-rb(3.0.7) + localhost => crash
fk82% ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
fk82% irb -rredis
irb(main):001:0> Redis::VERSION
=> "3.0.7"
irb(main):002:0> redis = Redis.new(host: 'fe80::1%lo0')
=> #<Redis client v3.0.7 for redis://fe80::1%lo0:6379/0>
irb(main):003:0> irb(main):003:0> redis.get 'foo'
Users/fukayatsu/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.0.7/lib/redis/connection/ruby.rb:129: [BUG] rb_sys_fail_str(connect(2) for [fe80::1%lo0]:6379) - errno == 0
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
@fukayatsu
fukayatsu / gist:8936887
Created February 11, 2014 15:21
Right Search options(sample)
google: https://www.google.co.jp/search?q=%s&safe=off
translate:
alc: http://eow.alc.co.jp/search?q=%s
yahoo:
image:
all: http://image.search.yahoo.co.jp/search?ei=UTF-8&fr=top_ga1_sa&p=%s
a:
b:
c:
d:
@fukayatsu
fukayatsu / reserved_string_gem.rb
Created February 19, 2014 06:49
作るかもしれないgem
# 知見 - 登録されるとつらいユーザー名リスト - Qiita http://qiita.com/phimcall/items/4c559b70f70ea7f1953b
require 'reserved_string'
ReservedString.configure do |config|
config.strip_string = true # default
config.use_default_list = true # default
config.lists = {
your_list: %w(foo bar baz),
another_list: %w(hoge piyo),
}
@fukayatsu
fukayatsu / gist:9613438
Created March 18, 2014 04:09
動きを止める
$('img[src$=movable_face.gif]').attr('src', 'http://0.gravatar.com/avatar/ada5318ef6bfb0f5e5a0bf8ada8f9cbc')
@fukayatsu
fukayatsu / snap.sh
Last active August 29, 2015 14:10
raspberry pi + camera + idobata
#!/bin/bash
# Usage
# 1. setup camera module and make it enabled
# 2. install ImageMagick
# 3. create generic webhook on idobata.io
# 4. add `0,30 10-23 * * * /home/pi/snap.sh` to crontab
raspistill -t 1 -o /home/pi/tmp/pic.jpg -w 200 -h 150 -q 80
convert -colorspace gray -sketch 0x20+135 /home/pi/tmp/pic.jpg /home/pi/tmp/pic_mod.jpg
@fukayatsu
fukayatsu / import.rb
Created May 24, 2015 13:07
Import from Qiita:Team to esa.io
require 'esa'
require 'json'
require 'pp'
class Importer
def initialize(client, file_path)
@client = client
@items = JSON.parse(File.read(file_path))
end
attr_accessor :client, :items
@fukayatsu
fukayatsu / happy-new-year.rb
Created January 1, 2012 12:27
happy new year!
def A(o)
p "A "+o.s
end
class Happy
def initialize(s)
@s=s
end
def s
@fukayatsu
fukayatsu / Cakefile
Created February 12, 2012 17:11
srcディレクトリに変更があったらビルドして、成功したらテストする
fs = require 'fs'
{print} = require 'util'
{spawn} = require 'child_process'
build = (callback) ->
coffee = spawn 'coffee', ['-c', '-o', 'lib', 'src']
coffee.stderr.on 'data', (data) ->
process.stderr.write data.toString()
coffee.stdout.on 'data', (data) ->
@fukayatsu
fukayatsu / Cakefile
Created March 20, 2012 04:26
テストケースやテスト対象に変更があったら自動的にビルドとテストが走るようにする。
###
前提:
必要なパッケージ
npm install -g coffee-script
npm install -g jasmine-node
ディレクトリ構成
/src #*.coffee
/lib #*.js
/spec #*.spec.coffee
###
@fukayatsu
fukayatsu / tree.spec.coffee
Created April 1, 2012 10:49
オブジェクトを階層化(?)する
describe 'tree', ->
describe 'キーにコロンを含まないとき', ->
it 'そのままのオブジェクトが返ってくること', ->
expect({'a': 1}).toEqual {a: 1}
expect({'a': 1,'b': 2}).toEqual {a:1, b:2}
describe 'キーがコロンでセパレートされているとき', ->
it '階層化されて返ってくること', ->
expect( tree {'a:b':1, 'c:d':2} ).toEqual {a:{b:1},c:{d:2}}
expect( tree {'a:b:c':1, 'a:b:d':2} ).toEqual {a:{b:{c:1, d:2}}}