Skip to content

Instantly share code, notes, and snippets.

View falcondai's full-sized avatar

Falcon Dai falcondai

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
0-mail.com
0815.ru
0clickemail.com
0wnd.net
0wnd.org
10minutemail.com
20minutemail.com
2prong.com
30minutemail.com
3d-painting.com
@falcondai
falcondai / benchmark.py
Created May 2, 2012 17:58
This computes the average run time of a piece of python code.
# File: benchmark.py
# Desc: This computes the average run time of a piece of code.
# Author: Falcon Dai
# Date: 5/2/2012
import time
global_dict = globals()
# should be run as soon as the module is imported to
@falcondai
falcondai / donation_gadget.html
Created July 10, 2012 08:22
A gadget that combines Google Wallet/Checkout and PayPal's donation buttons at one place. It also provides input validation and Google analytics integration. Disclaimer: you can use this freely but it does not have any warranty.
<!-- Google Checkout/Paypal donation gadget -->
<!-- written by Falcon Dai, falcondai.com -->
<!--
Usage: Replace all occurrences of {mid} by your Google Merchant ID, {name} by your name, and {pid} by your PayPal account email then it should work.
Disclaimer: you can use this freely but it does not have any warranty. If you like it, you can buy me a coffee.
-->
<p>You can buy me a coffee!</p>
<b>via Google Checkout</b>
@falcondai
falcondai / d3-cache-helper.js
Created September 21, 2012 18:51
Use Web Storage (or fallback to a JS object) to cache jsons for the async JSON method in d3js (http://d3js.org/).
// use HTML5 Web Storage or an object to cache
localStorage = localStorage || sessionStorage || {};
sessionStorage = sessionStorage || {};
// @param work: a function that works on k, i.e. of the form function(k) {}
// @param is_permanent: true if the data should be stored in localStorage, else in sessionStorage
function perform(work, k, url, is_permanent) {
var s = is_permanent? localStorage : sessionStorage;
if (s[k]) {
@falcondai
falcondai / sml-ps2-solution.ipynb
Last active October 24, 2015 22:22
SML p set 2 solution
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@falcondai
falcondai / sml-ps3-solution.ipynb
Created November 8, 2015 05:09
SML p set 3 solution
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@falcondai
falcondai / barchart.html
Last active December 19, 2015 21:48
a reusable bar chart (following the paradigm lay out in mbostock's blog post: http://bost.ocks.org/mike/chart/).
<!doctype html>
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
@falcondai
falcondai / .emacs
Last active December 21, 2015 00:18
custom init setup for Emacs 24
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-enabled-themes (quote (deeper-blue)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
@falcondai
falcondai / Makefile
Last active December 21, 2015 03:58
Makefile for packaging chrome extensions
EXT_NAME=omni
all: clean pages package
pages:
jade jade/*.jade -Po .
clean:
rm -rf *~
rm -f $(EXT_NAME).zip