Skip to content

Instantly share code, notes, and snippets.

@kano4
kano4 / troch_installer
Created March 6, 2012 13:11
Troch setup script for RedHat.
#!/bin/sh
# Troch
echo "Download Troch"
yum install -y git
cd /srv/
git clone https://github.com/kano4/troch.git troch
# Ruby
echo "Setup Ruby"
@kano4
kano4 / clean_resque_worker
Created March 5, 2012 15:00
Clean resque worker
#Resque.workers.first.prune_dead_workers
#Resque::Stat.clear("failed")
#Resque::Stat.clear("processed")
redis = Redis.new
redis.flushall
@kano4
kano4 / gem_error
Created March 5, 2012 04:24
gem_error
/usr/lib/ruby/1.9.1/rubygems.rb:1261: [BUG] Segmentation fault
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0007 p:---- s:0019 b:0019 l:000018 d:000018 CFUNC :require
c:0006 p:0321 s:0015 b:0015 l:000014 d:000014 TOP /usr/lib/ruby/1.9.1/rubygems.rb:1261
c:0005 p:---- s:0012 b:0012 l:000011 d:000011 FINISH
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :require
c:0003 p:0021 s:0006 b:0006 l:000005 d:000005 TOP <internal:gem_prelude>:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
@kano4
kano4 / screenshot.rb
Created March 3, 2012 01:14
screenshot in Ruby
#!/usr/bin/env ruby
require 'rubygems'
require 'capybara-webkit'
require 'headless'
Headless.ly do
driver = Capybara::Driver::Webkit.new 'web_capture'
driver.visit 'http://www.kano4.com'
driver.render 'out.png'
end
@kano4
kano4 / gem_clean.rb
Created March 1, 2012 09:21
gemを全て消す
$ for x in `gem list --no-versions`; do gem uninstall $x; done
url = "http://www.google.co.jp/hoge/moge".scan(/(http:\/\/(\w|\.|!\/)+)/)
url = (url.nil? || url[0].nil?) ? "" : url[0][0]
puts "#{url}" # => http://www.google.co.jp
@kano4
kano4 / ruby_path_for_root
Created February 23, 2012 09:36
ruby path for root
export PATH=/usr/local/bin:$PATH
alias sudo="sudo env PATH=$PATH"
@kano4
kano4 / delete_logs.rb
Created February 21, 2012 14:27
delete logs in Rails
# 一ヶ月以上前のログを削除
WatchLog.delete_all(["created_at < ?", 1.month.ago])
@kano4
kano4 / load_path.rb
Created February 6, 2012 13:25
Rubyでrequireするファイルのパスを表示
p $LOAD_PATH.push('.')
@kano4
kano4 / add_require_path.rb
Created February 4, 2012 14:50
Rubyのrequireのパスを追加
`ls .gems/gems/`.split.each {|gem| $LOAD_PATH.push(".gems/gems/#{gem}/lib")}