Skip to content

Instantly share code, notes, and snippets.

View sunng87's full-sized avatar
👑
keep calm and git push -f

Ning Sun sunng87

👑
keep calm and git push -f
View GitHub Profile
sel=geany.selection()
geany.launch('rxvt-unicode', '-e', 'man','2', sel)
@sunng87
sunng87 / gist:846150
Created February 27, 2011 12:42
Seat Query of TOEFL in China
#! /usr/bin/python3
import urllib.parse
import http.client
import html.parser
from datetime import datetime
def get_seat_status(location, month):
""" get free seat status for given location(Beijing) and month(201104)
"""
@sunng87
sunng87 / gist:865574
Created March 11, 2011 07:28
Lifestream widget on my site
var YAHOO_PIPE_URL = "http://pipes.yahoo.com/pipes/pipe.run?_id=7NxhUNSA3RG_BCC6BBNMsA&_render=json";
function lifeStreamCallback(stream){
var lifeStreamRootDom = document.getElementById("lifestream");
try{
lifeStreamRootDom.removeChild(lifeStreamRootDom.getElementsByTagName("ul")[0]);
}catch(e) {}
var lifeStreamListDom = document.createElement("ul");
for(var i=0; i<stream.count; i++) {
@sunng87
sunng87 / anonymous_class.py
Created April 29, 2011 06:08
Convert a python function to a Java anonymous class
#
# usage, convert this work method to a Runnable anonymous class
#
# @anonymous_class(Runnable, 'run')
# def work(dummy):
# print 'hello world'
#
# work.run()
#
import types
@sunng87
sunng87 / lighttpd.conf
Created May 28, 2011 01:00
Share directory with lighttpd
server.document-root="/your/path/to/share"
server.port = 8099
#server.bind = "192.168.1.100"
dir-listing.activate = "enable"
@sunng87
sunng87 / .conkyrc
Created September 16, 2011 12:42
My OpenBox Desktop
# conky configuration
# edited by darcon@gmail.com
# set to yes if you want Conky to be forked in the background
background no
# X font when Xft is disabled, you can pick one with program xfontsel
#font 5x7
#font 6x10
#font 7x13
@sunng87
sunng87 / init.el
Created September 19, 2011 07:26
My emacs configuration, start with emacs-starter-kit
;;; init.el --- Where all the magic begins
;;
;; Part of the Emacs Starter Kit
;;
;; This is the first thing to get loaded.
;;
;; "Emacs outshines all other editing software in approximately the
;; same way that the noonday sun does the stars. It is not just bigger
;; and brighter; it simply makes everything else vanish."
;; -Neal Stephenson, "In the Beginning was the Command Line"
@sunng87
sunng87 / project.clj
Created October 26, 2011 05:58
upvotes in subreddits
(ns reddit-visualization.core
(:require [reddit.clj.core :as reddit])
(:import [javax.swing JFrame])
(:import [org.jfree.chart ChartFactory ChartPanel])
(:import [org.jfree.data.general DefaultPieDataset])
(:import [org.jfree.util SortOrder]))
(def reddit-client (reddit/login nil nil))
(defn map-reddits [user after-id]
@sunng87
sunng87 / core.clj
Created October 28, 2011 07:34
clojure code for mining reddit upvotes
(ns reddit-visualization.core
(:refer-clojure :exclude [replace])
(:use [clojure.pprint])
(:use [clojure.string :only [lower-case replace split]])
(:require [clojure.java.jdbc :as jdbc])
(:require [reddit.clj.core :as reddit])
(:import [javax.swing JFrame])
(:import [org.jfree.chart ChartFactory ChartPanel])
(:import [org.jfree.data.general DefaultPieDataset])
(:import [org.jfree.util SortOrder]))
@sunng87
sunng87 / summary.py
Created November 15, 2011 09:58
simple hg extension to aggregate commit history by week
"""Display commit summary by week."""
import time
def summary(ui, repo, fs='', **opts):
"""Display commit summary by week"""
buckets = []
init_date = repo[0].date()[0]
now = time.time()