Skip to content

Instantly share code, notes, and snippets.

View ibigbug's full-sized avatar
🏓
Focusing

Yuwei Ba ibigbug

🏓
Focusing
View GitHub Profile
@ibigbug
ibigbug / imageScroll.html
Created June 9, 2012 18:37
Image Scoll Demo
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>imageScroll</title>
</head>
<body>
</body>
<script type="text/javascript">
function $(e) { return document.getElementById(e); }
@ibigbug
ibigbug / count_online_number.py
Created July 21, 2012 06:45
Tornado count online number
#!/usr/bin/env python
# -*- coding:utf8 -*-
import os
import tornado.web
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
import uuid
@ibigbug
ibigbug / clean_google_contacts.py
Last active December 12, 2015 05:48
Clean up your google contacts
#!/usr/bin/env python
def is_cn_char(c):
"""
Chinese char detecting
"""
return 0x4e00 <= ord(c) <= 0x9fa5
@ibigbug
ibigbug / derived-function.clj
Last active December 14, 2015 10:10
Solve the derived function of a given function.
(defn diff [f]
(fn [x]
(let [dx (/ 1 Integer/MAX_VALUE)] ;nearly 0
(/ (- (apply f [(+ x dx)]) (apply f [x])) dx))))
(defn g [x] ; given function
(* x x))
(def dg (diff g)) ; get dg
(print (float (dg 3))) ; 6
@ibigbug
ibigbug / dichotomy.clj
Created March 4, 2013 12:54
Dichotomy theorems in Clojure
(defn F [a b c]; generate the target function
(fn [x]
(+ (* (+ (* a x) b) x) c)))
(def f1 (F 1 2 1))
(defn
^{:doc "(Solve f a b)
f-- the target function
a,b the interval for isolating the root"
@ibigbug
ibigbug / gene_wave.py
Created March 23, 2013 11:31
Generate simple.wav using python
#!/usr/bin/env python2
#coding:utf-8
import numpy
import wave
class MainHandler(object):
def __init__(self, duration=10, frequency=2000):
@ibigbug
ibigbug / tieba_crawler.py
Created April 9, 2013 17:05
Baidu Tieba Crawler
#!/usr/bin/env python2
#coding:utf-8
import re
import time
import os
import urllib
import requests
@ibigbug
ibigbug / node-walk.js
Created May 15, 2013 08:48
node-walk
var fs = require('fs'),
path = require('path');
exports.walk = function(abspath, callback){
/*
* callback will get { dirname: {file1: file1_abs_path, subdir: { fil2: file2_abs_path, subdir2: {}.. }};
* if not callback passed, it just returns a tree like above;
*/
@ibigbug
ibigbug / call-forward.js
Created June 15, 2013 17:38
A Call Forwarding System
#!/usr/bin/env node
/*
* Author: ibigbug
* Language: NodeJS
*/
var fs = require('fs');
function Controller(){ // Global Controller
@ibigbug
ibigbug / js-encryption.js
Last active December 31, 2015 10:29
A encryption
var crypto = require('crypto');
function CodeUserName(name) {
var md5 = crypto.createHash('md5');
var time = Math.floor((new Date()).getTime() / 1000);
time = 1387112383;
var timediv5 = Math.floor(time / 5);
var timestr = "";