Skip to content

Instantly share code, notes, and snippets.

View harrifeng's full-sized avatar

Harri Feng harrifeng

View GitHub Profile
@harrifeng
harrifeng / build.xml
Last active December 10, 2015 07:58
Ant configure file for error message use English. The fork="true" is must-have.
<?xml version="1.0"?>
<project name="firstbuild" default="compile">
<target name="compile">
<javac srcdir="." fork="true" >
<compilerarg value="-J-Duser.language=en"/>
<compilerarg value="-J-Duser.country=US"/>
</javac>
<echo>compilation complete!</echo>
</target>
</project>
@harrifeng
harrifeng / mutable_length_array.c
Created January 10, 2013 09:33
Four way to *declare* mutable length array.
void f(int, int [*][*]);
void f(int n, int [*][m]);
void f(int n, int [n][n]);
void f(int, int [][*]);
#!/usr/bin/tclsh8.5
#
# Usage: git-unmerged branch1 branch2
#
# Shows all the non-common commits in the two branches, where non-common
# commits means simply commits with a unique commit *message*.
proc getlog branch {
lrange [split [exec git log $branch --oneline] "\n"] 0 400
}
@harrifeng
harrifeng / hello.md
Last active December 15, 2015 11:39

Readme

To collect all the algorithm work from previous two project

  1. sum_cci written in c
  2. sum_algo wrtten in cpp
(provide 'modeline-setting)
;; Mode line setup
(setq-default
mode-line-format
'(; Position, including warning for 80 columns
(:propertize "[%04l:" face mode-line-position-face)
(:eval (propertize "%03c]" 'face
(if (>= (current-column) 80)
'mode-line-80col-face
def print_file(path = "test.txt"):
"""print every word in the file
Arguments:
- `path`: file name
"""
mapped = dict()
with open(path, 'r') as f:
for line in f:
# print line.rstrip('\r\n')
# Torndb is a very thin wrapper around MySQLdb that makes it even easier to use MySQL.
# Because it is very light, one can just go through the one-file python source
# to learn how to use it.
# Installation: pip install torndb
# Official doc: http://torndb.readthedocs.org/en/latest/
# Source: https://github.com/bdarnell/torndb/blob/master/torndb.py
from torndb import Connection
@harrifeng
harrifeng / emacs.el
Created August 31, 2013 08:32
tmp file to special character
;; (setq whitespace-display-mappings
;; ;; all numbers are Unicode codepoint in decimal. try (insert-char 182 ) to see it
;; '(
;; (space-mark 32 [183] [46]) ; 32 SPACE, 183 MIDDLE DOT 「·」, 46 FULL STOP 「.」
;; (newline-mark 10 [182 10]) ; 10 LINE FEED
;; ;; (tab-mark 9 [9655 9] [92 9]) ; 9 TAB, 9655 WHITE RIGHT-POINTING TRIANGLE 「▷」
;; ))
;;
class myConnection(torndb.Connection):
"""
In torndb version 0.1, the time zone can not be set. we have to create our own connection class
and reconnect()
"""
def __init__(self, host=None, database=None, user=None, password=None, time_zone="+8:00"):
torndb.Connection.__init__(self, host=host, database=database, user=user, password=password)
self._db_args['init_command'] = ('SET time_zone = "%s"' % time_zone)
try:
self.reconnect()
# Client Side----------------------------------------
# Please cheng the `sh-rd-hfeng to your server's host-name
# Usage: python client.py <str> -- if <str> is 'Done', it
# will tell the server you are OK now and the server will close,
# any other strings will continue the server works
import socket
import sys
HOST, PORT = "sh-rd-hfeng", 9988