Skip to content

Instantly share code, notes, and snippets.

View luochen1990's full-sized avatar
🏠
Working from home

Luo Chen luochen1990

🏠
Working from home
View GitHub Profile
@luochen1990
luochen1990 / .zshrc
Last active May 23, 2019 06:41 — forked from zedongh/.zshrc
zsh config
[[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile'
[[ -e ~/.shrc ]] && emulate sh -c 'source ~/.shrc'
source $HOME/.antigen.zsh
# POWERLEVEL9K_INSTALLATION_PATH=$ANTIGEN_BUNDLES/bhilburn/powerlevel9k
antigen use oh-my-zsh
antigen bundles <<EOF
npm
@luochen1990
luochen1990 / SimpleABAC.hs
Last active January 9, 2019 07:22
a simple ABAC (Attribute Based Access Control) system implementation in Haskell
-- | This is a module to explain the Attribute based access control system
-- , [ABAC](https://en.wikipedia.org/wiki/Attribute-based_access_control)
-- , [XACML](https://en.wikipedia.org/wiki/XACML)
module SimpleABAC where
import Data.Foldable
type AccessorAttr = String
type ResourceAttr = String
type OperationAttr = String
@luochen1990
luochen1990 / mklink_examples.md
Last active February 12, 2019 08:18
Create symbolic link in Windows
@luochen1990
luochen1990 / .bashrc
Last active August 2, 2018 23:53
the `dx` alias: a convenient wrapper of the `docker exec` command
docker_exec() {
matches=$( docker ps | grep $1 )
echo "$matches"
pid=$(echo $matches | awk "{print \$1}" )
echo Entering: $pid
docker exec -it $pid sh
}
alias dx="docker_exec"
@luochen1990
luochen1990 / conemu-msys2-bash-task.txt
Created June 19, 2018 12:21
Cmder (ConEmu) Task config: {msys2:bash}
Task parameters:
/icon "c:\dev\msys2\msys2.ico" /dir "%CMDER_START%"
Command:
set CHERE_INVOKING=1 & set MSYS2_PATH_TYPE=inherit & %ConEmuDrive%\dev\msys2\usr\bin\bash.exe --login -i -new_console:t:"bash"
References:
@luochen1990
luochen1990 / EitherExample.java
Created May 15, 2018 07:45
ADT Sum Type in Java
import java.util.function.Function;
public class EitherExample {
public static void main(String[] args) {
Either<String, Integer> x = new Left<>("hello");
Either<String, Integer> y = new Right<>(123);
System.out.println("hello");
System.out.println(x);
System.out.println(y);
}
@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 ++ ")"
@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 / 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 / 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)]