Skip to content

Instantly share code, notes, and snippets.

@tomjamescn
tomjamescn / handle_http_response.php
Created July 6, 2018 08:50
使用php处理http响应_兼容chunked和压缩的响应
<?php
function http_unchunk($data) {
$res=[];
$p=0; $n=strlen($data);
while($p<$n) {
if (preg_match("/^([0-9A-Fa-f]+)\r\n/",substr($data,$p,18),$m)) {
$sz=hexdec($m[1]); $p+=strlen($m[0]);
$res[]=substr($data,$p,$sz); $p+=$sz+2;
} else {
@tomjamescn
tomjamescn / install-tmux.sh
Created June 21, 2019 06:04 — forked from pokev25/install-tmux.sh
Install tmux 2.8 on centos 7
# Install tmux 2.8 on Centos
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -LOk https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
tar -xf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable
./configure --prefix=/usr/local
@tomjamescn
tomjamescn / install_golang_org_x_quickly.sh
Last active July 15, 2019 06:24
国内快速安装golang.org/x下的包
#!/bin/bash
# 网络环境会导致直接安装失败,使用此脚本可以避免这个问题
if [ -z $GOPATH ];then
echo "GOPATH not exists!"
exit 1
fi
dir=$GOPATH/src/golang.org/x

Keybase proof

I hereby claim:

  • I am tomjamescn on github.
  • I am tomjamescn (https://keybase.io/tomjamescn) on keybase.
  • I have a public key ASCVXLKfU4pOGULqS3_JQChts4a1bnInoQ-qlshUWXaCvQo

To claim this, I am signing this object:

@tomjamescn
tomjamescn / rclone-install.sh
Last active February 21, 2020 14:04
rclone
#!/bin/bash
# debian/ubuntu
sudo apt install unzip fuse
curl https://rclone.org/install.sh | sudo bash
@tomjamescn
tomjamescn / custom_oh_my_zsh.sh
Created February 28, 2020 00:52
custom oh-my-zsh
#!/bin/bash
if [[ -z "$ZSH" ]]; then
echo "还未安装oh-my-zsh!"
exit 1
fi
os=`uname`
cp "$ZSH/themes/robbyrussell.zsh-theme" "$ZSH/custom/themes/robbyrussell.zsh-theme"
@tomjamescn
tomjamescn / init-server.sh
Created February 28, 2020 13:00
sudo init-server.sh
!#/bin/bash
apt update
apt install vim vim-nox git zsh
curl https://get.docker.com | bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
curl https://gist.githubusercontent.com/tomjamescn/ccdcda091650ff1d34b496e4eeba123f/raw/62166ff7e7d6d31f6d3964a69a131f1264d38a95/custom_oh_my_zsh.sh | bash
@tomjamescn
tomjamescn / letsencrypt_notes.sh
Created March 15, 2020 06:03 — forked from lachesis/letsencrypt_notes.sh
Set up LetsEncrypt using acme.sh without root
# How to use "acme.sh" to set up Lets Encrypt without root permissions
# See https://github.com/Neilpang/acme.sh for more
# This assumes that your website has a webroot at "/var/www/<domain>"
# I'll use the domain "EXAMPLE.com" as an example
# When this is done, there will be an "acme" user that handles issuing,
# updating, and installing certificates. This account will have the following
# (fairly minimal) permissions:
# - Host files at http://EXAMPLE.com/.well-known/acme-challenge
@tomjamescn
tomjamescn / init-vps-shell.sh
Last active March 23, 2020 06:53
sudo init-server.sh
!#/bin/bash
apt update
apt install vim vim-nox git zsh
curl https://get.docker.com | bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
curl https://gist.githubusercontent.com/tomjamescn/ccdcda091650ff1d34b496e4eeba123f/raw/62166ff7e7d6d31f6d3964a69a131f1264d38a95/custom_oh_my_zsh.sh | bash
@tomjamescn
tomjamescn / install-python3.8.sh
Created March 31, 2020 02:27
ubuntu/debian install python3.8
#!/bin/bash
set -e
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.8 python3-venv
# python3.8 -m venv myenv