Skip to content

Instantly share code, notes, and snippets.

View youknowone's full-sized avatar
😂
Being Lazy

Jeong, YunWon youknowone

😂
Being Lazy
View GitHub Profile
all:
rustc test.rs
./test
run: all
trait Trait {
fn method() { println!("delegation") }
}
struct Component { x: int }
impl Trait for Component { }
struct Composition { comp: Component }
#[delegate="comp"]
@youknowone
youknowone / sequence.swift
Last active August 29, 2015 14:02
How to implement custom sequence(for-in container) in Swift
class HundredContainer: Sequence {
var count = 0;
typealias GeneratorType = GeneratorOf<Int>
func generate() -> GeneratorType {
return GeneratorOf<Int>({
if self.count < 100 {
self.count += 1
return self.count
} else {
rpaheui$ ./aheui-c snippets/bahmanghui/bahmanghui.aheui < snippets/bahmanghui/bahmanghui.in
48175
rpaheui$ cat snippets/bahmanghui/bahmanghui.aheuic
????
pushchar ; L0 밯 (0, 0) 1
popnum ; L1 망 (0, 1) 12
halt ; L2 망 (0, 1) 2
rpaheui$ ./aheui-c snippets/bahmanghui/bahmanghui.aheuic < snippets/bahmanghui/bahmanghui.in
48175
$ cat loop.aheuis
push 1000000
loop: dup
brz halt
push 1
sub
jmp loop
halt: popnum
halt
$ python aheui.py loop.aheuis
@youknowone
youknowone / hangulize-html.js
Last active September 24, 2015 23:47
inline hangulize html based on 'lang' attribute
/* Created by youknowone <hangulize@youknowone.org> in 2011
NO right reserved.
This script provides inline functions to hangulize html document based on 'lang' attribute of each element.
For example,
<span lang="eo">La Espero</span>
upper one will be replaced to
<span lang="eo"><abbr title="라 에스페로">La Espero</abbr></span>
In complex case,
@youknowone
youknowone / waterjug.hs
Created March 27, 2011 16:16
waterjug by bfs not efficient
jugstates (fst_max, snd_max) = bfs [[(0, 0)]]
where
bfs [] = []
bfs (s@(h@((a,b):_)):ss) = s : bfs (ss++(map (:h) next_states))
where
fill_first = (fst_max,b)
fill_second = (a,snd_max)
first_to_second
| snd_max > a+b = (0, a+b)
@youknowone
youknowone / printstar.c
Created April 4, 2011 08:13
Print 4-edged star with numbering gradation
#include <stdio.h>
#define PRINT printf("%c", (i*X>j*Y&&j*X>i*Y) ? '9'-((i<j?i*X-Y*j:j*X-Y*i)*9)*X/((X-Y)*X*size) : ' ')
int main() {
int size;
int i, j;
int X, Y;
printf("input size of star> ");
scanf("%d", &size);
printf("input space by ratio type (X/Y), X and Y should be positive integer> ");
#!/bin/bash
for size in 29 57 72 512; do
f=Icon_"$size"x"$size".png
cp "$1" "$f"
sips -z $size $size "$f"
done
for size in 29 50 57 60 72 76 512; do
f=Icon_"$size"x"$size"@2x.png
cp "$1" "$f"
>>> from korean import Noun, NumberWord, Loanword
>>> fmt = u'{subj:은} {obj:을} 먹었다.'
>>> print fmt.format(subj=Noun(u'나'), obj=Noun(u'밥'))
나는 밥을 먹었다.
>>> print fmt.format(subj=Noun(u'나'), obj=Noun(u'bob'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "korean/morphology/substantive.py", line 38, in __format__
text = merge(self, Particle(separated_spec.pop(0)))
File "korean/morphology/__init__.py", line 77, in merge