This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;中文与英文字体设置 | |
;; Setting English Font | |
(set-face-attribute | |
'default nil :font "Monaco 14") | |
;; Chinese Font | |
(dolist (charset '(kana han symbol cjk-misc bopomofo)) | |
(set-fontset-font (frame-parameter nil 'font) | |
charset | |
(font-spec :family "WenQuanYi Micro Hei Mono" :size 16))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import codecs | |
import tempfile | |
METHOD_PATTERN = re.compile('\s*[^/]+\s*(public|private|protected)\s+[^class]\s*[a-zA-Z][a-zA-Z0-9_]*\s+[a-zA-Z][a-zA-Z0-9_]*\s*\(') | |
JS_METHOD_PATTERN = re.compile('\s*[^/]+\s*public\s+[^class]\s*[a-zA-Z][a-zA-Z0-9_]*\s+[a-zA-Z][a-zA-Z0-9_]*\s*\(') | |
JS_INTERFACE_PATTERN = re.compile('\s*@JavascriptInterface') | |
JS_ANNOTATION = '\t@JavascriptInterface\n' | |
JS_ANNOTATION_CLASS_NAME = 'android.webkit.JavascriptInterface' | |
JS_ANNOTATION_IMP = 'import android.webkit.JavascriptInterface;\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In software engineering, the Initialization on Demand Holder (design pattern) idiom is a lazy-loaded singleton. | |
In all versions of Java, the idiom enables a safe, highly concurrent lazy initialization with good performance. | |
public class Something { | |
private Something() {} | |
private static class LazyHolder { | |
private static final Something INSTANCE = new Something(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
访问一级缓存 | |
Branch mispredict 5 ns | |
分支误预测 | |
L2 cache reference 7 ns 14x L1 cache | |
访问二级缓存 | |
Mutex lock/unlock 25 ns | |
互斥锁 加锁/解锁 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Android Utility Function Library | |
================================ | |
If you need a feature that is native to Linux but not present on other | |
platforms, construct a platform-dependent implementation that shares | |
the Linux interface. That way the actual device runs as "light" as | |
possible. | |
If that isn't feasible, create a system-independent interface and hide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git 常用命令: | |
--------------------------------------- | |
1. tag: | |
------------------------- | |
git tag 列出所有tag | |
git tag -a [tag-name] -m [tag-description] 创建 tag | |
git show [tag-name] 显示该 tag 的信息 | |
git push origin [local-tag-name] 推送本地 tag 到远程 | |
git push origin --tags 推送本地所有 tag 到远程 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;1.3 Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. | |
(define (sq x)(* x x)) | |
(define (f2 x y)(if (< x y) x y)) | |
(define (f3 x y z)(f2 (f2 x y) (f2 y z))) | |
(define (sum_3 x y z)(- (+ (sq x) (sq y) (sq z)) (sq(f3 x y z)))) | |
;;1.4 implemenets: | |
;; (define (a-plus-abs-b a b) | |
;; ((if (> b 0) + -) a b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create a file named /tmp/android.rules with the following contents (hex vendor numbers were taken from the vendor list page): | |
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666", GROUP="plugdev" | |
SUBSYSTEM=="usb", ATTRS{idVendor}=="0e79", MODE="0666", GROUP="plugdev" | |
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666", GROUP="plugdev" | |
SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", MODE="0666", GROUP="plugdev" | |
SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", MODE="0666", GROUP="plugdev" | |
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666", GROUP="plugdev" | |
SUBSYSTEM=="usb", ATTRS{idVendor}=="091e", MODE="0666", GROUP="plugdev" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// test the gist file show in the blogspot | |
#include <stdio.h> | |
int main(){ | |
println("hello world"); | |
exit(0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open cv android 学习: | |
------------------------------------------------------------------ | |
1.基本数据结构: java name -> c/c++ name | |
Point Point3 -> CvPoint, CvPoint2D32f, CvPoint3D32f | |
Size -> CvSize, CvSize2D32f | |
Rect -> CvRect | |
Scalar -> CvScalar 数据容器,最多可保存4个double值 | |
TermCriteria -> CvTermCriteria ?? | |
Mat -> CvMat 单通道或者多通道矩阵 | |
Imgproc 图像处理函数类 |