Skip to content

Instantly share code, notes, and snippets.

View taoyuan's full-sized avatar
:octocat:
I may be slow to respond.

TY taoyuan

:octocat:
I may be slow to respond.
View GitHub Profile
@taoyuan
taoyuan / install-nodejs.sh
Created December 25, 2017 12:47 — forked from TooTallNate/install-nodejs.sh
Simple Node.js installation script using the precompiled binary tarballs
#!/bin/sh
VERSION=0.8.6
PLATFORM=darwin
ARCH=x64
PREFIX="$HOME/node-v$VERSION-$PLATFORM-$ARCH"
mkdir -p "$PREFIX" && \
curl http://nodejs.org/dist/v$VERSION/node-v$VERSION-$PLATFORM-$ARCH.tar.gz \
| tar xzvf - --strip-components=1 -C "$PREFIX"
@taoyuan
taoyuan / WxTransport.js
Last active June 24, 2018 16:02
微信小程序蓝牙 Roal 适配器
class WxTransport extends roal.Transport {
constructor(options) {
super();
this._buf = [];
this._serviceUUID = options.serviceUUID;
this._characteristicUUID = options.characteristicUUID;
this._deviceId = null; // 扫描连接后,更新此字段
this.ready = this.setup();
}
setup() {
pushd /opt
sudo bash -c "wget https://github.com/sarfata/pi-blaster/archive/master.zip -O pi-blaster.zip"
sudo unzip pi-blaster.zip
if [ -d pi-blaster ]; then
sudo rm -fr pi-blaster
fi
sudo mv pi-blaster-master pi-blaster
cd pi-blaster
sudo ./autogen.sh
@taoyuan
taoyuan / Makefile
Created October 28, 2018 15:47
Pack the nodejs application using `pkg`
# Pack the nodejs application using `pkg` (https://github.com/zeit/pkg)
# dependencies: rimraf, cpx and pkg
# > npm i rimraf cpx pkg -D
.PHONY: init clean build
OS := $(shell uname)
ARCH := $(shell uname -p)
all: dist
@taoyuan
taoyuan / dumplib.sh
Created November 4, 2019 14:58
View the list of functions a Linux shared library is exporting
# On a MAC, use:
nm *.o | c++filt
@taoyuan
taoyuan / privoxy_socks5_http_proxy.md
Last active November 28, 2019 02:03 — forked from alexniver/golang, ubuntu go get in china.md
ubuntu下, 使用 Privoxy 转换 socks5 到 http_proxy

#解决方案 Socks5 + Privoxy

思路就是, 建立一个本地sock5代理, 但因为go get 需要http代理, 所以需要使用privoxy把sock5代理转为http代理.

shadowsock

sudo apt-get install python-pip
@taoyuan
taoyuan / rand.c
Created February 10, 2020 06:11
A linear congruential random generator
static uint32_t seed = 0;
static void srand32(uint32_t s) {
seed = s;
}
static uint32_t rand32(void) {
seed = (uint32_t)(((uint64_t)1664525 * seed) + 1013904223);
@taoyuan
taoyuan / git_config_proxy.sh
Last active March 13, 2020 12:25
git config proxy set and unset
# http proxy
git config --global https.proxy http://127.0.0.1:1088
git config --global https.proxy http://127.0.0.1:1088
# socks5 proxy
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
# unset proxy
git config --global --unset http.proxy
@taoyuan
taoyuan / Clone-All-Repos-GitHub-Organization.md
Created June 24, 2020 06:03 — forked from nucliweb/Clone-All-Repos-GitHub-Organization.md
Clone all repos from a GitHub organization

Publics repos

With Ruby 1.8 (default version on MacOS) :

sudo gem install json
curl -s https://api.github.com/orgs/[ORGANIZATION]/repos | ruby -rubygems -e 'require “json”; JSON.load(STDIN.read).each {|repo| %x[git clone #{repo["ssh_url"]} ]}'

With Ruby 1.9+, the json library is by default thus you just use :

@taoyuan
taoyuan / generate_self_signed_certification.md
Last active June 6, 2024 20:38
Generation of a Self Signed Certificate

Generation of a Self Signed Certificate

Generation of a self-signed SSL certificate involves a simple 3-step procedure:

STEP 1: Create the server private key

openssl genrsa -out cert.key 2048

STEP 2: Create the certificate signing request (CSR)

openssl req -new -key cert.key -out cert.csr