This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# restart-unicorn: Graceful restart for Unicorn | |
# depends on Linux's proc(5) | |
# | |
# MIT License: Copyright(c)2011 MATSUYAMA Kengo | |
require 'scanf' | |
require 'timeout' | |
class ProcFS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Integer | |
def commalize | |
to_s.gsub(/\d(?=.{3}+$)/, '\0,') | |
end | |
end | |
if defined?(RSpec::Core::Runner) | |
describe 'Integer#commalize' do | |
[ | |
[ 321, '321'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rev' | |
require 'rev/ssl' | |
class MyHttpClient < Rev::HttpClient | |
attr_reader :response_header, :response_body | |
def on_connect | |
@response_body = [] | |
super | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rspec' | |
describe 'Local variable in eval' do | |
context 'Assignment in eval' do | |
it 'works' do | |
expect { | |
eval <<-EOS | |
var = true | |
raise unless var |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~$ cat info_t.proto | |
message Info_t { | |
required string Category = 1; | |
required string Value = 2; | |
} | |
~$ rprotoc info_t.proto | |
./info_t.pb.rb writing... | |
~$ cat test.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var paste = readFromClipboard(); | |
if (paste) | |
gBrowser.selectedTab = gBrowser.addTab(paste); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
from=$(date -d "${1:-today}" +%Y-%m-%d) | |
to=$(date -d "${2:-tomorrow}" +%Y-%m-%d) | |
d=$from | |
while true; do | |
next=$(date -d "$d + 1day" +%Y-%m-%d) | |
echo -n "$d:" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sequel.connect( | |
"mysql://user:password@host/database", | |
:compress => false # Required! | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
require 'rubygems' | |
require 'bundler' | |
Bundler.setup | |
require 'icalendar' | |
cal = Icalendar::Calendar.new | |
cal.timezone do | |
tzid 'Tokyo/Asia' | |
standard do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macks@debian:~/test$ ls | |
test.rb test1.proto test2.proto | |
macks@debian:~/test$ cat test1.proto | |
package A; | |
message m1 | |
{ | |
required uint32 aaa = 1 [ default = 0 ]; | |
optional uint32 bbb = 2 [ default = 0 ]; | |
} | |
macks@debian:~/test$ cat test2.proto |