Skip to content

Instantly share code, notes, and snippets.

@krtx
krtx / Bisim.agda
Last active August 29, 2015 14:07
strong bisimulation is equivalence
module Bisim where
open import Data.Nat
open import Data.List
open import Data.Product using (∃; _×_; _,_; proj₁; proj₂)
open import Relation.Binary using (IsEquivalence)
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
{
"1. Nature": {
"Weather and landscape symbols": {
"BLACK SUN WITH RAYS": "☀",
"CLOUD": "☁",
"UMBRELLA WITH RAIN DROPS": "☔",
"SNOWMAN WITHOUT SNOW": "⛄",
"HIGH VOLTAGE SIGN": "⚡",
"CYCLONE": "🌀",
"FOGGY": "🌁",
@krtx
krtx / snum.ml
Created March 16, 2014 06:55
surreal number implementation from On Numbers and Games
type snum = snums * snums
and snums = Nil | Cons of (snum * snums)
let zero = (Nil, Nil)
let one = (Cons (zero, Nil), Nil)
let mone = (Nil, Cons (zero, Nil))
let half = (Cons (zero, Nil), Cons (one, Nil))
let two = (Cons (one, Nil), Nil)
let rec map f = function
@krtx
krtx / agif.cpp
Last active December 19, 2015 19:38
animation gif player 256 colors version
#include <Magick++.h>
#include <ncurses.h>
#include <unistd.h>
#include <vector>
#include <algorithm>
int main(int argc, char *argv[])
{
bool full = false;
@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
@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 / 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 / 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 / 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
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