Skip to content

Instantly share code, notes, and snippets.

View t1anchen's full-sized avatar

tianchen t1anchen

View GitHub Profile
#define v putchar
# define print(x) main(){v(4+v(v(52)-4));return 0;}/*
#>+++++++4+[>++++++<-]>++++.----.++++.*/
print(202*2);exit();
#define/*>.@*/exit()
install-info.exe /usr/share/info/guile.info.gz /cygdrive/c/Program\ Files/emacs-24.1/info/dir
@t1anchen
t1anchen / Makefile
Created October 2, 2012 15:07
C++0x Lambda Demo
CXX = i686-pc-mingw32-g++
CXXFLAGS = -Wall
CXXDEBUGFLAG = -g
CXXOPTFLAG = -O3
CXX0XFLAG = -std=c++0x
CXXLINKFLAG = -static
BINS = cxx0x-address
all: $(BINS)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; golang mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-to-list 'load-path "C:/go/misc/emacs/")
(require 'go-mode-load)
(defun distl (m N)
(cond
((null N) nil)
(t (cons (list m (car N))
(distl m (cdr N))))))
(print (distl 'b '(x y z)))
(defun cartesian (M N)
(cond
((null M) nil)
@t1anchen
t1anchen / rename.py
Last active September 29, 2019 08:45
#!/usr/bin/python
import os
import sys
import getopt
import re
import os.path
def main():
@t1anchen
t1anchen / gist:5693672
Created June 2, 2013 13:35
Remove all white spaces of all files under current directory
find . -type f -regex '.*\ .*' | awk '{gsub(/\(/,"\\(",$0);gsub(/\)/,"\\)",$0);gsub(/\ /,"\\ ",$0);orig_fname=$0;gsub(/ /,".",$0);system("mv -v " orig_fname " " $0)}'
@t1anchen
t1anchen / typoglycemia.clj
Last active December 18, 2015 13:48
Simply generate typoglycemia
(use 'clojure.string)
(defn gen-rnd-idx-seq [s]
(let [ordered-idx (range (count s))
randomed-idx (map #(rand-int %) ordered-idx)
arrayed-s (into-array s)]
(join (reduce #(let [foo-idx (first %2)
bar-idx (last %2)
foo (nth arrayed-s foo-idx)
bar (nth arrayed-s bar-idx)]
@t1anchen
t1anchen / timestamp.el
Last active December 19, 2015 04:08
emacs handy functions
(defun insert-textual-timestamp-in-diary ()
;; Set timestamp insert function. This function comes from
;; http://www.patd.net/~ciggieposeur/other/startup.el
;; RFC 3339 and ISO 8601
(interactive "*")
(insert
(concat "["
(format-time-string "%Y-%m-%dT%T%z" (current-time))
"] ")))
(global-set-key (kbd "C-c 1 `") 'insert-textual-timestamp-in-diary)
@t1anchen
t1anchen / BufferedScannerPerfTest.java
Last active December 20, 2015 00:19
Benchmark for reading and parsing 10000000 integers
package org.coursera.algs4partII002.perf;
import org.junit.Test;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;