Skip to content

Instantly share code, notes, and snippets.

View flyhigher139's full-sized avatar
🖥️
working

Gevin flyhigher139

🖥️
working
View GitHub Profile
@flyhigher139
flyhigher139 / 2019-https-localhost.md
Created October 26, 2023 05:39 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@flyhigher139
flyhigher139 / red_black_tree.go
Created July 27, 2023 14:37
red_black_tree.go
type Node[K any, V any] struct {
Key K
Value V
Red bool
Left *Node[K, V]
Right *Node[K, V]
Parent *Node[K, V]
}
type RedBlackTree[K any, V any] struct {
@flyhigher139
flyhigher139 / demo.py
Created May 5, 2019 05:49
Get human readable file size
"""
https://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size
>>> sizeof_fmt(168963795964)
'157.4GiB'
"""
def sizeof_fmt(num, suffix='B'):
for unit in ['','Ki','Mi','Gi','Ti','Pi','Ei','Zi']:
if abs(num) < 1024.0:
@flyhigher139
flyhigher139 / proxy.conf
Last active May 31, 2021 08:20
NginX 反向代理example
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
add_header 'Access-Control-Allow-Origin' '*';
@flyhigher139
flyhigher139 / import_from_string.py
Created March 15, 2017 01:57 — forked from theskumar/import_from_string.py
Django: Attempt to import a class from a string representation.
def import_from_string(val):
"""
Attempt to import a class from a string representation.
From: https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/settings.py
"""
try:
# Nod to tastypie's use of importlib.
parts = val.split('.')
module_path, class_name = '.'.join(parts[:-1]), parts[-1]
@flyhigher139
flyhigher139 / setup-container.sh
Created November 29, 2016 13:45 — forked from katopz/setup-container.sh
For setup Docker container and use data volume for db.
#!/bin/bash
CONTAINER_INDEX=$1
CONTAINER_NAME="mongo"$1
DATA_VOLUME="mongo-data-volume"$1
mkdir $CONTAINER_NAME
DB_PORT=$((30000+$CONTAINER_INDEX))
HTTP_PORT=$((28017+$CONTAINER_INDEX))
NETWORK_NAME=$2
REPLICASET_NAME=$3
@flyhigher139
flyhigher139 / setup.sh
Created November 29, 2016 13:43 — forked from katopz/setup.sh
For setup 3 MongoDB replica set in Docker container and use data volume for db. will need https://gist.github.com/katopz/0f553b431302d9313ebfa7d48b53db89
## Setup Docker
NETWORK_NAME=${1:-my-mongo-cluster}
REPLICASET_NAME=${2:-my-mongo-set}
# Disconnect old container if has.
docker network disconnect -f $NETWORK_NAME mongo0
docker network disconnect -f $NETWORK_NAME mongo1
docker network disconnect -f $NETWORK_NAME mongo2
# Remove old network if has.
docker network rm $NETWORK_NAME
@flyhigher139
flyhigher139 / basic.py
Last active September 20, 2016 09:20
python log
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import logging
logging.debug('debug message')
logging.info('info message')
logging.warn('warn message')
logging.error('error message')
logging.critical('critical message')
@flyhigher139
flyhigher139 / bobp-python.md
Created November 13, 2015 01:00 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@flyhigher139
flyhigher139 / surge_main.conf
Created November 12, 2015 06:20 — forked from jason5ng32/surge.conf
Surge Configs ( Both 2 files are needed )
[General]
loglevel = notify
skip-proxy = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12,127.0.0.0/24,100.64.0.0/10
bypass-tun = 0.0.0.0/8, 1.0.0.0/9, 1.160.0.0/11, 1.192.0.0/11, 10.0.0.0/8, 14.0.0.0/11, 14.96.0.0/11, 14.128.0.0/11, 14.192.0.0/11, 27.0.0.0/10, 27.96.0.0/11, 27.128.0.0/9, 36.0.0.0/10, 36.96.0.0/11, 36.128.0.0/9, 39.0.0.0/11, 39.64.0.0/10, 39.128.0.0/10, 42.0.0.0/8, 43.224.0.0/11, 45.64.0.0/10, 47.64.0.0/10, 49.0.0.0/9, 49.128.0.0/11, 49.192.0.0/10, 54.192.0.0/11, 58.0.0.0/9, 58.128.0.0/11, 58.192.0.0/10, 59.32.0.0/11, 59.64.0.0/10, 59.128.0.0/9, 60.0.0.0/10, 60.160.0.0/11, 60.192.0.0/10, 61.0.0.0/10, 61.64.0.0/11, 61.128.0.0/10, 61.224.0.0/11, 100.64.0.0/10, 101.0.0.0/9, 101.128.0.0/11, 101.192.0.0/10, 103.0.0.0/10, 103.192.0.0/10, 106.0.0.0/9, 106.224.0.0/11, 110.0.0.0/7, 112.0.0.0/9, 112.128.0.0/11, 112.192.0.0/10, 113.0.0.0/9, 113.128.0.0/11, 113.192.0.0/10, 114.0.0.0/9, 114.128.0.0/11, 114.192.0.0/10, 115.0.0.0/8, 116.0.0.0/8, 117.0.0.0/9, 117.128.0.0/10, 118.0.0.0/11, 118.64.0.0/10, 118.128.0.0