require 'mongo'
def rescue_connection_failure(num_retries = 30)
retries = 0
begin
puts "retries: #{retries}"
yield
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
// Written in the D programming language | |
/** | |
* Basic mixed sources by Slepian-Wolf in 1973 | |
*/ | |
import std.math : abs; | |
alias byte Data; | |
alias int[] Points; |
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/local/bin/ruby -Ku | |
# -*- coding: utf-8 -*- | |
$KCODE = 'u' if RUBY_VERSION < '1.9.0' | |
%w[cgi time rss/2.0 net/https].each do |lib| | |
require lib | |
end | |
class OneDay |
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 ruby1.9 | |
# -*- coding: utf-8 -*- | |
require 'csv' | |
require 'erb' | |
require 'kconv' | |
require 'net/smtp' | |
require 'openssl' | |
def post(content, config) |
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
# -*- coding: utf-8 -*- | |
# | |
# Building dmd trunk | |
# | |
require 'rake' | |
OS = 'osx' | |
DMD_DIR = 'trunk' |
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 'mongo' | |
c = Mongo::Connection.new.db('fluent').collection('a') | |
i = 0 | |
loop { | |
begin | |
c.insert({'a' => i}) | |
i += 1 | |
p "alive! #{i}" | |
sleep(1) |
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 'optparse' | |
require 'net/http' | |
require 'date' | |
def kg_download(path) | |
uri = "http://www.kita-colle.com/i/mj/image/kg/kg_#{path}.jpg" | |
res = Net::HTTP.get_response(URI.parse(uri)) | |
if res.code.to_i == 200 | |
filename = File.basename(uri) | |
open(filename, 'wb') { |file| |
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
// Written in the D programming language. | |
/** | |
* High peformance downloader | |
* | |
* Implemented according to <a href="http://yusukebe.com/archives/20120229/072808.html">this implementation</a>. | |
* | |
* Example: | |
* ----- | |
* dmd -L-lcurl -run downloader.d |
denvはrbenvのD言語バージョンです. コマンドで簡単にバージョンを切り替えることができます.
LinuxやMacなどの環境で動作します.Windows上では直接は動きません.
OlderNewer