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
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
~$ 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
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
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
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
#!/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
require 'win32ole' | |
app = WIN32OLE.new('iTunes.Application') | |
# p app.ole_obj_help | |
# p app.ole_methods | |
tracks = app.LibraryPlaylist.Tracks | |
puts "Num of tracks: #{tracks.Count}" | |
tracks.each do |track| | |
%w(Artist Name Album).each do |name| |
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/bash | |
cli53=$HOME/bin/cli53 | |
. $HOME/.ec2/env | |
ec2-describe-instances | \ | |
perl -lane '/^INSTANCE/ and $name = $F[3]; /^TAG/ and $F[3] eq "Name" and print "$F[4] CNAME $name"' | \ | |
xargs -n 3 -r $cli53 rrcreate aws.example.com --ttl 60 --replace |
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
--- a/main/Tiarra/Resolver.pm | |
+++ b/main/Tiarra/Resolver.pm | |
@@ -269,6 +269,8 @@ sub _paranoid_stage2 { | |
if ($entry->answer_status eq $entry->ANSWER_OK) { | |
if (grep { $data eq $_ } @{$entry->answer_data}) { | |
$closure->(1, $entry->query_data, $entry); | |
+ } else { | |
+ $closure->(0, undef, $entry); | |
} | |
} else { |