Skip to content

Instantly share code, notes, and snippets.

@krtx
krtx / le4a_example.rb
Created November 9, 2012 08:03
le4a-typeinfernantoka
# coding: utf-8
require 'mechanize'
require 'pp'
agent = Mechanize.new
page = agent.get('http://www.fos.kuis.kyoto-u.ac.jp/~t-sekiym/classes/isle4/testcases.html')
number = 1
@krtx
krtx / svm_plot.sh
Last active October 13, 2015 23:38
usage: ./svm_plot.sh sample_data graph_data
#!/bin/sh
vector=$1
border=$2
/usr/bin/gnuplot <<EOF
ismin(x) = (x<min)?min=x:0
ismax(x) = (x>max)?max=x:0
grabx(x)=(x<x0)?x0=x:(x>x1)?x1=x:0
@krtx
krtx / 5f.agda
Last active October 26, 2015 08:28
module 5f where
postulate
A : Set
B : Set
postulate
a′ : A
b′ : B
module Z3 = ZZ3.Make (struct let ctx = Z3.mk_context [] end)
open Z3
let solve board =
let cells =
Array.init 9 (fun i ->
Array.init 9 (fun j ->
Symbol.declare Int (Printf.sprintf "%d%d" i j)))
291 126 -1
269 60 1
293 291 1
265 195 1
380 133 -1
294 211 1
170 156 -1
180 249 1
239 201 1
293 164 -1
@krtx
krtx / group.rb
Last active December 16, 2015 09:38
the ruby program which calculates conjugacy classes of symmetry groups and alternate groups
require 'pp'
require 'set'
class Array
def rotmin
self.rotate(self.index(self.min))
end
end
class Permutation < Array
@krtx
krtx / group.lisp
Last active December 16, 2015 11:28
the *lisp* program which calculates conjugacy classes of symmetric groups and alternating groups
;; '((1 . 2) (2 . 3) (3 . 1))
;; '((1 . 4) (2 . 3) (4 . 1) (3 . 2))
;; '((5 . 1) (4 . 2) (2 . 5) (3 . 4) (1 . 3))
(defun mapping (item g)
(cdr (assoc item g)))
(defun normalize (g)
(sort g #'(lambda (x y) (< (car x) (car y)))))
@krtx
krtx / sc.rb
Created June 3, 2013 17:39
mp3のタグを書き換えるスクリプト ruby 1.9.2
require 'mp3info'
dir = '/my/music/library/'
Dir::glob(dir + '*.mp3').each {|f|
Mp3Info.open(f) do |mp3|
t = mp3.tag.title
title = t.slice(t.rindex('/') + 2, t.length)
artist = t.slice(0, t.rindex('/') - 1)
if title.index(' - ')
@krtx
krtx / parse.rb
Created June 10, 2013 12:04
aaaaaaaaaaaaaaaaaaaaaaaaaaaa
require 'pp'
str = 'a+b*c*(d+e)+f+g'
$idx = 0
def term(str)
ops = []
while $idx < str.length
if str[$idx] == '('
@krtx
krtx / catagif.rb
Last active December 19, 2015 10:49
animation gif player on terminal
#!/usr/bin/env ruby
require 'curses'
require 'RMagick'
Curses.noecho
Curses.init_screen
Curses.stdscr.keypad(true)
Curses.start_color
Curses.timeout = 0 # non-blocking getch