Skip to content

Instantly share code, notes, and snippets.

@non-static
non-static / PythonEchoSrv.Dockerfile
Last active February 11, 2020 17:49
Python echo server based on tornado, including Dockerfile
FROM ubuntu:18.04
EXPOSE 8000
RUN apt-get update && apt-get install -y python3 python3-pip
RUN python3 -m pip install tornado
WORKDIR /srv
COPY main.py /srv
@non-static
non-static / status_code_analysis.lua
Last active November 4, 2023 07:56
Lua script for wrk2 to count response code and a particular header
wrk.method = "POST"
local f = io.open("data.json", "r")
wrk.body = f:read("*all")
wrk.headers["Content-Type"] = "application/json"
wrk.headers["Host"] = "foo.bar.net"
local counter = 1
local threads = {}
@non-static
non-static / pfx2pem.sh
Created January 31, 2020 17:56
Split cert and key from pfx file and write into two pem files.
#!/bin/bash
# Split out the key
openssl pkcs12 -in <my-cert-with-key.pfx> -nocerts -out gcs_encrypted.key -passin "pass:asdf1234"
openssl rsa -in gcs_encrypted.key -out gcs.key -passin "pass:asdf1234"
# Split out the cert
openssl pkcs12 -in <my-cert-with-key.pfx> -clcerts -nokeys -out gcs.cert
@non-static
non-static / MyCodeExtensions.txt
Last active January 11, 2020 23:07
Collection of handy VSCode Extensions: `cat ext.txt | xargs -n 1 code --install-extension`
adamhartford.vscode-base64
eamodio.gitlens
HookyQR.beautify
ms-python.python
ms-vscode.cpptools
WakaTime.vscode-wakatime
yzhang.markdown-all-in-one
BazelBuild.vscode-bazel
esbenp.prettier-vscode
ev3dev.ev3dev-browser
@non-static
non-static / u1804_setup.sh
Created December 11, 2019 22:27
New Ubuntu 18.04 Setup
#!/bin/bash
# apt update
sudo apt update
sudo apt list --upgradable
# Review and upgrade
sudo apt upgrade
# Add apt repository
@non-static
non-static / u1604_setup.sh
Last active December 7, 2019 06:17
New Ubuntu 16.04 Setup
#!/bin/bash
# apt update
sudo apt-get update
sudo apt-get list --upgradable
# Review and upgrade
sudo apt-get upgrade
# Add apt repository
@non-static
non-static / Dockerfile.load_test_tools
Created December 1, 2019 22:59
Dockerfile to create a docker image with load test tools embedded
FROM ubuntu:18.04 AS PREP
RUN apt-get update && apt-get install -y build-essential git libssl-dev libz-dev liblua5.1-0-dev wget
WORKDIR /code
RUN git clone https://github.com/giltene/wrk2
WORKDIR /code/wrk2
RUN make CFLAGS="-O3 -DNDEBUG -I/usr/include/lua5.1"
@non-static
non-static / run_temp_docker_image_with_kubectl.sh
Last active December 1, 2019 08:04
Run a temp docker image with kubectl
#!/bin/bash
# It is goint to create a new pod with all sidecars injected.
kubectl run [-n <namespace>] -i --rm --restart=Never busybox --image=odise/busybox-curl -- sh -c "curl -i -X POST -d 'body=parameters' 172.17.0.4:80/post"
# If run in Ubuntu server or WSL, need to install the following dependencies before run this scipt
# sudo apt install libxcursor1 libnss3 libxss1 libasound2 libatk1.0-0 libatk-bridge2.0-0 libgtk-3-0
import asyncio
from pyppeteer import launch
async def main():
browser = await launch()
page = await browser.newPage()
await page.goto('https://linuxize.com/post/how-to-install-python-3-7-on-ubuntu-18-04/')
@non-static
non-static / jieba_pyecharts_4_tianlongbabu.py
Last active November 21, 2019 05:38
Using pyecharts and jieba to display word cloud of Tian Long Ba Bu
from pyecharts import options as opts
from pyecharts.charts import Page, WordCloud
from pyecharts.globals import SymbolType
import jieba
with open('./tianlong.txt', 'r') as f:
txt = f.read()
seg_list = jieba.cut(txt, cut_all=True)