Skip to content

Instantly share code, notes, and snippets.

View Kroisse's full-sized avatar

Eunchong Yu Kroisse

View GitHub Profile
@Kroisse
Kroisse / gist:9001369
Created February 14, 2014 13:55
Forward remained arguments to the other script, in Flask-Script
class CeleryDaemon(script.Command):
capture_all_args = True
def run(self, args):
from project.tasks import initialize
celery = initialize(current_app)
celery.worker_main(argv=sys.argv[:1] + args)
manager.add_command('celeryd', CeleryDaemon())
@Kroisse
Kroisse / gist:9187028
Created February 24, 2014 11:54
curious
def chunks(iterable, size):
if not size > 0:
raise ValueError('size should greater than 0; not {}'.format(size))
it = iter(iterable)
def iterate():
while True:
chunk = list(islice(it, size))
if not chunk:
break
use std::rand;
use std::rand::Rng;
struct BinTree<T>(Option<~BinNode<T>>);
struct BinNode<T> {
value: T,
left: BinTree<T>,
right: BinTree<T>,
}
@Kroisse
Kroisse / ks.rs
Last active August 29, 2015 13:57
// #[feature(globs)];
extern crate collections;
// use std::iter::*;
use std::from_str::from_str;
// use std::str::from_utf8;
// use collections::hashmap::HashSet;
#[deriving(Clone)]
struct Knapsack {
score: uint,
Prelude> let all@x:xs@a:b:s = [1..4]
Prelude> (all, x, xs, a, b, s)
(1,1,2,2,3,[4])
Prelude> let all@(x:xs)@(a:b:s) = [1..4]
<interactive>:9:15: parse error on input `@'
Prelude> let all@(x:xs@a:b:s) = [1..4]
Prelude> (all, x, xs, a, b, s)
([1,2,3,4],1,2,2,3,[4])
use std::io::IoResult;
trait Shape {
fn draw(&self, size: uint, buf: &mut Writer) -> IoResult<()>;
}
fn draw<T: Shape>(shape: T, size: uint) {
match shape.draw(size, &mut std::io::stdio::stdout()) {
Ok(_) => (),
Err(e) => fail!(e),
use std::{iter, slice};
use std::io::{IoResult, Writer};
pub struct BlockWriter {
blk_size: uint,
blks: Vec<Vec<u8>>,
}
struct Blocks<'a>(slice::Items<'a, Vec<u8>>);

Keybase proof

I hereby claim:

  • I am kroisse on github.
  • I am kroisse (https://keybase.io/kroisse) on keybase.
  • I have a public key whose fingerprint is 1E03 AD64 5079 0E12 CD28 2FF2 B39A 3CA2 AD8D 5DC3

To claim this, I am signing this object:

@Kroisse
Kroisse / promise.rs
Last active August 29, 2015 14:11
Madness
#![feature(unboxed_closures)]
use std::sync::{Arc, Mutex};
use std::mem;
use PromiseState::{Ready, Fulfilled, Deferred, Done};
enum PromiseState<T, F: FnOnce(T) + Send> {
Ready,
#include <stdio.h>
#include <konami.h> //구곡해금함수
int 구곡[] = { /* 생략함다... */ };
void 구곡해금();
int main() {
/*구곡해금 조건문은 생략. 상상에 맡김미당 ㅈㅅ*/
구곡해금();
return 0;