Skip to content

Instantly share code, notes, and snippets.

View HeGanjie's full-sized avatar

Bruce He HeGanjie

View GitHub Profile
import React from 'react'
import * as d3 from 'd3'
export default class CircularProgress extends React.Component {
constructor(props) {
super(props);
this.state = {
aProgress: props.min
}
.flex {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
.flex.flex--reverse {
-webkit-box-orient: horizontal;
@HeGanjie
HeGanjie / Drag PNG here.bat
Created September 12, 2014 01:29
bat for pngquant, auto cover original png file (DANGEROUS)
:: http://pngquant.org/
@echo off
set path=%~d0%~p0
:start
"%path%pngquant.exe" --force --ext .png --verbose --ordered --speed=1 --quality=50-90 %1

Java/Android case insensitive contains and indexOf
O(n), no Object creating, no GC, should be faster than Pattern.CASE_INSENSITIVE?

public static boolean equalsIgnoreCaseInString(String longer, int ai, String shorter, int bi) {
	int chkLen = shorter.length() - bi;
	if (longer.length() - ai < chkLen) return false;
	for (int c = 0; c < chkLen; ai++, bi++, c++) {
		char ac = longer.charAt(ai);
		char bc = shorter.charAt(bi);
[user]
email = heganjie@gmail.com
name = heganjie
[gui]
encoding = utf-8
[branch]
autosetupmerge = always
[alias]
aa = add -A
st = status
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
@HeGanjie
HeGanjie / build.gradle
Created June 5, 2014 15:42
compile android using java8
// http://www.cnblogs.com/youxilua/archive/2013/05/20/3087935.html
// https://github.com/evant/gradle-retrolambda
// http://tools.android.com/tech-docs/new-build-system/user-guide
buildscript {
repositories {
mavenCentral()
}
dependencies {
@HeGanjie
HeGanjie / _vimrc
Last active August 29, 2015 14:00
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
public static float dp2Px(float dp, Context context){
    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    return dp * (metrics.densityDpi / 160f);
}

public static float px2Dp(float px, Context context) {
    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    return px / (metrics.densityDpi / 160f);
}

在LISP之根源里面看到作者提到Y组合子,于是去了解了一下,但是看其他人的解释都很难完全弄懂。
最后通过 王垠的wiki 发现 Franco 教授的推演过程讲得最简单易懂,在看懂了之后我再用CoffeeScript推演了一次,加深理解。

LISP之根源 http://daiyuwen.freeshell.org/gb/rol/roots_of_lisp.html#foot108
王垠的wiki http://minus273.eu/mirrors/2001315450/wiki/SchemeYcombinator.html
Franco 教授的推演过程 http://www.ece.uc.edu/~franco/C511/html/Scheme/ycomb.html
可以将代码贴在这里上面验证结果 http://coffeescript.org/

  • 第一步