Skip to content

Instantly share code, notes, and snippets.

View repeatedly's full-sized avatar

Masahiro Nakagawa repeatedly

View GitHub Profile
// Written in the D programming language
/**
* Basic mixed sources by Slepian-Wolf in 1973
*/
import std.math : abs;
alias byte Data;
alias int[] Points;
#!/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
#!/usr/bin/env ruby1.9
# -*- coding: utf-8 -*-
require 'csv'
require 'erb'
require 'kconv'
require 'net/smtp'
require 'openssl'
def post(content, config)
@repeatedly
repeatedly / dmd.rake
Created March 11, 2010 23:37
Rakefile for building dmd, druntime and phobos from trunk
# -*- coding: utf-8 -*-
#
# Building dmd trunk
#
require 'rake'
OS = 'osx'
DMD_DIR = 'trunk'
@repeatedly
repeatedly / reconnection_test.rb
Created November 16, 2011 19:44
Check reconnection in Mongo-Ruby-Driver
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)
@repeatedly
repeatedly / kg_downloader.rb
Created November 25, 2011 02:10
kita-colle girls downloader
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|
@repeatedly
repeatedly / gist:1650238
Created January 20, 2012 23:36
data loss in mongo-ruby-driver with Replica Set

Code

require 'mongo'

def rescue_connection_failure(num_retries = 30)
  retries = 0
  begin
    puts "retries: #{retries}"
    yield
@repeatedly
repeatedly / downloader.d
Last active October 1, 2015 23:18
D言語でいかにしておっぱい画像をダウンロードするか〜2013
// 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
@repeatedly
repeatedly / d_master.md
Last active December 17, 2024 10:01
D言語基礎文法最速マスター

他の言語をある程度知っている人はこれを読めばD言語の基礎をマスターでき,D言語の氷山の一角くらいは知ることができると思います.対象バージョンはdmd 2.059です.

1. 基礎

ソースファイル

ASCIIかUTFしか受け付けません.それ以外の文字コードで書くとコンパイルエラーになります.

main

D言語のmainはCとは違い以下のようなシグネチャです.

@repeatedly
repeatedly / denv_for_contest_programming.md
Created May 9, 2012 04:50
競技プログラミングのためのD言語環境 with denv

denv

denvはrbenvのD言語バージョンです. コマンドで簡単にバージョンを切り替えることができます.

LinuxやMacなどの環境で動作します.Windows上では直接は動きません.

denvのインストール

https://github.com/repeatedly/denv#-2-installation