This file contains 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/env ruby | |
require 'json' | |
require 'base64' | |
require 'tempfile' | |
def request_json(cn) | |
{ | |
"CN" => cn, | |
"key" => { |
This file contains 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
WEATHER_API = 'http://weather.livedoor.com/forecast/webservice/json/v1?city=130010'.freeze | |
require 'json' | |
require 'open-uri' | |
module Filter | |
class WeatherBot | |
def update(p) | |
return nil unless p['text'] =~ /^\:weather/ | |
{ | |
username: "Weather", | |
text: forecast |
This file contains 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
file = ENV['file'] | |
out_dir = ENV['out_dir'] || './out' | |
time_format = ENV['time_format'] || "%Y-%m-%d_%H-%M-%S" | |
task :platex do | |
cmd = "platex #{file}.tex" | |
abort unless system(cmd) | |
end | |
task :dvipdfmx do |
This file contains 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
def timestamps | |
Dir::glob("**/*").map{|f| File::mtime(f)}.join | |
end | |
def do_cmd | |
open("|platex paper_all.tex && dvipdfmx paper_all.dvi") | |
end | |
t_ = '' | |
loop do |
This file contains 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
Pry.config.prompt = [ | |
proc {|target_self, nest_level, pry| | |
nested = (nest_level.zero?) ? '' : ":#{nest_level}" | |
"[#{pry.input_array.size}] #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}(#{Pry.view_clip(target_self)})#{nested}> " | |
}, | |
proc {|target_self, nest_level, pry| | |
nested = (nest_level.zero?) ? '' : ":#{nest_level}" | |
"[#{pry.input_array.size}] #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}(#{Pry.view_clip(target_self)})#{nested}* " | |
} | |
] |
This file contains 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
curl 'https://my.bitcasa.com/uploader/download-to-bitcasa' \ | |
-X POST \ | |
-d 'file=http%3A%2F%2Flab.cnosuke.com%2Fexample.png&cookies=%5B%5D'\ | |
-H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"\ | |
-H "X_REQUESTED_WITH: XMLHttpRequest" --cookie "sessionid=YOUR_SESSION_ID"; |
This file contains 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 'benchmark' | |
require 'msgpack' | |
require 'redis' | |
require 'json' | |
r = Redis.new | |
h = { a: 'hoge', b: 100, c: true } | |
n = 50000 | |
r.flushdb |
This file contains 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 Object | |
def try(*a, &b) | |
if a.empty? && block_given? | |
yield self | |
else | |
public_send(*a, &b) if respond_to?(a.first) | |
end | |
end | |
end |
This file contains 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 'pry' | |
module ECard | |
class Game | |
attr_reader :players | |
def initialize | |
@players = [ Player.new(:emperor), Player.new(:slave) ] | |
end |
This file contains 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 | |
OUTFILEPREFIX=$1 | |
RECTIMEMIN=$2 | |
CHANNEL=$3 | |
FFMPEG=/usr/bin/ffmpeg | |
FFMPEGOPT="-acodec libmp3lame -ab 64kb -ac 1 -ar 44100" | |
OUTFILEBASEPATH=/home/cnosuke/radiko/data | |
FLVFILEEXT=".flv" | |
MP3FILEEXT=".mp3" |
NewerOlder