Skip to content

Instantly share code, notes, and snippets.

View qiao's full-sized avatar

Xueqiao (Joe) Xu qiao

View GitHub Profile
@qiao
qiao / .jshintrc
Created May 31, 2012 18:23
My configuration file for jshint
// vim: set filetype=javascript:
// See http://www.jshint.com/options/ for the elaboration of the options.
// The comment after each entry is the result of applying this configuration.
// When toggling the booleans, don't forget to change the comments as well.
{
// Enforcing Options
@qiao
qiao / ip.js
Created January 17, 2012 11:27
Node.js get client IP address
// snippet taken from http://catapulty.tumblr.com/post/8303749793/heroku-and-node-js-how-to-get-the-client-ip-address
function getClientIp(req) {
var ipAddress;
// The request may be forwarded from local web server.
var forwardedIpsStr = req.header('x-forwarded-for');
if (forwardedIpsStr) {
// 'x-forwarded-for' header may return multiple IP addresses in
// the format: "client IP, proxy 1 IP, proxy 2 IP" so take the
// the first one
var forwardedIps = forwardedIpsStr.split(',');
@qiao
qiao / stackoverflow_monitor.py
Created January 5, 2012 10:21
Monitor for new questions on StackOverflow
#!/usr/bin/env python
# Monitor for new questions on StackOverflow
# Author: Xueqiao Xu <xueqiaoxu@gmail.com>
import time
import json
import gzip
import pprint
import urllib
import urllib2