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
@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 {
trait Trait {
fn method() { println!("delegation") }
}
struct Component { x: int }
impl Trait for Component { }
struct Composition { comp: Component }
#[delegate="comp"]
all:
rustc test.rs
./test
run: all
#!/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"
@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> ");
@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 / 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,