Skip to content

Instantly share code, notes, and snippets.

@luochen1990
luochen1990 / shareAP.bat
Created April 8, 2015 02:50
Windows上创建WIFI热点 共享网络连接
netsh wlan show drivers
netsh wlan set hostednetwork mode=allow ssid=SharedAP key=12345678
netsh wlan start hostednetwork
@echo 创建虚拟网卡成功后,需要共享当前的Internet连接:
@echo -- 打开[网络和共享中心]
@echo -- 点击[更改适配器设置]
@echo -- 右键{你现在上网用的连接,如'本地连接'}
@echo -- 点击[属性]
@echo -- 点击[共享]
import Data.List
import Data.Function
import Control.Monad
groupOn f = groupBy ((==) `on` f) . sortBy (compare `on` f)
uniq = map (!! 0) . groupOn id
-- 场景:假设a得到了数字x,b得到了数字y
-- 可看做二分图,其中possibleX,possibleY是顶点,possible是边,(aGuessY x)和(bGuessX y)分别表达x点和y点的邻接点集
possible = [(5, 15), (5, 16), (5, 19), (6, 17), (6, 18), (7, 14), (7, 16), (8, 14), (8, 15), (8, 17)]
@luochen1990
luochen1990 / aggregator.coffee
Last active August 29, 2015 14:20
stream data aggregator
require 'coffee-mate/global'
compareDictOn = (f) ->
(da, db) ->
[da, db] = [f(da), f(db)]
for k, va of da
vb = db[k]
if (not vb?) or (va < vb)
return -1
else if (not va?) or (va > vb)
isPrime x = all (\p -> x `mod` p /= 0) . takeWhile ((<= x) . (^ 2)) $ primes
primes = 2 : 3 : filter isPrime [5..]
@luochen1990
luochen1990 / kochSnowflake.hs
Created January 14, 2017 09:46
The koch Snowflake implementation (with bmp exports)
{-# language NoMonomorphismRestriction #-}
import Control.Monad
import Test.QuickCheck hiding (scale)
import Codec.BMP
import qualified Data.ByteString
import Data.Word
--------------------- Point & Vec etc ----------------------
type Scalar = Double
@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 / most-used-regex.coffee
Last active February 15, 2017 01:51
Most Used Regex in JavaScript
capitalize = (s) -> s.replace /(?:_|^)([a-z])/g, (_, c) -> c.toUpperCase() # 'hello_world' to 'HelloWorld'
uncapitalize = (s) -> s.replace /([A-Z])/g, (_, c) -> '_' + c.toLowerCase() # 'HelloWorld' to 'hello_world'
is_chinese_char = (c) -> /[\u4E00-\u9FA5\uF900-\uFA2D]/.test c
@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