Skip to content

Instantly share code, notes, and snippets.

View lepture's full-sized avatar
💭
I'm working on Typlog.com now

Hsiaoming Yang lepture

💭
I'm working on Typlog.com now
View GitHub Profile
@lepture
lepture / quemail.py
Created September 26, 2011 15:44
quemail
# -*- coding: utf-8 -*-
'''
Simple implementation of mailer based on thread and queues. Early version.
copy from https://github.com/marcinc81/quemail/blob/master/quemail.py
@author: Marcin Chwalek <marcin@chwalek.pl>
Example of use:
# at start
@lepture
lepture / student.c
Created December 7, 2011 14:50
forget c
#include<stdio.h>
#include<stdlib.h>
#define MAX 100
int choice=1, count=0;
double scores[MAX][6];
int notify() {
printf("\nYou can do:\n [1]: Input a Student Score\t[2]: Print Students Scores\t[3]: Sort Students Scores\t[4]:Exit\n>>> ");
scanf("%d", &choice);
@lepture
lepture / smtp.py
Created December 14, 2011 16:01 — forked from koblas/smtp.py
SMTP Client for Tornado
from tornado import ioloop
from tornado import iostream
import socket
class Envelope(object):
def __init__(self, sender, rcpt, body, callback):
self.sender = sender
self.rcpt = rcpt[:]
self.body = body
self.callback = callback
@lepture
lepture / lib.less
Created January 12, 2012 04:13
less: the missing lib
.animation() {
-webkit-animation: @arguments;
-moz-animation: @arguments;
-ms-animation: @arguments;
-o-animation: @arguments;
animation: @arguments;
}
.animation-delay() {
-webkit-animation-delay: @arguments;
-moz-animation-delay: @arguments;
@lepture
lepture / gist:1727348
Created February 3, 2012 02:57
tornado http proxy
#!/usr/bin/env python
#coding:utf-8
import sys, os, re
import logging
import socket
import urlparse
from tornado import iostream, ioloop
from tornado.httpserver import HTTPServer
from tornado import httputil
@lepture
lepture / emoji.py
Created March 10, 2012 15:54
emoji support in python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012, lepture.com
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
@lepture
lepture / instance_cache.py
Created March 23, 2012 07:08
instance cache
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012, lepture.com
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
@lepture
lepture / xiami.py
Created March 23, 2012 10:06
decode xiami music location
import urllib
def decode_xiami_location(s):
totle = int(s[0])
s1 = s[1:]
chu = len(s1) / totle
yu = len(s1) % totle
stor = []
@lepture
lepture / finder.js
Created March 28, 2012 11:54
find and sort in js
var find = function(data, word){
if(!word.length) return [];
var results = [];
var fuzzyResults = [];
for (i=0; i<data.length; i++) {
var _fuzzy = true;
var item = data[i];
if(item.key.toLowerCase().indexOf(word) != -1){
item.order = item.key.toLowerCase().indexOf(word);
results.push(item);
@lepture
lepture / gist:2723398
Created May 18, 2012 05:42
Guardfile
from livereload.task import Task
def delay():
import time
time.sleep(10) # 10s
Task.add('*', delay)