Skip to content

Instantly share code, notes, and snippets.

Not affected by COVID-19

Lake Chan StoneMoe

Not affected by COVID-19
View GitHub Profile
StoneMoe /
Created Jan 30, 2021
Simple preforking echo server in Python
Simple preforking echo server in Python.
Python port of
import os
import sys
import socket
# Source
if [ -z $pkgname ]; then
echo "Usage: ./ pkgname-here"
exit 1
rand=$(openssl rand -base64 6)
StoneMoe /
Last active Jul 14, 2020
volume to volume
# make tarball from sentry_pgdb volume
docker run --rm -v sentry_pgdb:/var/lib/postgresql/data -v (pwd):/backup busybox tar cvf /backup/backup.tar /var/lib/postgresql/data
# create a sentry-postgres volum
docker volume create sentry-postgres
# restore to sentry-postgres volume
# NOTE: tarball will keep absolute path folder structure, so we don't need specify the target extract path
docker run --rm -v sentry-postgres:/var/lib/postgresql/data -v (pwd):/backup busybox tar xvf /backup/backup.tar
StoneMoe /
Created Dec 19, 2019 — forked from iAklis/
ICMP packet tracer using BCC
bpf_text = """
#include <linux/ptrace.h>
#include <linux/sched.h> /* For TASK_COMM_LEN */
#include <linux/icmp.h>
#include <linux/netdevice.h>
struct probe_icmp_data_t
u64 timestamp_ns;
u32 tgid;
StoneMoe / supervisor.conf
Created Sep 26, 2019 — forked from hezhao/supervisor.conf
Example supervisor config file /etc/supervisor/conf.d/myapp.conf
View supervisor.conf
autostart = true
autorestart = true
command = python /home/pi/
stdout_logfile = /home/pi/stdout.log
stderr_logfile = /home/pi/stderr.log
startretries = 3
user = pi
StoneMoe /
Created Sep 25, 2019 — forked from denji/
Simple Sentry docker-compose.yml
  1. Download docker-compose.yml to dir named sentry
  2. Change SENTRY_SECRET_KEY to random 32 char string
  3. Run docker-compose up -d
  4. Run docker-compose exec sentry sentry upgrade to setup database and create admin user
  5. (Optional) Run docker-compose exec sentry pip install sentry-slack if you want slack plugin, it can be done later
  6. Run docker-compose restart sentry
  7. Sentry is now running on public port 9000
StoneMoe /
Created Jan 8, 2019 — forked from andreyvit/
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

# remap prefix to Control + a
StoneMoe /
Created Mar 7, 2018
Monkey patch for eventlet wsgi environ string bug
def eventlet_patcher():
# Ref:
# Ref:
from eventlet.wsgi import HttpProtocol
def new_get_environ(self):
env = self.server.get_environ()
env['REQUEST_METHOD'] = self.command
env['SCRIPT_NAME'] = ''
StoneMoe /
Last active Jan 15, 2019
Monkey patch for Python-EngineIO JSONP-Polling support
# For Python-EngineIO 2.0.2
def engine_io_patcher():
from engineio.payload import Payload as eio_Payload
from engineio.server import Server as eio_Server
original_handle_request = eio_Server.handle_request
def new_eioserv__ok(self, packets=None, headers=None, b64=False, jsonp_seq=None):
"""response generator."""
if packets is not None:
if headers is None: