Skip to content

Instantly share code, notes, and snippets.

View smileboywtu's full-sized avatar
🌴
On vacation

wind smileboywtu

🌴
On vacation
View GitHub Profile
@toolness
toolness / adventures-in-python-core-dumping.md
Last active January 9, 2024 11:53
Adventures in Python Core Dumping

Adventures in Python Core Dumping

After watching Bryan Cantrill's presentation on [Running Aground: Debugging Docker in Production][aground] I got all excited (and strangely nostalgic) about the possibility of core-dumping server-side Python apps whenever they go awry. This would theoretically allow me to fully inspect the state of the program at the point it exploded, rather than relying solely on the information of a stack trace.

@jvmsangkal
jvmsangkal / connection-pool.py
Created October 21, 2015 03:36
Connection Pool PyMySQL
class ConnectionPool():
"""
Usage:
conn_pool = nmi_mysql.ConnectionPool(config)
db = conn_pool.get_connection()
db.query('SELECT 1', [])
conn_pool.return_connection(db)
conn_pool.close()
@JJediny
JJediny / gist:a466eed62cee30ad45e2
Created October 5, 2015 20:42
Jekyll Liquid Cheatsheet

There are two types of markup in Liquid: Output and Tag.

  • Output markup (which may resolve to text) is surrounded by
{{ matched pairs of curly brackets (ie, braces) }}
  • Tag markup (which cannot resolve to text) is surrounded by
@binderclip
binderclip / python-smtp-send-qq-mail.py
Last active February 16, 2023 14:59
Python & Email,附上用 Python 发送 QQ 邮箱邮件的代码
import smtplib
from getpass import getpass
def prompt(prompt):
return input(prompt).strip()
fromaddr = prompt("From: ")
toaddrs = prompt("To: ").split()
subject = prompt("Subject: ")
print("Enter message, end with ^D (Unix) or ^Z (Windows):")
@wen-long
wen-long / nali-update.sh
Last active November 18, 2019 03:44
QQWry.Dat is the ip database from http://www.cz88.net/ the website which offers the original code seems won't update any more and the download link refers to another obsolete website original script was from https://www.surfchen.org/nali but it was obsolete because the download link https://chenze.name/wenjian/QQWry.Dat offers an obsolete file a…
#!/bin/sh
qqwry_dat_url="http://update.cz88.net/soft/setup.zip";
qqwry_dat_local_path="/usr/local/share/QQWry.Dat"
curl=`which curl`
wget=`which wget`
workdir="/tmp/QQWry/"
zipname="QQWry.setup.zip"
@powerman
powerman / AsciidocCheatsheet.adoc
Last active March 22, 2024 19:18
Asciidoc cheatsheet for GitHub

Asciidoc cheatsheet for GitHub

@evi1m0
evi1m0 / PicConverText.py
Last active December 5, 2023 03:08
12306 新版验证码识别脚本 (已失效)
#!/usr/bin/env python
# coding=utf8
# author=evi1m0
# website=linux.im
'''
12306 Captcha Picture:
author: Evi1m0@20150316
1. Download Captcha
2. Pic Conver Text
@sphvn
sphvn / traverse.js
Last active October 26, 2023 21:49
Recursively traverse object javascript, recurse json js, loop and get key/value pair for JSON
var traverse = function(o, fn) {
for (var i in o) {
fn.apply(this,[i,o[i]]);
if (o[i] !== null && typeof(o[i])=="object") {
traverse(o[i], fn);
}
}
}
// usage
@mivade
mivade / tornadobg.py
Last active March 17, 2020 02:07
Background tasks with tornado and concurrent.futures
"""A simple demonstration of running background tasks with Tornado.
Here I am using a basic TCP server which handles streams and keeps
them open while asynchronously performing a fake task in the
background. In order to test it, simply telnet to localhost port 8080
and start typing things to see that the server receives the messages.
The advantage to running on an executor instead of conventional
threads is that we can more easily shut it down by stopping the
tornado IO loop.
@jewzaam
jewzaam / gist:5a9496f1ca2e5feb07bb
Last active April 1, 2019 08:27
MongoDB replica set in docker
# get it
docker pull mongo
# startup a 3 node replica set
docker run --name mongo-rs-1 -d mongo --nojournal --oplogSize 10 --replSet rs
docker run --name mongo-rs-2 -d mongo --nojournal --oplogSize 10 --replSet rs
docker run --name mongo-rs-3 -d mongo --nojournal --oplogSize 10 --replSet rs
# connect to first node
docker run -it --link mongo-rs-1:mongo1 --link mongo-rs-2:mongo2 --link mongo-rs-3:mongo3 --rm mongo /bin/bash