Skip to content

Instantly share code, notes, and snippets.

View hlian's full-sized avatar
🦫
beaver

Hao Lian hlian

🦫
beaver
View GitHub Profile
@hlian
hlian / Power.hs
Created January 11, 2013 19:18
how do you get the i^th element of P^exp(natural numbers), where P^exp is the exp^th power set function
import Data.List (intercalate)
data Tree t = Leaf t | Branch [Tree t]
instance Show t => Show (Tree t) where
show (Leaf n) = show n
show (Branch ts) = "[" ++ (intercalate "," $ map show ts) ++ "]"
indiciesFrom n =
let f 0 i = []
@hlian
hlian / _README.txt
Created December 3, 2012 16:17
[PATCH STABLE] localrepo: clear filecache correctly on destroyed()
* Run like this: `rm -r /tmp/foo; hg init /tmp/foo; python test.py`
* 2be2a is the parent of http://selenic.com/hg/rev/9f94358
* f94ea is the tip of stable as of writing
* Running hg verify after running the test script yields the output seen in verify.f94ea.output
@hlian
hlian / build_exe.diff
Created May 1, 2012 15:11
how to get build_exe to not byte-compile at all
--- /cygdrive/c/code/build_exe_mine.py 2012-05-01 10:56:41.466200000 -0400
+++ /cygdrive/c/Python27-64/Lib/site-packages/py2exe/build_exe.py 2012-05-01 11:11:08.271068800 -0400
@@ -1514,7 +1514,7 @@
# "Indirect" byte-compilation: write a temporary script and then
# run it with the appropriate flags.
- if not direct and False:
+ if not direct:
from tempfile import mktemp
@hlian
hlian / profile.ps1
Created February 29, 2012 22:32
powershell profile!
function Check-Resolve {
hg resolve -l | ForEach-Object { Select-String '<<<' $_.Split()[1] }
}
Set-Alias cr Check-Resolve
function Grep-Service($regex) {
Get-Service | ? { $_.Name -match $regex }
}
[DataContract]
public class Search {
[DataMember("movies")]
public List<Movies> Movies { get; set; }
[DataMember("link_template")]
public string LinkTemplate { get; set; }
[DataMember("links")]
public Links Links { get; set; }
PS C:\code\elasticsearch-opengrok> mvn archetype:generate
[INFO] Scanning for projects...
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom (5 KB at 9.6 KB/sec)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom
Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom (13 KB at 27.4 KB/sec)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/16/maven-parent-16.pom
Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/16/maven-parent-16.pom (23 KB at 46.3 KB/sec)
Downloading: http://repo1.maven.org/maven2/org/apache/apache/7/apache-7.pom
Downloaded: http://repo1.maven.org/maven2/org/apache/apache/7/apache-7.pom (15 KB at 39.5 KB/sec)
@hlian
hlian / node_debian_init.sh
Created December 25, 2011 02:14 — forked from peterhost/node_debian_init.sh
Daemon init script for node.js based app/server (DEBIAN/UBUNTU)
#!/bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
bad friends
-----------
chris
good friends
------------
everybody else
@hlian
hlian / philosophy.py
Created May 26, 2011 16:00
EVERY WIKIPEDIA ARTICLE CONVERGES TO PHILOSOPHY
#!/usr/bin/env python
import gzip
import urllib2
from cStringIO import StringIO
from lxml import etree, html
from lxml.cssselect import CSSSelector
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
@hlian
hlian / gist:964009
Created May 10, 2011 06:41
playerless: post-hao
# Report 7 - Session 5 - Time Profile of game
SharkProfileViewer
# Generated from the visible portion of the outline view
+ 97.9%, start, game
| + 97.9%, main, game
| | + 86.5%, GLUTMainLoop(), game
| | | + 86.5%, glutMainLoop, GLUT
| | | | + 86.5%, -[GLUTApplication run], GLUT
| | | | | + 86.3%, __glutProcessWorkEvents, GLUT
| | | | | | + 86.3%, processWindowWorkList, GLUT