Skip to content

Instantly share code, notes, and snippets.

View astronasutarou's full-sized avatar

Ryou Ohsawa astronasutarou

View GitHub Profile
@astronasutarou
astronasutarou / voronoi.gp
Created February 7, 2013 06:21
ボロノイ図を陰線処理で作成する方法 on gnuplot
#!/usr/bin/gnuplot
## define cone function
cone(x,y,cx,cy) = 1 - sqrt((x-cx)**2+(y-cy)**2)
## set hidden line removal
set hidden3d
## set view
set view 0,0
@astronasutarou
astronasutarou / RootedTree.cc
Created March 26, 2013 19:09
根付き木を C++ で実装してみたメモ. RootedTree(int n) で index が 0, 1, ..., (n-1) までのノードを作成. AddChild(n,m) で n を m の子供に指定する.
#include<iostream>
#include<cstdio>
class RootedTree {
int** tree;
public:
RootedTree(int s) {
tree = new int*[3];
tree[0] = new int[s](); // pointer to parent
tree[1] = new int[s](); // pointer to first child
@astronasutarou
astronasutarou / easyHeap.cc
Created March 26, 2013 19:11
簡単な heap を C++ で実装してみた. void push(int n) で n をヒープに追加. int pop() でヒープの根を取り出す. void show() でヒープの構造を出力する.
#include <iostream>
#include <vector>
#include <algorithm>
using std::vector;
using std::swap;
class easyHeap {
int numel;
vector<int> mem;
@astronasutarou
astronasutarou / accent.txt
Last active December 22, 2015 08:48
google 日本語入力 (mozc) 向けのアクセント記号入力用辞書
:あきゅーと Á アルファベット
:あきゅーと á アルファベット
:あきゅーと É アルファベット
:あきゅーと é アルファベット
:あきゅーと Í アルファベット
:あきゅーと í アルファベット
:あきゅーと ń アルファベット
:あきゅーと Ń アルファベット
:あきゅーと Ó アルファベット
:あきゅーと ó アルファベット
@astronasutarou
astronasutarou / parsecontour.m
Last active December 26, 2015 00:09
octave の contourc で出力されるコントア情報を元にしてコントアを描画するためのスクリプト
#!/usr/bin/octave
function [val lev] = parsecontour(cnt)
npar = 0; ptr = 0; N = size(cnt,2);
while(ptr < N)
npar++; ptr++;
lev{npar} = cnt(1,ptr);
n = cnt(2,ptr);
val{npar} = cnt(:,((ptr+1):(ptr+n)))';
ptr+=n;
@astronasutarou
astronasutarou / mh.m
Created November 1, 2013 21:20
Metropolis–Hastings algorithm で乱数生成するためのスクリプト
function x1 = mh(x0,func,xgen)
## input:
## x0 - input distribution
## func - target distribution function
## xgen - random generator for next step
## output:
## x1 - resultant distribution
xp = xgen(x0);
y0 = func(x0); y1 = func(xp);
a = y1./(y0+(y0==0)) + (y0==0);
@astronasutarou
astronasutarou / deluxetable.sty.patch
Last active December 31, 2015 10:39
deluxetable.sty で cont'd なテーブルを表目次に載せないためのハック
diff --git a/deluxetable.sty b/deluxetable.sty
index *******..******* ******
--- a/deluxetable.sty
+++ b/deluxetable.sty
@@ -127,7 +127,10 @@
\pt@ncol=#1\relax
\global\let\pt@addcol\@empty
}%
-\newcommand\tablecaption[1]{\gdef\pt@caption{#1}}%
+\newcommand\tablecaption[1]{%
@astronasutarou
astronasutarou / Makefile
Created January 4, 2014 08:43
フォルダ内に存在する eps ファイルをすべて横幅 800px の png ファイルへと変換する Makefile
SOURCE := $(wildcard *.eps)
TARGET := $(patsubst %.eps,%.png,$(SOURCE))
.SUFFIXES: .png .eps
all: $(TARGET)
%.png: %.eps
gs -dBATCH -sDEVICE=png16m -dNOPAUSE -r1200 -dEPSCrop -sOutputFile=$@ -f $<
mogrify -geometry 800x $@
@astronasutarou
astronasutarou / setwacom
Created January 11, 2014 09:56
Wacom Bamboo の初期設定を xsetwacom を通してやるためのサンプルスクリプト
#!/bin/bash
xsetwacom set "Wacom Bamboo 16FG 4x5 Finger touch" Touch off
xsetwacom set "Wacom Bamboo 16FG 4x5 Finger pad" Button 1 "key shift"
xsetwacom set "Wacom Bamboo 16FG 4x5 Finger pad" Button 3 "key shift equal"
xsetwacom set "Wacom Bamboo 16FG 4x5 Finger pad" Button 8 "key minus"
xsetwacom set "Wacom Bamboo 16FG 4x5 Finger pad" Button 9 "key ctrl z"
@astronasutarou
astronasutarou / deluxetable.sty.patch
Created January 17, 2014 09:34
deluxetable.sty で cont'd な table を List of Tables に載せない,かつ label の多重定義を起こさないようなハック
diff --git a/deluxetable.sty b/deluxetable.sty
index *******..******* ******
@@ -127,7 +127,13 @@
\pt@ncol=#1\relax
\global\let\pt@addcol\@empty
}%
-\newcommand\tablecaption[1]{\gdef\pt@caption{#1}}%
+\newcommand\tablecaption[1]{%
+ \gdef\pt@caption{#1}%
+ \gdef\pt@short@caption{#1}%