Skip to content

Instantly share code, notes, and snippets.

View lifthrasiir's full-sized avatar

Kang Seonghoon lifthrasiir

View GitHub Profile
티비플 애니 목록
================
(애니를 골라 봅시다)
: [티비플](http://tvple.com/)에 쌓여 있는 온갖 애니들을 좀 더 편하게 보세! ㅋ
([자세한 설명](http://cosmic.mearie.org/tvple/about.html) /
2010년 10월 23일 오후 6시 40분 갱신)
케이온!
: 케이온! (1기)
/* The world's smallest Brainfuck interpreter in C, by Kang Seonghoon
* http://j.mearie.org/post/1181041789/brainfuck-interpreter-in-2-lines-of-c */
s[99],*r=s,*d,c;main(a,b){char*v=1[d=b];for(;c=*v++%93;)for(b=c&2,b=c%7?a&&(c&17
?c&1?(*r+=b-1):(r+=b-1):syscall(4-!b,b,r,1),0):v;b&&c|a**r;v=d)main(!c,&a);d=v;}
@lifthrasiir
lifthrasiir / ere2pcre.php
Created November 18, 2010 07:59
a drop-in replacement for ereg* functions in PHP
<?php
// ere2pcre -- a drop-in replacement for ereg* functions
// written by Kang Seonghoon <[email protected]>.
//
// this library is dedicated to the public domain. for the jurisdictions that
// does not recognize the public domain, CC0 1.0 Universal Public Domain
// Dedication applies.
function _ere2pcre_escape($c) {
if ($c == "\0") {
var cutString = function(s, width, trail) {
if (typeof trail == 'undefined') trail = '…';
var w = 0;
for (var i = 0; i < s.length; ++i) {
// we approximate east-asian width using the most prevalent ideographic blocks
w += (s.charAt(i).match(/[\u3000-\u9fff\uac00-\ud7ff\uf900-\ufaff]/) ? 2 : 1);
if (w > width) return s.substring(0, i) + trail;
}
return s;
};
@lifthrasiir
lifthrasiir / 2to10to7.c
Created April 18, 2011 20:37
2^(10^k)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
typedef uint32_t digit; // should be able to represent 0..3*BASE-1
typedef uint64_t digit2; // should be as large as maxdigit + maxdigit * maxdigit
#define BASE 1000000000u
@lifthrasiir
lifthrasiir / Makefile
Created April 20, 2011 05:05
simplistic genetic TSP solver, circa May 2010 (you need tspdata.h to run it)
tspsolve: tspsolve.c tspdata.h
gcc -O3 -s -mtune=core2 -std=c99 -W -Wall -lm tspsolve.c -o tspsolve
@lifthrasiir
lifthrasiir / README.txt
Created July 10, 2011 19:04
A little program that converts "a hundred" to "100". (Updated!)
These little programs read a spelt (EDIT: it is not "spoken") number from the
standard input and write the corresponding number to the standard output. Weigh
just 243 bytes and 227 bytes of C. (EDIT: was originally 256 and 240 bytes.)
The longer version handles numbers up to 999,999,999,999,999, that is, just
shy of 1,000 trillions. The shorter version handles numbers up to 19,999,999,
or 999,999,999 if your "int" is 64 bits long. The input should be correct,
although it will handle "a" and "and" correctly and ignore some invalid
words.
@lifthrasiir
lifthrasiir / bms2html5.py
Created August 15, 2011 13:45
quick and dirty BMS-to-HTML5 converter
import sys, os, urllib
wavs = {}
lines = {}
linesln = {}
stretches = {}
bpm = 120.0
maxpos = 0
precision = 1 << 16
for l in open(sys.argv[1], 'r'):
@lifthrasiir
lifthrasiir / big.ml
Created October 4, 2011 08:35
Big_int disguised as a plain int (Or: how to abuse Ocaml's gc without actually messing it)
type real_int =
| Small of int
| Big of Big_int.big_int
let pack = function
| Small v -> v
| Big v -> (Obj.magic v : int)
let unpack v =
if Obj.is_int (Obj.repr v) then Small v else Big (Obj.magic v : Big_int.big_int)
@lifthrasiir
lifthrasiir / check.sh
Created February 5, 2012 16:06
simple code golf checker.
#!/bin/bash
STDERR=/dev/null
if [ "$1" = '-v' ]; then
STDERR=/dev/stderr
shift
fi
if [ $# -lt 1 ]; then
echo "Usage: $0 [-v] filename ..."
exit 1
fi