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 / private_fork.md
Created July 27, 2022 02:31 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@guozi
guozi / HttpUtil.java
Created March 28, 2022 13:29 — forked from liujbo/HttpUtil.java
HTTP请求工具
package com.xilai.cuteBoy.common.util;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.AuthSchemes;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
@Bean
public HttpClient httpClient(SSLContext sslContext) {
return HttpClients.custom()
.setMaxConnPerRoute(30)
.setMaxConnTotal(60)
.setSSLContext(sslContext).build();
}
@Bean
public ClientHttpRequestFactory clientHttpRequestFactory(HttpClient httpClient) {
return new HttpComponentsClientHttpRequestFactory(httpClient);
@guozi
guozi / HexUtils.java
Created November 17, 2021 09:25 — forked from keepingcoding/HexUtils.java
进制转换工具类
public class HexUtils {
private HexUtils() {
}
/**
* 16进制转2进制
*
* @param str
* @return
@guozi
guozi / App.java
Created March 10, 2021 07:14 — forked from rponte/App.java
Downloading file using Apache HttpClient (>= v4.2) with support to HTTP REDIRECT 301 and 302 when using HTTP method GET or POST
public class App {
public static void main(String[] args) throws MalformedURLException {
URL rightUrl = new URL("http://cursos.triadworks.com.br/assets/css/main.css");
URL redirectableUrl = new URL("http://www.triadworks.com.br/assets/css/main.css"); // redirected to cursos.triadworks.com.br
Downloader downloader = new Downloader();
System.out.println("Downloading file through right Url...");
@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"

摘译自 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:

@guozi
guozi / IntelliJ_IDEA__Perf_Tuning.txt
Created December 14, 2018 09:08 — forked from P7h/IntelliJ_IDEA__Perf_Tuning.txt
Performance tuning parameters for IntelliJ IDEA. Add these params in idea64.exe.vmoptions or idea.exe.vmoptions file in IntelliJ IDEA. If you are using JDK 8.x, please knock off PermSize and MaxPermSize parameters from the tuning configuration.
-server
-Xms2048m
-Xmx2048m
-XX:NewSize=512m
-XX:MaxNewSize=512m
-XX:PermSize=512m
-XX:MaxPermSize=512m
-XX:+UseParNewGC
-XX:ParallelGCThreads=4
-XX:MaxTenuringThreshold=1

Best Practices for Azure Redis

Below are a set of best practices that I recommend for most customers. This information is based on my experience helping hundreds of Azure Redis customers investigate various issues.

Configuration and Concepts

  1. Use Standard or Premium Tier for Production systems. The Basic Tier is a single node system with no data replication and no SLA. Also, use at least a C1 cache. C0 caches are really meant for simple dev/test scenarios since they have a shared CPU core, very little memory, are prone to "noisy neighbor", etc.
  2. Remember that Redis is an In-Memory data store. Read this article so that you are aware of scenarios where data loss can occur.
  3. Configure your client library to use a "connect timeout" of at least 10 to 15 seconds, giving the system time to connect even under higher CPU conditions. If your client or server tend to be under high load