Skip to content

Instantly share code, notes, and snippets.

View guozi's full-sized avatar
🎯
Focusing

guozi_1989 guozi

🎯
Focusing
View GitHub Profile
@guozi
guozi / install-lrzsz.sh
Created September 18, 2020 14:41 — forked from zthxxx/install-lrzsz.sh
install-lrzsz on macOS
#!/usr/bin/env zsh
brew install lrzsz
recv='/usr/local/bin/iterm2-recv-zmodem.sh'
send='/usr/local/bin/iterm2-send-zmodem.sh'
curl -sSL https://github.com/zzy0-0/iterm2-zmodem/raw/master/iterm2-recv-zmodem.sh -o "$recv"
curl -sSL https://github.com/zzy0-0/iterm2-zmodem/raw/master/iterm2-send-zmodem.sh -o "$send"
chmod +x "$recv" "$send"
@guozi
guozi / HttpClientResult.java
Created August 5, 2020 07:57
HttpClient连接池工具类
public class HttpClientResult implements Serializable {
private static final long serialVersionUID = 1;
/**
* 响应状态码
*/
private int code;
/**
* 响应数据
@guozi
guozi / ParseToCsc.java
Created July 14, 2020 06:06
Parse .txt to .csv
public class ParseToCsc {
public static void main(String[] args) throws Exception {
final Path path = Paths.get("path", "to", "folder");
final Path txt = path.resolve("myFile.txt");
final Path csv = path.resolve("myFile.csv");
try (
final Stream<String> lines = Files.lines(txt);
final PrintWriter pw = new PrintWriter(Files.newBufferedWriter(csv, StandardOpenOption.CREATE_NEW))) {
lines.map((line) -> line.split("\\|")).
map((line) -> Stream.of(line).collect(Collectors.joining(","))).
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Paths;
@guozi
guozi / RSAUtils.java
Last active September 12, 2023 07:51
RSA加解密工具类
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.nio.charset.StandardCharsets;
@guozi
guozi / AesCbcWithIntegrity.java
Created May 16, 2019 08:22
AES加解密工具类
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
@guozi
guozi / demo1.java
Last active March 18, 2019 02:37
java 反射获得类的属性和父类的属性,属性值
try {
Class<?> clazz = param.getClass();
for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
int mod = field.getModifiers();
if (Modifier.isStatic(mod) || Modifier.isFinal(mod)) {
continue;
}
field.setAccessible(true);

摘译自 robots.thoughtbot.com

launchctl 命令加载,卸载开机自动运行的服务,在 OS X 中,服务本身存储在 .plist 文件中(即 property list),这些文件的位置一般在 ~/Library/LaunchAgents/Library/LaunchAgents。可以使用 launchctl load $PATH_TO_LISTunload them with launchctl unload $PATH_TO_LIST 命令来加载/卸载他们。加载就是允许这个程序开机执行,卸载反之。

如果你使用 Homebrew 安装过 mysql 那么下面的安装后提示你可能比较熟悉

To have launchd start mysql at login:
   ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
@guozi
guozi / brew-java-and-jenv.md
Created March 6, 2019 02:06 — forked from tomysmile/brew-java-and-jenv.md
How To Install Java 8 on Mac

Install HomeBrew first

brew update
brew tap caskroom/cask
brew install brew-cask

If you get the error "already installed", follow the instructions to unlink it, then install again:

/**
* Hystrix线程池隔离支持日志链路跟踪
*
* @author yuhao.wang3
*/
public class MdcHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy {
@Override
public <T> Callable<T> wrapCallable(Callable<T> callable) {
return new MdcAwareCallable(callable, MDC.getCopyOfContextMap());