Skip to content

Instantly share code, notes, and snippets.

@luochen1990
luochen1990 / stack.yaml
Created February 15, 2017 01:47
note: stack install SourceGraph failed
#resolver: ghc-7.8.4
resolver: ghc-7.10.2
packages:
- '.'
extra-deps:
- SourceGraph-0.7.0.7
- Graphalyze-0.14.1.1
@luochen1990
luochen1990 / bad-whitespace-example.txt
Last active September 25, 2023 07:52
团队协作的场景下, 需要对团队成员的git使用方式有一定的要求, 以保证协作的畅通和高效.
hello
tab indent
space indent
tab indent with following space
space before tab
space at eol (trailing-space)
tab at eol (trailing-space)
blank at eof (also trailing-space)
@luochen1990
luochen1990 / git-checkoutr
Created June 14, 2017 03:14
User defined Git Command to auto update submodule when checkout branch.
#!/bin/sh
# add this file to your path so that you can run it as an git command via `git checkoutr xxx`
br=$1
test -z $br || git checkout $br
git submodule update --init --recursive
@luochen1990
luochen1990 / rawToPng.sh
Created September 20, 2017 13:57
Convert an android raw screenshot to PNG
ffmpeg -loglevel panic -f rawvideo -pix_fmt bgr32 -s 2560x1440 -i screenshot.raw -vcodec png -vframes 1 screenshot.png -y
@luochen1990
luochen1990 / CATS-script.py
Created October 27, 2017 05:10
C.A.T.S auto fighting script, depending on adb
#coding:utf-8
import subprocess
import time
from PIL import Image
def call(cmd):
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return proc.stdout.read()
### general tools
@luochen1990
luochen1990 / check-node-icu.sh
Last active November 7, 2017 06:51
Check if NODE_ICU_DATA is configured correctly. 检查 NODE ICU DATA 的配置是否正确.
node --print "['吃', '矮', '笨', 'c', 'a', 'b'].sort((a, b) => a.localeCompare(b, 'zh-Hans-CN')).join('') === '矮笨吃abc'"
# Expected Output: true
@luochen1990
luochen1990 / type-infer-problem-in-dependent-pair.idr
Created January 13, 2018 03:48
Idris 1.2.0 can not infer type of tuple in Dependent Pair
data Color = Red | Blue
data Size = S | M | L
data Ball : (c : Color) -> (s : Size) -> Type where
MkRedSBall : Ball Red S
MkRedMBall : Ball Red M
arr : List (c : Color ** s : Size ** Ball c s)
arr = [(Red ** S ** MkRedSBall), (Red ** M ** MkRedMBall)]
@luochen1990
luochen1990 / PhraseEdit.txt
Last active November 20, 2024 17:33
搜狗输入法 - 数学&逻辑符号输入设置
; 搜狗输入法: 设置 -> 高级 -> 自定义短语设置 -> 直接编辑配置文件
;  配置文件格式: <按键序列> "逗号" <位置> "等于号" <目标字符序列>
; 希腊字母: 参考 https://en.wikipedia.org/wiki/Greek_alphabet
Alpha,1=Α
alpha,1=α
Nu,9=Ν
nu,9=ν
@luochen1990
luochen1990 / completed-kata-score.js
Last active March 14, 2018 16:51
Calculate Kata Score in Codewars (www.codewars.com)
total = ['white', 'yellow', 'blue', 'purple', 'black'].map((x, i) => $('.kata .is-' + x + '-rank').length *2*(4**i)).reduce((x, y) => x+y)
count = ['white', 'yellow', 'blue', 'purple', 'black'].map((x) => $('.kata .is-' + x + '-rank').length)
//visit https://www.codewars.com/users/USERNAME/completed , and scroll to bottom of the page, and run above code in console.
@luochen1990
luochen1990 / gen-arith-expr-puzzle.hs
Created March 20, 2018 14:14
如何以1,1,4,5,1,4固定顺序,不论计算方式组合,排列出0-99的所有数字? https://www.zhihu.com/question/269086028
import Data.List
import GHC.Exts
type Number = Int
data Op = Add | Sub | Mul | Div | Pow deriving (Show, Eq, Ord, Enum, Bounded)
data AST = BinOp Op AST AST | Lit [Number] deriving (Eq, Ord)
instance Show AST where
show (BinOp op x y) = "(" ++ show x ++ pure ("+-*/^" !! fromEnum op) ++ show y ++ ")"