Skip to content

Instantly share code, notes, and snippets.

View Kroisse's full-sized avatar

Eunchong Yu Kroisse

View GitHub Profile
@Kroisse
Kroisse / info.md
Last active December 15, 2015 05:49
I think that CPython treats TypeError specially in the generator expression. So do PyPy.

Related issue:

>>> import redis
>>> client = redis.StrictRedis()
>>> client
<redis.client.StrictRedis object at 0x102fdbb10>
>>> p = client.pipeline()
>>> p.info()
<redis.client.StrictPipeline object at 0x103190050>
>>> client.info()
{'aof_rewrite_in_progress': 0, 'run_id': ......}
>>>
@Kroisse
Kroisse / loop.py
Last active December 15, 2015 13:39
import eventlet
eventlet.monkey_patch()
import time
import flask
def a(i):
# shsh~~!
return '<p>{0}</p>'.format(i)
@Kroisse
Kroisse / home.html
Last active December 15, 2015 21:19
A simple Flask example
<!DOCTYPE html>
<html>
<body>
{% for c in comments %}
<p>{{ c }}</p>
{% endfor %}
<form action="/" method="post">
<input type="text" name="comment" />
<button type="submit">Comment</button>
</form>
fn main() {
let filename = match os::args() {
[_, filename] => filename,
args => {
io::println(fmt!("Usage: %s <filename>", args[0]));
return
}
};
let str = match io::read_whole_file_str(&path::Path(filename)) {
@Kroisse
Kroisse / .gitignore
Last active December 15, 2015 23:59 — forked from yoloseem/htmlfill.py
__pycache__/
*.pyc
@Kroisse
Kroisse / gist:5533457
Last active December 17, 2015 02:09
trivial single producer - multiple consumer example. rustc 0.6 stable
fn main() {
let chans = do vec::from_fn(5) |i| {
let (port, chan) = stream();
do spawn {
let mut buffer = ~[];
loop {
match port.try_recv() {
Some(v) => {
buffer.push(v);
if buffer.len() >= 5 {
// http://euler.synap.co.kr/prob_detail.php?id=5
fn factorize(n: int) -> ~[(int, uint)] {
let mut v = n;
let mut p = 2;
do vec::build |push| {
while v > 1 {
let mut c = 0;
while v % p == 0 {
c += 1;
// http://euler.synap.co.kr/prob_detail.php?id=3
// rustc 0.6
fn factorize(n: int) -> ~[(int, uint)] {
let mut v = n;
let mut p = 2;
do vec::build |push| {
while v > 1 {
let mut c = 0;
while v % p == 0 {
// http://euler.synap.co.kr/prob_detail.php?id=4
// rustc 0.6
pub trait Palindrome {
fn is_palindrome(&self) -> bool;
}
impl Palindrome for int {
// int 타입에 대한 is_palindrome() 메서드 구현
pub fn is_palindrome(&self) -> bool {