Skip to content

Instantly share code, notes, and snippets.

View eccyan's full-sized avatar

eccyan eccyan

View GitHub Profile
@eccyan
eccyan / worker.rb
Last active August 29, 2015 13:57
Resque の Worker 毎に Redis のホストを設定する ref: http://qiita.com/eccyan/items/c10b4b0080c235b65976
require 'worker_base'
class Worker < WorkerBase
@redis = OTHER_REDIS_HOST
# ...
end
@eccyan
eccyan / prepare-commit-msg
Created March 31, 2014 03:26
prepare-commit-msg for JIRA
#!/usr/bin/env ruby
exit if %w(merge).include? $*[1]
current_branch = `git rev-parse --abbrev-ref HEAD`
if /^([A-Z]{2,}-\d+).*/ =~ current_branch
commit_messages = File.readlines($*[0])
open($*[0], 'w') do |file|
commit_messages.unshift "#{$1} " << commit_messages.shift
file.puts commit_messages
@eccyan
eccyan / redis.rb
Created May 7, 2014 07:26
Rails でサクッと Redis を Master/Slave 構成にする ref: http://qiita.com/eccyan/items/7a7bdeb693f4df16b8f9
class Redis
class Client
def call(command, &block)
master_host = MASTER_HOST_URI
slave_host = SLAVE_HOST_URI
# Slave に向けたいお好きなコマンドを登録
slave_commands = [:get, :hget, :hgetall]
disconnect
@eccyan
eccyan / file0.txt
Created June 25, 2014 10:56
Capistranoでroleが空の場合でも処理を続行させる方法 ref: http://qiita.com/eccyan/items/e494e418eed2e3fc9f79
`deploy:your_task' is only run for servers matching {:roles=>[:role]}, but no servers matched
@eccyan
eccyan / file1.txt
Created July 30, 2014 12:22
Resqueでコネクションプールをしない ref: http://qiita.com/eccyan/items/8f7876bba9d18ca2c483
$ mysql YOUR_DATABASE -e 'SHOW PROCESSLIST;' | grep -v + | cut -f 3 | cut -d ':' -f 1 | sort | uniq -c
@eccyan
eccyan / ruby_hiroba.md
Created September 21, 2014 05:43
RubyHirobaスライド

Ruby Hiroba

テルミーの歴史

http://tell-me.jp

リードエンジニア @eccyan

@eccyan
eccyan / factorial.out
Created September 21, 2014 13:45
ruby-llvm sample
✗ LD_LIBRARY_PATH="`llvm-config --libdir`" bundle exec ruby samples/factorial.rb 1
; ModuleID = 'Factorial'
define i32 @fac(i32 %n) {
entry:
%test = icmp eq i32 %n, 1
br i1 %test, label %result, label %recur
recur: ; preds = %entry
%n-1 = sub i32 %n, 1
@eccyan
eccyan / file0.txt
Last active August 29, 2015 14:08
Redis のメモリが足りなくなった時にどうやってチューニングしたか ref: http://qiita.com/eccyan/items/e8cc56948a00d6aad0aa
$ rdb -c memory dump.rdb > redis_memory.csv
# バイトサイズとキーの個数と単位バイトサイズを出す
$ cat redis_memory.csv | sed -E "1d" | sed -E 's/:[0-9]+(:|")/:{id}\1/g' | cut -d ',' -f 3,4 | awk -F ',' '{ sum[$1] += $2; count[$1] += 1 } END { for (key in sum) print key, sum[key], count[key], sum[key] /count[key] }' > redis_memory_status.csv
@eccyan
eccyan / build.gradle
Last active August 29, 2015 14:10
λ... < ユニットテストのテストコード上で Retrolambda が使えない ref: http://qiita.com/eccyan/items/400a60da44d1d603380b
tasks.withType(Test) {
project.tasks
.findAll { task -> (task.name ==~ /compileTest.*Java/) }
.each { task ->
task.doFirst {
def buildPath = "$project.buildDir/retrolambda"
def jarPath = "$buildPath/$project.android.compileSdkVersion"
def javac = "${project.retrolambda.tryGetJdk()}/bin/javac"
sourceCompatibility = JavaVersion.VERSION_1_8
@eccyan
eccyan / com.example.ShadowablePagerSlidingTabStrip.java
Last active August 29, 2015 14:12
Lolipop より前のバージョンでカスタムビューに影をつける ref: http://qiita.com/eccyan/items/71db808b3f6b1fbde6cf
public class ShadowablePagerSlidingTabStrip extends PagerSlidingTabStrip {
public ShadowablePagerSlidingTabStrip(Context context) {
super(context);
}
public ShadowablePagerSlidingTabStrip(Context context, AttributeSet attrs) {
super(context, attrs);
}