Skip to content

Instantly share code, notes, and snippets.

View knwng's full-sized avatar
🐱

Kyle Wang knwng

🐱
  • Mountain View, CA
  • 06:35 (UTC -07:00)
View GitHub Profile
@tsabat
tsabat / supervisor.conf
Created December 28, 2011 15:09
Sample supervisor config file
; Sample supervisor config file.
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
;[inet_http_server] ; inet (TCP) server disabled by default
@sandervm
sandervm / commandline.txt
Last active March 5, 2025 14:49
Generate Django secret key commandline
$ python -c 'import random; print "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])'
@hynek
hynek / gunicorn_callbacks_for_worker_id.py
Last active October 24, 2024 13:27
This is an attempt to emulate uWSGI’s uwsgi.worker_id() that ensures that I have worker IDs from 1…--workers which is useful in logging and instrumentation where changing PIDs are annoying.
import os
def on_starting(server):
"""
Attach a set of IDs that can be temporarily re-used.
Used on reloads when each worker exists twice.
"""
server._worker_id_overload = set()
@batzner
batzner / tensorflow_rename_variables.py
Last active May 25, 2023 06:15
Small python script to rename variables in a TensorFlow checkpoint
import sys, getopt
import tensorflow as tf
usage_str = 'python tensorflow_rename_variables.py --checkpoint_dir=path/to/dir/ ' \
'--replace_from=substr --replace_to=substr --add_prefix=abc --dry_run'
def rename(checkpoint_dir, replace_from, replace_to, add_prefix, dry_run):
checkpoint = tf.train.get_checkpoint_state(checkpoint_dir)
@monkut
monkut / Ubuntu1604py36Dockerfile
Last active June 14, 2023 20:31
Base Docker image for ubuntu-16.04 & Python3.6
# docker build -t ubuntu1604py36
FROM ubuntu:16.04
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:jonathonf/python-3.6
RUN apt-get update
RUN apt-get install -y build-essential python3.6 python3.6-dev python3-pip python3.6-venv
RUN apt-get install -y git
@fotock
fotock / nginx.conf
Last active February 3, 2025 15:03 — forked from plentz/nginx.conf
Nginx SSL 安全配置最佳实践.
# 生成 dhparam.pem 文件, 在命令行执行任一方法:
# 方法1: 很慢
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
# 方法2: 较快
# 与方法1无明显区别. 2048位也足够用, 4096更强
openssl dhparam -dsaparam -out /etc/nginx/ssl/dhparam.pem 4096
@cymruu
cymruu / main.go
Created June 26, 2018 12:06
Golang raw RSA encryption (no padding) RSA_NO_PADDING
package main
import (
"crypto/rsa"
"fmt"
"math/big"
)
var RSA_PublicKeyString string = "109120132967399429278860960508995541528237502902798129123468757937266291492576446330739696001110603907230888610072655818825358503429057592827629436413108566029093628212635953836686562675849720620786279431090218017681061521755056710823876476444260558147179707119674283982419152118103759076030616683978566631413"
var Public_RSA_Key = rsa.PublicKey{
N: fromBase10(RSA_PublicKeyString),
@knwng
knwng / .tmux.conf
Last active February 2, 2025 02:08
my tmux configuration
# remap prefix key from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# increase history limit
set-option -g history-limit 30000
# close auto rename
set -wg allow-rename off
@knwng
knwng / .vimrc
Last active September 27, 2024 22:18
无插件版本vimrc
set laststatus=2
set number "设置行号
set hlsearch "高亮搜索
set incsearch "增量搜索,即每次输入新字符都会触发搜索
set autoindent "自动缩进
set smartindent "智能缩进,基于autoindent
set tabstop=4 "设置一个tab占4个空格
set shiftwidth=4 "每层缩进4个空格
set expandtab "扩展tab为空格
set softtabstop=4 "使用退格键,每次将删除4个空格
@knwng
knwng / .vimrc
Last active September 25, 2024 18:59
无插件版本vimrc,无注释(vimrc without plugins and comments)
set laststatus=2
set number
set hlsearch
set incsearch
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
set softtabstop=4