Skip to content

Instantly share code, notes, and snippets.

View wecing's full-sized avatar
🍄
Growing mushrooms

Chenguang Wang wecing

🍄
Growing mushrooms
View GitHub Profile
@wecing
wecing / ffmpeg-still-image-video.sh
Created August 29, 2012 01:02
Create video with still image
ffmpeg -loop 1 -r 1 -i image.png -i audio.mp3 -shortest output.mp4
@wecing
wecing / ea.md
Created September 6, 2012 00:59
Tools & Data

Tools

(You could read the "line", "shell", and "regular expression" parts later.)

~/bin

You could create a folder at anywhere (better if under your home directory) with any name you like (usually "bin") to create your own shell commands. After creating the folder, add this line to ~/.profile.local(create it if it doesn't exist) :

PATH=$PATH:~/bin

Then put your own scripts to the folder (~/bin here) and after logging out and re-logging in, you would be able to run any commands under the folder from anywhere.

@wecing
wecing / hmm.rkt
Created October 17, 2012 01:56
Hmm...
#lang racket
;; recur-1, I guess maybe the problem could be avoided
;; by implementing call carefully?
(fun "recur-1" "x"
(ifgreater (var "x") (int 1)
(add (call (var "recur-1")
(add (var "x")
(int -1)))
(var "x"))
@wecing
wecing / OMFG.m
Created October 25, 2012 05:27
OMFG
// str[_j * w + _i] = location[j]
[str replaceCharactersInRange:NSMakeRange(_j * w + _i, 1)
withString:[location substringWithRange:NSMakeRange(j, 1)]];
@wecing
wecing / rr.c
Created February 5, 2013 10:57
rotate right
int main () {
...
Node *root;
...
root = rotate_right(root);
...
}
Node *rotate_right(Node *n) {
Node *r = n->left;
@wecing
wecing / run.sh
Last active December 13, 2015 17:39
errseg_tagger_for_uw
# first -- sorry that in this case, you have to set the environment variables before running ./configure.
# the script will write "CFLAGS=xxx" in the generated Makefile, which is different from what I expected ("CFLAGS+=xxx").
#
# then run "make clean" in the four sub directorys and the topmost directory.
# do this before running ./configure --prefix=/full/path/to/the/target/directory
# notice that "./configure --prefix=$(workspace)/xxx" will not work.
# I know this is stupid, but it works...
export CFLAGS="-I/homes/iws/wangc8/software/include -L/homes/iws/wangc8/software/lib"
@wecing
wecing / happy.txt
Created February 20, 2013 06:57
happy happy
Parser/DLCParser.hs:1495:16:
Couldn't match expected type `PExpr' with actual type `PTExpr'
Expected type: Int
-> Token
-> HappyState
Token
(HappyStk
(HappyAbsSyn
t0
t1
@wecing
wecing / dlc-output.hs
Created February 23, 2013 06:07
The whole parsed data structure, without pretty-printing...
-- compiler-in-haskell $ ./dlc examples/oop/
[PRootClassDef ("Pos",Nothing,[Right (Nothing,False,(PInt,[("x",Nothing)])),Right (Just PProtected,Fal
se,(PBool,[("b",Nothing)])),Left (Nothing,False,(PVoid,"init",[],[Right (PNull,PExprAssign (PNull,PExp
rDotAccess (PNull,PExprVar "self") "x") (PNull,PExprInt 42)),Right (PNull,PExprAssign (PNull,PExprDotA
ccess (PNull,PExprVar "self") "b") (PNull,PExprBool True))])),Left (Nothing,False,(PVoid,"dumpX",[],[L
eft (PStmtPrint [(PNull,PExprDotAccess (PNull,PExprVar "this") "x")]),Left (PStmtPrint [(PNull,PExprCh
ar 10)])])),Left (Nothing,False,(PVoid,"dumpB",[],[Left (PStmtPrint [(PNull,PExprStr "b is "),(PNull,P
ExprDotAccess (PNull,PExprVar "self") "b"),(PNull,PExprChar 10)])])),Left (Nothing,False,(PVoid,"setX"
,[(PInt,"x")],[Right (PNull,PExprAssign (PNull,PExprDotAccess (PNull,PExprVar "this") "x") (PNull,PExp
rVar "x"))])),Left (Nothing,False,(PVoid,"setB",[(PBool,"b")],[Right (PNull,PExprAssign (PNull,PExprDo
@wecing
wecing / b.java
Last active December 14, 2015 10:59
344 VideoStore bug?
else if (t.equals("fastsearch")) {
/* same as search, only faster (and single words only) */
if (st.hasMoreTokens()) {
String movie_word = st.nextToken(); // !!!!!!!!!!!!!!!!!!!!!!!!!
System.out.println("Fast Searching for the movie '"
+ movie_word + "'");
q.transaction_fastSearch(cid, movie_word);
} else {
System.out.println("Error: need to type in movie title");
}
@wecing
wecing / gist:5236053
Created March 25, 2013 09:49
My Emacs configure file (Mar. 25, 2013)
(add-to-list 'load-path "~/.emacs.d/")
;;; ; command=>meta
; (setq mac-command-modifier 'meta)
; for aquamacs: fullscreen
(global-set-key (kbd "<M-f12>") 'ns-toggle-fullscreen)
;;; scratch mode
(setq initial-major-mode 'text-mode)