Skip to content

Instantly share code, notes, and snippets.

View changsijay's full-sized avatar
🐧
I may be slow to respond.

Jay Chang changsijay

🐧
I may be slow to respond.
  • Taiwan
View GitHub Profile
@changsijay
changsijay / install.sh
Last active August 29, 2015 13:56
django-wiki
# official site: https://github.com/benjaoming/django-wiki
$ sudo apt-get install python-pip python-dev
# don't use `pip install wiki`, cuz has some bug. Using latest from git.
$ sudo pip install git+git://github.com/benjaoming/django-wiki.git
# check installed packages, where django-wiki is wiki (0.0.23)
$ pip list
argparse (1.2.1)
chardet (2.0.1)
Django (1.6.2)
django-classy-tags (0.4)
@changsijay
changsijay / mysql.go
Created March 27, 2014 08:19
golang mysql
package main
import (
"fmt"
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func main() {
fmt.Println("Connect to mysql now")
@changsijay
changsijay / remove.py
Last active July 24, 2018 17:08
remove unnecessary packages, only keep what I want
import subprocess
must_have = [
"linux46",
"systemd",
"acpid",
"xorg-server",
"xf86-video-ati",
"xf86-input-evdev",
@changsijay
changsijay / myexporter.py
Last active January 16, 2018 11:44
prometheus exporter
from prometheus_client import start_http_server, Metric, REGISTRY
class MyCollector(object):
def collect(self):
metric = Metric('current_devices', 'current device resource', 'gauge')
for someloop:
# it taks about 3 minutes to finish the loop
metric.add_sample('current_device_count', value=count, labels=labels)
yield metric
@changsijay
changsijay / server.py
Created March 18, 2018 11:48 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
@changsijay
changsijay / SimpleAuthServer.py
Created March 18, 2018 11:49 — forked from fxsjy/SimpleAuthServer.py
SimpleAuthServer: A SimpleHTTPServer with authentication
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import sys
import base64
key = ""
class AuthHandler(SimpleHTTPRequestHandler):
''' Main class to present webpages and authentication. '''
def do_HEAD(self):
@changsijay
changsijay / http_get.go
Created April 4, 2018 03:37 — forked from hidva/http_get.go
golang wget
package main
import (
"context"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"time"
@changsijay
changsijay / secret-key-gen.py
Created April 4, 2018 09:09 — forked from ndarville/secret-key-gen.py
Generating a properly secure SECRET_KEY in Django
"""
Two things are wrong with Django's default `SECRET_KEY` system:
1. It is not random but pseudo-random
2. It saves and displays the SECRET_KEY in `settings.py`
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`
@changsijay
changsijay / tmux-cheatsheet.markdown
Created July 24, 2018 05:04 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

tmux at [-t 会话名]
@changsijay
changsijay / pkgs.txt
Created September 30, 2018 09:47
choco_pkgs.txt
nodejs.install
yarn
python
dotnetcore-sdk
golang
jdk10
vscode
sublimetext3