Golang文件流下载,边下载边计算MD5
当时是为了测试文件网卡问题,发现同样的文件,在一个很烂的网卡中不断的下载,计算的文件MD5会不一样的问题。代码记录下,留作参考。
1 | package main |
当时是为了测试文件网卡问题,发现同样的文件,在一个很烂的网卡中不断的下载,计算的文件MD5会不一样的问题。代码记录下,留作参考。
1 | package main |
1 | package main |
新建文件:pm2.json
1 | { |
然后执行命令:pm2 start pm2.json
启动服务。
电脑上是使用nvm安装的node,安装之后每次打开一个新的terminal都比较慢,运营是因为termainl在打开的时候会加载nvm相关内容,如下:
1 | # nvm |
可以按照下面方式来修改,只有在需要用到nvm的时候才去加载:
1 | # nvm |
推荐一个工具:https://github.com/jenv/jenv
Follow the steps below to get a working jenv
installation with knowledge of your java
environment. Read all the code you execute carefully: a $
symbol at the beginning of a line should be omitted, since it’s meant to show you entering a command into your terminal and observing the response after the command.
jenv
On OSX, the simpler way to install jEnv is using Homebrew
1 | brew install jenv |
Alternatively, and on Linux, you can install it from source :
1 | git clone https://github.com/jenv/jenv.git ~/.jenv |
Restart your shell by closing and reopening your terminal window or running exec $SHELL -l
in the current session for the changes to take effect.
To verify jenv
was installed, run jenv doctor
. On a macOS machine, you’ll observe the following output:
1 | jenv doctor |
Observe that jenv
is correctly loaded but Java is not yet installed.
To make sure JAVA_HOME
is set, make sure to enable the export
plugin:
1 | jenv enable-plugin export |
Problem? Please visit the Trouble Shooting Wiki page.
Continue to the next section to install java.
Untested: While this fork has improved fish
shell support, it has not been tested by this maintainer. To install jenv
for Fish according to the contributor’s instructions:
1 | echo 'set PATH $HOME/.jenv/bin $PATH' >> ~/.config/fish/config.fish |
Use jenv add
to inform jenv
where your Java environment is located. jenv
does not, by itself, install Java.
For example, on macOS, use brew
to install the latest Java (OpenJDK 11) followed by the appropriate jenv add PATH_TO_JVM_HOME
command to recognize it.
1 | brew install --cask java |
With macOS OpenJDK 11.0.2 installed, for example, either of these commands will add /Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home
as a valid JVM. Your JVM directory may vary!
Observe now that this version of Java is added to your java versions
command:
1 | jenv versions |
By default, the latest version of Java is your system
Java on macOS.
We’ll now set a jenv local VERSION
local Java version for the current working directory. This will create a .java-version
file we can check into Git for our projects, and jenv
will load it correctly when a shell is started from this directory.
1 | jenv local 11.0.2 |
Is JAVA_HOME
set?
1 | echo ${JAVA_HOME} |
Yes! Observe that JAVA_HOME
is set to a valid shim directory. Unlike the main repository’s documentation we helpfully installed the export
plugin, and we now have the most important jenv
features covered.
If you executed this commands inside your $HOME
directory, you can now delete .java-version
:
1 | rm .java-version |
Use jenv global VERSION
to set a global Java version:
1 | jenv global 11.0.2 |
When you next open a shell or terminal window, this version of Java will be the default.
On macOS, this sets JAVA_HOME
for GUI applications on macOS using jenv macos-javahome
. Integrates this tutorial to create a file that does not update dynamically depending on what local or shell version of Java is set, only global.
Use jenv shell VERSION
to set the Java used in this particular shell session:
1 | jenv shell 11.0.2 |
These common workflows demonstrate how to use jenv
to solve common problems.
Our goal is to have both the latest version of Java and JDK 8 installed at the same time. This is helpful for developing Android applications, whose build tools are sensitive to using an exact Java version.
We’ll resume where we left off with Java 11.0.2 installed. Let’s install Java 8 now:
1 | brew install --cask adoptopenjdk8 |
This will install the latest version of Java 8 to a special directory in macOS. Let’s see which directory that is:
1 | ls -1 /Library/Java/JavaVirtualMachines |
Observe the adoptopenjdk-8.jdk
directory. Your exact version may vary. We cannot retrieve this using /usr/libexec/java_home
, unfortunately. We’ll add the Java home directory using jenv
so that it shows up in our jenv versions
command:
1 | jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/ |
场景:目录中有多个git项目,想要更新批量拉取一下这些项目的最新代码。
实现如下:
1 |
|
扫码目录下的所有项目,如果发现当前项目在master分支,那么pull一下代码。
偶然的机会需要用一下PHP,记录下安装方式。本身mac系统是自带php的,但是自带的修改起来及其不方便,不好安装扩展。所以直接使用brew安装。
1 | brew search php 使用此命令搜索可用的PHP版本 |
1 | pecl version 查看版本信息 |
本文主要介绍mac
环境下使用iterm2
的rz sz
功能的安装流程。
1 | brew install lrzsz |
将iterm2-send-zmodem.sh
和iterm2-recv-zmodem.sh
保存到/usr/local/bin
目录下。
1 | #!/bin/bash |
1 | #!/bin/bash |
1 | chmod 777 /usr/local/bin/iterm2-* |
设置Iterm2的Tirgger特性,profiles->default->editProfiles->Advanced中的Tirgger
添加两条trigger,分别设置 Regular expression,Action,Parameters,Instant如下:
1 | Regular expression: rz waiting to receive.\*\*B0100 |
示例图:
参考:
这应该是一个BUG,在终端执行以下命令可以恢复正常:
1 | killall ControlStrip |
1 | sudo killall -HUP mDNSResponder |
解决办法:https://www.mspring.org/2021/01/19/mac-iterm2-rz%E4%B8%8Esz%E7%9A%84%E5%8A%9F%E8%83%BD/