Skip to content

Instantly share code, notes, and snippets.

View henryleu's full-sized avatar
🎯
Focusing

Henry Leu henryleu

🎯
Focusing
View GitHub Profile
@henryleu
henryleu / gist:0838ff1848de560f02c90c115b0987cf
Created October 27, 2021 04:00 — forked from dmitshur/gist:6927554
[Legacy GOPATH mode] How to `go get` private repos using SSH key auth instead of password auth.

WARNING: This gist was created in 2013 and targets the legacy GOPATH mode. If you're reading this in 2021 or later, you're likely better served by reading https://tip.golang.org/cmd/go/#hdr-Configuration_for_downloading_non_public_code and https://golang.org/ref/mod#private-modules.

$ ssh -A vm
$ git config --global url."[email protected]:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "[email protected]:"]
	insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!
@henryleu
henryleu / update-golang.md
Created October 26, 2021 07:48 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@henryleu
henryleu / ubuntu-16-increase-maximum-file-open-limit-ulimit-n.md
Created July 8, 2021 07:01 — forked from ntamvl/ubuntu-16-increase-maximum-file-open-limit-ulimit-n.md
Ubuntu 16 – how to increase maximum file open limit ( ulimit -n )

Ubuntu 16 – how to increase maximum file open limit ( ulimit -n )

If you are setting up nginx,chances are you will discover your worker_connections is at some low number, such as 1024. You can’t increase this number unless you increase kernel limit as well. First of all run cat /proc/sys/fs/file-max to discover your maximum limit.

abc@ubuntu:~$ cat /proc/sys/fs/file-max
1048576
abc@ubuntu:~$ ulimit -n
1024
@henryleu
henryleu / ip.js
Created March 13, 2021 13:34 — forked from szalishchuk/ip.js
Get local external ip address with nodejs
var
// Local ip address that we're trying to calculate
address
// Provides a few basic operating-system related utility functions (built-in)
,os = require('os')
// Network interfaces
,ifaces = os.networkInterfaces();
// Iterate over interfaces ...
@henryleu
henryleu / npm.taobao.sh
Created November 12, 2020 05:15 — forked from 2Loong6/npm.taobao.sh
设置 npm 和 yarn 的镜像源为淘宝镜像源
# ==========================================================
# NPM
# ==========================================================
npm set registry https://r.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass # node-sass 二进制包镜像
npm set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron 二进制包镜像
@henryleu
henryleu / client.go
Created September 1, 2020 02:52 — forked from xjdrew/client.go
golang tls client and server, require and verify certificate in double direction
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io"
"io/ioutil"
"log"
"os"
@henryleu
henryleu / parse_yaml.sh
Created August 12, 2020 04:08 — forked from pkuczynski/LICENSE
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@henryleu
henryleu / installGO.sh
Created August 5, 2020 13:18 — forked from RaviTezu/installGO.sh
Shell(bash) script to install golang on Linux and MacOS machines
#!/usr/bin/env bash
set -e
# Author: Ravi Teja Pothana (@RaviTezu)
# Date: Nov 15, 2016
# The MIT License (MIT)
# Copyright (c) 2016 RaviTezu
@henryleu
henryleu / dnsovertls.md
Created December 21, 2019 03:21 — forked from uraimo/dnsovertls.md
Configure your Mac to use DNS over TLS
@henryleu
henryleu / homebrew-mirror-in-china.sh
Created December 21, 2019 03:01 — forked from shrekuu/homebrew-mirror-in-china.sh
homebrew 中国镜像服务, 清华大学与中科大
# 清华大学:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 手动修改 bottles 地址:
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
# 或: