番茄工作法, 番茄钟, Pomodoro
‘番茄工作法, 番茄钟, Pomodoro’ 简单来说,就是把工作时间划分为多个番茄时间。一个番茄时间包含两个部分: 25分钟的工作学习和5分钟的休息。
‘番茄工作法, 番茄钟, Pomodoro’ 简单来说,就是把工作时间划分为多个番茄时间。一个番茄时间包含两个部分: 25分钟的工作学习和5分钟的休息。
Golang,Signal https://colobu.com/2015/10/09/Linux-Signals/ 信号(Signal)是Linux, 类Unix和其它POSIX兼容的操作系统中用来进程间通讯的一种方式。一个信号就是一个异步的通知,发送给某个进程,或者同进程的某个线程,告诉它们某个事件发生了。 当信号发送到某个进程中时,操作系统会中断该进程的正常流程,并进入相应的信号处理函数执行操作,完成后再回到中断的地方继续执行。 如果目标进程先前注册了某个信号的处理程序(signal handler),则此处理程序会被调用,否则缺省的处理程序被调用。 signals := make(chan os.Signal) signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGTERM) // ... for s := range signals { if s == os.Interrupt || s == os.Kill || s == syscall.SIGTERM { break } } signal.Stop(signals) Go中的Signal发送和处理 有时候我们想在Go程序中处理Signal信号,比如收到SIGTERM信号后优雅的关闭程序(参看下一节的应用)。 Go信号通知机制可以通过往一个channel中发送os.Signal实现。 首先我们创建一个os.Signal channel,然后使用signal.Notify注册要接收的信号。 package main import “fmt” import “os” import “os/signal” import “syscall” func main() { // Go signal notification works by sending os.Signal // values on a channel. We’ll create a channel to // receive these notifications (we’ll also make one to // notify us when the program can exit). sigs := make(chan os.Signal, 1) done := make(chan bool, 1) // signal.Notify registers the given channel to // receive notifications of the specified signals. signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) // This goroutine executes a blocking receive for // signals. When it gets one it’ll print it out // and then notify the program that it can finish. go func() { sig := <-sigs fmt.Println() fmt.Println(sig) done <- true }() // The program will wait here until it gets the // expected signal (as indicated by the goroutine // above sending a value on done) and then exit. fmt.Println(“awaiting signal”) <-done fmt.Println(“exiting”) } go run main.go执行这个程序,敲入ctrl-C会发送SIGINT信号。 此程序接收到这个信号后会打印退出。 ...
golang SOCKS5 proxy, http proxy https://segmentfault.com/a/1190000038247560 https://github.com/wiloon/pingd-proxy https://golangnote.com/topic/258.html
golang http get resp, err := http.Get("http://example.com/") http post func httpPostForm() { // params:=url.Values{} // params.Set("hello","fdsfs") //这两种都可以 params= url.Values{"key": {"Value"}, "id": {"123"}} resp, _:= http.PostForm("http://baidu.com", body) defer resp.Body.Close() body, _:= ioutil.ReadAll(resp.Body) fmt.Println(string(body)) } proxy https://www.flysnow.org/2016/12/24/golang-http-proxy.html package main import ( "bytes" "fmt" "io" "log" "net" "net/url" "strings" ) func main() { log.SetFlags(log.LstdFlags | log.Lshortfile) l, err := net.Listen("tcp", ":8080") if err != nil { log.Panic(err) } for { client, err := l.Accept() if err != nil { log.Panic(err) } go handleClientRequest(client) } } func handleClientRequest(client net.Conn) { if client == nil { return } defer client.Close() log.Println(client.RemoteAddr()) var b [1024]byte n, err := client.Read(b[:]) if err != nil { log.Println(err) return } var method, host, address string fmt.Sscanf(string(b[:bytes.IndexByte(b[:], '\n')]), "%s%s", &method, &host) hostPortURL, err := url.Parse(host) if err != nil { log.Println(err) return } if hostPortURL.Opaque == "443" { //https访问 address = hostPortURL.Scheme + ":443" } else { //http访问 if strings.Index(hostPortURL.Host, ":") == -1 { //host不带端口, 默认80 address = hostPortURL.Host + ":80" } else { address = hostPortURL.Host } } //获得了请求的host和port,就开始拨号吧 server, err := net.Dial("tcp", address) if err != nil { log.Println(err) return } if method == "CONNECT" { fmt.Fprint(client, "HTTP/1.1 200 Connection established\r\n\r\n") } else { server.Write(b[:n]) } //进行转发 go io.Copy(server, client) io.Copy(client, server) } https://segmentfault.com/a/1190000013262746
Shell 判断进程是否存在 #! /bin/bash function check(){ count=`ps -ef |grep $1 |grep -v "grep" |wc -l` #echo $count if [ 0 == $count ];then nohup python /runscript/working/$1 & fi } ———————————————— 版权声明: 本文为CSDN博主「栎枫」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 原文链接: https://blog.csdn.net/superbfly/article/details/52513765
hyphen、en dash 和 em dash https://cherysunzhang.com/2016/08/using-hyphen-and-dash-correctly/ 在 Unicode 中 hyphen-minus 与 hyphen 和 minus 都是不同的符号,但是在 ASCII 中则是用 hyphen-minus 来同时替代 hyphen 和 minus,所以这就是其名称的来源。 为了适应早期的打字机和计算机,不得不作出妥协。除了用 hyphen-minus 这个符号来代替 hyphen 和 minus,以前经常还会用它直接代替 en dash。 因为大部分的编程语言都限制只能够使用 ASCII,所以在编写代码时所使用的表示负数或数字相减的符号即是 hyphen-minus,以及在变量名称中使用的连接符号。 另外,Unicode 中还有一个类似的 full hyphen-minus (-) 。
golang init init函数的主要作用: 初始化不能采用初始化表达式初始化的变量。 程序运行前的注册。 实现sync.Once功能。 其他 init函数的主要特点: init函数先于main函数自动执行,不能被其他函数调用; init函数没有输入参数、返回值; 每个包可以有多个init函数; 包的每个源文件也可以有多个init函数,这点比较特殊; 同一个包的init执行顺序,golang没有明确定义,编程时要注意程序不要依赖这个执行顺序。 不同包的init函数按照包导入的依赖关系决定执行顺序。 golang程序初始化 golang程序初始化先于main函数执行,由runtime进行初始化,初始化顺序如下: 初始化导入的包(包的初始化顺序并不是按导入顺序(“从上到下”)执行的,runtime需要解析包依赖关系,没有依赖的包最先初始化,与变量初始化依赖关系类似,参见golang变量的初始化); 初始化包作用域的变量(该作用域的变量的初始化也并非按照“从上到下、从左到右”的顺序,runtime解析变量依赖关系,没有依赖的变量最先初始化,参见golang变量的初始化); 执行包的init函数;
word basic 英文破折号、连接号、连字符、负号的区别 Hyphen (-) Hyphen 的 Unicode 编码是 U+2010,在 MS Word 里可以先输入 2010 再按 Alt +x。 不过在 ASCII 编码系统中,hyphen 被编为45号字符「hyphen-minus」,也就是我们电脑键盘上「0」和「=」之间的那个「-」。在通常情况下我们直接使用这个符号就可以了。 MS Word 中 hyphen后面跟数字, 在换行时会被拆开显示。 · En dash (–) En dash 的 Unicode 编码是 U+2013,在 MS Word 里可以先输入 2013 再按 Alt + x,更简便的方法是利用 MS Word 的自动更正功能: 按空格,按两下「-」,再按空格,例如输入「this is - atest」,将转换为「this is – a test」 (当然,要注意 en dash 前后一般是不留空格的) 。 En dash 在 Windows 里可以用 Alt + 0150 (即按下 Alt 键的同时依次按下 0150) 来输入,在 Mac 里可以用⌥+ - 来输入,在 TeX 里可以用 - 输入,在 HTML 里可以用 – 来输入。 ...
chrome os, crostini, 开发环境 crostini 的Debian 对snap 支持不全, 不能使用snap 应用 terminal https://snugug.com/musings/developing-on-chrome-os/ terminal, tilix crostini默认的terminal在使用oh my zsh时,光标显示不正常。 安装tilix,从chromeos启动tilix使用terminal sudo pacman -S tilix # 在chromeos中启动tilix使用shell 或者使用Secure Shell App idea 慢的问题 File->Settings->Plugins. Click marketplace, search for “Choose Runtime” Install official Choose Runtime addon from JetBrains Wait for install and click to restart IDE. Once back in project, press shift twice to open the search window Search for Runtime. Select “Choose Runtime” Change to “jbrsdk-8u-232-linux-x64-b1638.6.tar.gz”, which should be the very last one at the bottom of the list. ...
xxd, 以 16进制查看文件 xxd 命令用于使用二进制或十六进制格式显示文件内容,可以将指定文件或标准输入以十六进制转储,也可以把十六进制转储转换成原来的二进制形式。 command xxd -b file xxd file
tr command # 转大写 echo 'hello' | tr '[:lower:]' '[:upper:]' # 转小写 echo 'HELLO' | tr '[:upper:]' '[:lower:]' # 删除文本中的换行符 tr -d '\n' < input.txt > output.txt # 删除空行 cat file | tr -s "\n" > new_file tr -s "[\012]" < plan.txt tr -s ["\n"] < plan.txt 什么是 tr 命令? tr, translate 的简写 \NNN character with octal value NNN (1 to 3 octal digits) \\ backslash \a audible BEL \b backspace \f form feed \n new line \r return \t horizontal tab \v vertical tab CHAR1-CHAR2 all characters from CHAR1 to CHAR2 in ascending order [CHAR*] in SET2, copies of CHAR until length of SET1 [CHAR*REPEAT] REPEAT copies of CHAR, REPEAT octal if starting with 0 [:alnum:] all letters and digits [:alpha:] all letters [:blank:] all horizontal whitespace [:cntrl:] all control characters [:digit:] all digits [:graph:] all printable characters, not including space [:lower:] all lower case letters [:print:] all printable characters, including space [:punct:] all punctuation characters [:space:] all horizontal or vertical whitespace [:upper:] all upper case letters [:xdigit:] all hexadecimal digits [=CHAR=] all characters which are equivalent to CHAR https://blog.csdn.net/jeffreyst_zb/article/details/8047065 通过使用tr,您可以非常容易地实现 sed 的许多最基本功能。您可以将 tr 看作为 sed的 (极其) 简化的变体: 它可以用一个字符来替换另一个字符,或者可以完全除去一些字符。您也可以用它来除去重复字符。这就是所有 tr所能够做的。 ...
‘golang unsigned shift, 无符号右移’ int32 转 uint32 再右移 https://stackoverflow.com/questions/33336336/go-perform-unsigned-shift-operation func Test10(t *testing.T) { x1 := -100 result := uint32(x1) >> 2 fmt.Println(result) }
golang interface interface 是一种类型 type foo interface { Get() int } 首先 interface 是一种类型,从它的定义可以看出来用了 type 关键字,更准确的说 interface 是一种具有一组方法的类型,这些方法定义了 interface 的行为。 go 允许不带任何方法的 interface ,这种类型的 interface 叫 empty interface。 如果一个类型实现了一个 interface 中所有方法,我们说类型实现了该 interface,所以所有类型都实现了 empty interface,因为任何一种类型至少实现了 0 个方法。go 没有显式的关键字用来实现 interface,只需要实现 interface 包含的方法即可。 ‘golang 获取interface{} 的数据类型’ https://blog.csdn.net/xia_xing/article/details/49423771 interface{} 可以接受任何类型的对象值 获取interface{}队形的数据类型,可以使用断言,或者 switch type 来实现 // Assertion project main.go package main import ( “fmt” ) type Bag struct { Key string } type Bag2 struct { Key int } func main() { ...
mount –bind https://xionchen.github.io/2016/08/25/linux-bind-mount/ The bind mounts bind 是 mount 中比较特殊的用法之一,这里对一些例子进行分析和实验 bind 的意思是,把其他地方的子树再进行挂载,也就是说可以把文件系统中的某一个部分进行挂载。这个特性是从 linux2.4.0 开始的。 或者更简单的说,就是挂载一个已有的文件夹 常见使用场景 在做一些 chroot 的操作的时候, 我们希望把当前的文件系统的一个目录(例如/dev) 出现在 chroot 的目录下. 但是又不希望 chroot 对这个目录进行更改, 我们该怎么做呢? 首先, 我们可以使用 mount –bind 将 /dev 目录挂载到 chroot 的目录下: mount --bind /dev $chrootdir/dev 这样, 我们从chroot的目录和自己本身的文件系统的目录就都可以访问/dev目录. 不过有时我们不希望挂载的目录是可以修改的. 那么,可以通过下面的命令将挂载的属性设置为 readonly 的这样就实现了上述的要求 mount -o remount,ro,bind /dev $chrootdir/dev 最基础的用法的如下 mount --bind olddir newdir 如果执行了上面这个命令,在 olddir 和 newdir 都可以访问相同的内容,并且如果对其中一个目录内的内容进行了修改,在另一个目录会有相同的显示。 下面的命令可以创建一个挂载点 mount --bind foo foo 在挂载后可以通过 mount 命令查看所有的挂载点 如果要递归的挂载一个目录可以使用如下命令 mount -rbind olddir newdir 递归的挂载是指如果挂载的 olddir 内有挂载点,会把这个挂载点也一起挂载到 newdir 下。 ...
sftp https://linuxize.com/post/how-to-use-linux-sftp-command-to-transfer-files/ sftp remote_username@server_ip_or_hostname >sftp pwd >sftp ls >sftp cd /tmp >sftp lcd ~/tmp >sftp get foo.zip
remote jobs https://github.com/remoteintech/remote-jobs https://github.com/lukasz-madon/awesome-remote-job
google voice Apple客服: +1(800)275-2273 微软客服: +1 (800) 642-7676 Google Voice简介及使用&保号 保号 电话呼出 可以找有GV的熟人互打,相信网友为了隐私起见是不会和你互打的。这里也提供几个免费的美国号码供大家拨打: +1 (415) 787-4253 某IFTTT的定时拨号服务御用号码,是机器人 +1 (888) 280-4331 亚马逊免费客服电话 电话呼入 IFTTT 我觉得这是最优解,用IFTTT的定时服务定期拨打电话给你即可,这里推荐两个service Keep Google Voice Active 一个月拨打一次,可自定义时间和日期 Alarm Clock Phone Call 强迫症福利,可自定义拨打频率、时间
Spring静态注入的三种方式 Spring静态注入的三种方式: (说明: MongoFileOperationUtil是自己封装的一个Mongodb文件读写工具类,里面需要依赖AdvancedDatastore对象实例,dsForRW用来获取Mongodb数据源) 在springframework里,我们不能@Autowired一个静态变量,使之成为一个spring bean,例如下面这种方式: @Autowired private static AdvancedDatastore dsForRW; 可以试一下,dsForRW在这种状态下不能够被依赖注入,会抛出运行时异常java.lang.NullPointerException,为什么呢?静态变量/类变量不是对象的属性,而是一个类的属性,spring则是基于对象层面上的依赖注入。 但是自己比较喜欢封装工具类,并通过@Component注解成功能组件,但是功能组件中的方法一般都是静态方法,静态方法只能调用静态成员变量,于是就有了下面的问题。封有的时候封装功能组件会需要底层的service注入,怎么办呢? 去网上搜了下解决办法,简单总结一下几种实现方式; 1.xml方式实现; public class MongoFileOperationUtil { private static AdvancedDatastore dsForRW; private static MongoFileOperationUtil mongoFileOperationUtil; public void init() { mongoFileOperationUtil = this; mongoFileOperationUtil.dsForRW = this.dsForRW; } } 这种方式适合基于XML配置的WEB项目; 2.@PostConstruct方式实现; import org.mongodb.morphia.AdvancedDatastore; import org.springframework.beans.factory.annotation.Autowired; @Component public class MongoFileOperationUtil { @Autowired private static AdvancedDatastore dsForRW; private static MongoFileOperationUtil mongoFileOperationUtil; @PostConstruct public void init() { mongoFileOperationUtil = this; mongoFileOperationUtil.dsForRW = this.dsForRW; } } ...
huawei vpn, sslvpn, secoclient in archlinux, 华为SSLVPN客户端 下载安装包 http://www.corem.com.cn/index.php/service/tools/secoclient 官方只提供了ubuntu版本,用以下方式可以在 archlinux 上使用。 sudo -i # seco client 依赖 ubuntu 的 arch 命令, 模拟 arch 命令返回 x86_64 echo "echo x86_64" > /usr/bin/arch chmod u+x /usr/bin/arch # install seco client ./secoclient-linux-64-6.0.2.run # 启动后台服务 cd /usr/local/SecoClient/promote ./SecoClientPromoteService -d # 启动secoclient UI cd /usr/local/SecoClient/ ./SecoClient 启动脚本 把 server_address 替换成服务端IP #!/bin/bash sudo ip route del <server_address> count=`ps -ef |grep SecoClientPromoteService |grep -v "grep" |wc -l` echo $count if [ 0 == $count ];then cd /usr/local/SecoClient/promote sudo ./SecoClientPromoteService -d fi count=`ps -ef |grep SecoClient |grep -v "grep" |wc -l` echo $count if [ 1 == $count ];then cd /usr/local/SecoClient/ sudo ./SecoClient fi crostini # in crostini export WAYLAND_DISPLAY=wayland-0 # user id 使用非0数字(非root的已有用户id,如1000,填0 时,secoclient无法启动) export XDG_RUNTIME_DIR=/run/user/<user id> /opt/google/cros-containers/bin/sommelier -X ./SecoClient
linux 挂载 windows共享 先在 Windows 下面共享需要挂载的目录 sudo mount -t cifs -o username=<username>,password=<password> //192.168.50.104/path/to/win/share /mnt/path/to/linux/mnt/dir # windows域控账户不需要加前缀,直接写用户名 # 查看挂载状态 df -h # 卸载 umount /mnt/path/to/linux/mnt/dir https://blog.csdn.net/tojohnonly/article/details/71374984