Skip to content

Instantly share code, notes, and snippets.

@Haroperi
Haroperi / listgen.rb
Created April 2, 2012 01:25
Freshman list
#coding:utf-8
#
# input:
# Fullname [TAB] College [TAB] Prefecture [TAB] School code [TAB] School name
#
require 'CSV'
require 'pp'
require 'nkf'
@Haroperi
Haroperi / pankuz.js
Created June 25, 2012 05:00
パンくずリスト with js
// add following HTML to your HTML file.
// <div id="pankuz"></div>
// <script type="text/javascript" src="pankuz.js"></script>
// definition of each pages
table = {
"foo.github.ac.jp": {
"name": "foo github",
"directory": {
"name": "the title of this directory",
@Haroperi
Haroperi / timer.rkt
Created June 28, 2012 16:00
timer with racket/gui
#lang racket/gui
; DrRacket, version 5.2.1
; 情報科学類ソフトウェアサイエンス主専攻実験
; M.NAKAJIMA
; 2012/06/29
; Create a window and show message.
(define frame (new frame% [label "Timer"]))
(define msg (new message% [parent frame]
@Haroperi
Haroperi / gist:3024941
Created June 30, 2012 18:25
動的言語でファイルのcloseをデストラクタにまかせる場合のちょっとした落とし穴
# generate a file (1000 lines)
def make_1000lines
f = open("hoge", 'w')
1000.times do |i|
f.puts i.to_s * 100
end
end
make_1000lines()
puts `wc -l hoge` # 989 is printed in my environment.
@Haroperi
Haroperi / gist:3661820
Created September 7, 2012 00:22
most long repeat
l = gets
l.chomp!
while /^(.+)\1+/ =~ l
l = $1
end
puts l
@Haroperi
Haroperi / gist:3721290
Created September 14, 2012 10:56
convert from space separated to matrix (wolfram alpha format)
l = gets
num_list = l.split(/\s/)
n = Math.sqrt(num_list.size).to_i
print '{'
n.times {
print '{'
(n-1).times {
print "%s, " % num_list.shift
}
@Haroperi
Haroperi / komachi.pl
Last active December 13, 2015 20:09
Komachi calculation
% komachi
digit(X) :- member(X, [0,1,2,3,4,5,6,7,8,9]).
is_composed_of(N, X, Y) :-
digit(X),
digit(Y),
(Z is X+Y;
Z is X-Y;
Z is Y-X;
@Haroperi
Haroperi / fdtd.rb
Last active December 14, 2015 12:49
FDTD algorithm in Ruby
include Math
require 'pp'
X = 10
T = 4
PI = 3.14
dt = 1
dx = 1
@Haroperi
Haroperi / slidepuzzle.pl
Last active December 22, 2015 03:59
list rules for slide puzzle written in Prolog
% スライドパズルの移動のルール
move_one([0,B,C,D,E,F,G,H,I], [B,0,C,D,E,F,G,H,I]).
move_one([A,0,C,D,E,F,G,H,I], [0,A,C,D,E,F,G,H,I]).
move_one([0,B,C,D,E,F,G,H,I], [D,B,C,0,E,F,G,H,I]).
move_one([A,B,C,0,E,F,G,H,I], [0,B,C,A,E,F,G,H,I]).
move_one([A,0,C,D,E,F,G,H,I], [A,C,0,D,E,F,G,H,I]).
move_one([A,B,0,D,E,F,G,H,I], [A,0,B,D,E,F,G,H,I]).
move_one([A,0,C,D,E,F,G,H,I], [A,E,C,D,0,F,G,H,I]).
move_one([A,B,C,D,0,F,G,H,I], [A,0,C,D,B,F,G,H,I]).
[~/work/now/mlr/third_party/dtm_release/dtm]$ gdb main haro@harombp 2013/09/27 10:19:13
GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 15 08:33:48 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ..... done
(gdb) run