Skip to content

Instantly share code, notes, and snippets.

View foreversmart's full-sized avatar
🤒

Rorschach foreversmart

🤒
View GitHub Profile
define deep_test
$(eval current = $(subst ...,,$(1)))
$(eval files = $(wildcard src/$(current)*/))
$(eval testFiles = $(filter %_test.go, $(files)))
$(if $(testFiles),go test $(current))
$(eval packages = $(filter %/, $(files)))
$(if $(packages),$(foreach package,$(packages),$(call deep_test,$(subst src/,,$(package))...)))
endef
@foreversmart
foreversmart / colors.js
Created June 15, 2020 10:02
// 用法 console 打下面两行 // 可以 https://www.arealme.com/colors/zh/ 网站的颜色识别中作弊,自动点击不一样的颜色块
// 用法 console 打下面两行
// 可以 https://www.arealme.com/colors/zh/ 网站的颜色识别中作弊,自动点击不一样的颜色块
f = function(){
a = document.getElementById("box")
c = ""
cc = 0
d = ""
dc = 0
a.childNodes.forEach(function(s){
@foreversmart
foreversmart / 正则替换 type 为 某 package 下的 alias
Last active August 11, 2020 03:17
正则替换 type 为 某 package 下的 alias
// params struct 调整为 common 包的alias
type (\w+) struct \{\n([,/|\[\]\s\w\*\(\)\?`:".-]+)\n\}
type $1 = common.$1
// params string 调整为 common 包的alias
type (\w+) string
type $1 = common.$1
// params int 调整为 common 包的alias
type (\w+) int
@foreversmart
foreversmart / reverse.go
Created August 26, 2020 07:12
golang 字符串翻转
// only support ascii
func reverseString(s string) string {
b := []byte(s)
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
// switch
b[i], b[j] = b[j], b[i]
}
return string(b)
}