Skip to content

Instantly share code, notes, and snippets.

@laixintao
laixintao / decent_request.py
Last active February 20, 2024 12:05
Send HTTP requests using python-requests with timeout, tcp reuse(session) and retry.
from requests.adapters import HTTPAdapter, Retry
from requests import Session
retries = Retry(
total=5, backoff_factor=1, status_forcelist=[502, 503, 504]
)
session = Session() # reuse tcp connection
session.mount("http://", HTTPAdapter(max_retries=retries))
session.mount("https://", HTTPAdapter(max_retries=retries))
@munificent
munificent / generate.c
Last active May 14, 2024 05:30
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@pamolloy
pamolloy / README.md
Last active May 12, 2024 04:17
Mesh network using VXLAN over Wireguard
@alchemyst
alchemyst / spreadsheet.py
Created December 18, 2017 13:41
Spreadsheet in 100 lines of Python
#!/usr/bin/env python
import tkinter as tk
import math
import re
from collections import ChainMap
Nrows = 5
Ncols = 5
@stevenringo
stevenringo / reinvent-2017-youtube.md
Created December 3, 2017 23:01
Links to YouTube recordings of AWS re:Invent 2017 sessions

| Title | Description

@pharzan
pharzan / server.py
Last active March 6, 2024 10:03
esp8266 post json data using usocket
#listens to the above run to
#FLASK_APP=server.py FLASK_DEBUG=1 python3.5 -m flask run -h 192.168.1.124 -p 8999:
#run this on the local server to listen to socket communication
from flask import Flask, render_template, jsonify
from flask import request as query
app = Flask(__name__)
@yegle
yegle / looping-over-tuple-vs-list.md
Last active July 11, 2019 08:29
Looping over tuple is slightly faster than looping over list

Looping over a tuple is faster than looping over a list in Python2

In Python2:

In [1]: def loop_list():    
   ...:     for i in [1, 2, 3]:                          
   ...:         pass        
   ...:                     

In [2]: def loop_tuple():   
@fotock
fotock / nginx.conf
Last active May 2, 2024 02:43 — 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
@Hengjie
Hengjie / tutorial.md
Last active June 26, 2024 04:41
How to passthrough SATA drives directly on VMWare ESXI 6.5 as RDMs

How to passthrough SATA drives directly on VMWare EXSI 6.5 as RDMs

There aren't many tutorials about this, the only tutorials I've found were about passing through entire PCIe cards to VMs, or refered to old ESXI versions (below 6.5) that used a more comprehensive desktop client instead of the web app. In v6.5, the web app was introduced and the desktop client was deprecated. You used to be able to setup RDMs in the desktop client, but with the introduction of the web console, this is no longer the case. This tutorial shows you how to pass SATA HDDs to the virtual machine on VMWare ESXI 6.5. This tutorial is partially based on VMWare's own KB and the now deprecated Forza IT blog post.

A word about VMWare ESXI 6.7

There is now an option while editing your VM's settings to add a New raw disk when you click `Add ha

@fcicq
fcicq / ngxstream_readpartial.patch
Last active June 7, 2016 01:43
partial read or recv for openresty stream-lua-nginx-module, receive('*p') introduced.
diff --git a/src/ngx_stream_lua_socket_tcp.c b/src/ngx_stream_lua_socket_tcp.c
index 4680811..4da1ac6 100644
--- a/src/ngx_stream_lua_socket_tcp.c
+++ b/src/ngx_stream_lua_socket_tcp.c
@@ -88,6 +88,7 @@ static int ngx_stream_lua_socket_write_error_retval_handler(
ngx_stream_session_t *s, ngx_stream_lua_socket_tcp_upstream_t *u,
lua_State *L);
static ngx_int_t ngx_stream_lua_socket_read_all(void *data, ssize_t bytes);
+static ngx_int_t ngx_stream_lua_socket_read_partial(void *data, ssize_t bytes);
static ngx_int_t ngx_stream_lua_socket_read_until(void *data, ssize_t bytes);