Skip to content

Instantly share code, notes, and snippets.

View snipsnipsnip's full-sized avatar

Satoshi Kodama snipsnipsnip

View GitHub Profile
@snipsnipsnip
snipsnipsnip / batter.cpp
Created September 22, 2012 09:57
batter.cpp
#include <windows.h>
#include <stdio.h>
#include <string>
/*
batter.c from http://mattn.kaoriya.net/software/windows/20120920154016.htm
*/
static int emsg() {
char* p = NULL;
#!/usr/bin/python
import sys
import datetime
# Calculates death probabilities based on Social Security
# actuarial tables for a given group of people.
# Run with a list of ages/genders and an optional timespan (or year in the future):
# python actuary.py 63m 80m 75f 73m 10
@snipsnipsnip
snipsnipsnip / hash_tree_parser.rb
Created September 9, 2012 02:07
sinatra's @@ parser
class HashTreeParser
def self.parse(*args)
new.parse(*args)
end
def parse(text)
subhash = proc {|s,k| s[k] = Hash.new(&subhash) }
tree = Hash.new(&subhash)
each_entry(text) do |name, content|
@snipsnipsnip
snipsnipsnip / couch_view_group_demo.rb
Last active August 24, 2019 16:16
couch_view_group_demo.rb
require 'net/http'
class Couch
def initialize(appuri)
if appuri.respond_to?(:host)
@appuri = appuri
else
@appuri = URI(appuri.to_s)
end
end
@snipsnipsnip
snipsnipsnip / egcd.rb
Last active October 9, 2015 07:38
egcd (拡張されたユークリッドの互除法)
def egcd(x, y, a=0, b=1)
d, m = x.divmod(y)
return [y, a] if m == 0
egcd(y, m, b - d * a, a)
end
def tex(w,h)
t = make_texture(w, h)
n = w
t.bucket white
@snipsnipsnip
snipsnipsnip / build.xml
Created August 7, 2012 10:46
ant build.xml for netbeans with ivy integration
<?xml version="1.0" encoding="UTF-8"?>
<project name="JavaApplication2" default="default" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<description>Builds, tests, and runs the project JavaApplication2.</description>
<import file="nbproject/build-impl.xml"/>
<property name="ivy.install.version" value="2.3.0-rc1" />
<property name="ivy.jar.dir" value="${basedir}/ivy" />
<property name="ivy.cache.dir" value="${basedir}/ivy" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<property name="ivy.lib" value="${basedir}/lib" />
@snipsnipsnip
snipsnipsnip / example.txt
Last active August 24, 2019 16:15
gauss.rb: 手作業っぽくガウスの消去法のようすを表示
$ ruby gauss.rb 1 2 3 4 5 6 7 8 9 10 10 12
-- input:
[1 2 3 4]
[5 6 7 8]
[9 10 10 12]
-- forward elimination
(1) <-> (3)
(1) ÷ 9
[1 10/9 10/9 4/3]
[5 6 7 8]
@snipsnipsnip
snipsnipsnip / thick_bresenham.rb
Last active August 24, 2019 16:15
thick Bresenham
# copied from http://lifc.univ-fcomte.fr/~ededu/projects/bresenham/
# but POINT(y, x) is replaced by yield(x, y)
def thick_bresenham(from_x, from_y, to_x, to_y)
dx = (to_x - from_x).abs
dy = (to_y - from_y).abs
ystep = from_y < to_y ? 1 : -1
xstep = from_x < to_x ? 1 : -1
ddx = 2 * dx
@snipsnipsnip
snipsnipsnip / snipsnipsnip.pub.asc
Last active August 24, 2019 16:14
pgp public key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.7 (MingW32)
mQGiBE/I1A8RBADMW0TeBLoqwGH3ta7KNz299lzbzT6Ml7aWlVEKZ2r+gMrM73eY
lH8NDJNExQmRjFXcv89K4gWEj9eJFxdAbyTRtUhC5zZnrEngV2dKp9IXAQvnxWDN
UwEhLPxnS4E176WYnv5FIUREVk61CrhlIzJcFIJTDxt29Fb5M3G/DzOf3wCgmOUh
Jn/JH2166zpPehYg4BhPuq0D/iCzPzdaIB1eyC3NwrFPXDWmY50NHIdI2PfrgM7m
aMMkartBdjoem7dAUqh1OAuy801WEVDeDqmCb9cGrI7+7numoo+ZKOk26PCbSVsY
Eo6kkvmgC7xIM16iLMMwe5OsCHUgMBSYZEISwarqiHrJnL/+vO4UlT0PIxP/Uze+
ECdaBACw/jdgg6fdw69ki7UTfk24V1fQxvP88ZGb6J0QB/c6lkB4hwNC6gxsVEYZ
@snipsnipsnip
snipsnipsnip / dat2thunderbird.rb
Last active August 24, 2019 16:14
npopからgmailにエクスポート (exporting mails from npop to gmail)
# tweaked from http://d.hatena.ne.jp/auto_ptr/20060403#1144110624
require 'time'
require 'kconv'
d = []
time = nil
ARGF.each_line do |line|
case line