Skip to content

Instantly share code, notes, and snippets.

@mywaiting
mywaiting / graceful_shutdown_tornado_web_server.py
Last active May 7, 2022 08:30
The example to how to shutdown tornado web server gracefully...
#!/usr/bin/env python
"""
How to use it:
1. Just `kill -2 PROCESS_ID` or `kill -15 PROCESS_ID` , The Tornado Web Server Will shutdown after process all the request.
2. When you run it behind Nginx, it can graceful reboot your production server.
3. Nice Print in http://weibo.com/1682780325/zgkb7g8k7
"""
@glenfant
glenfant / logging_yaml_config.py
Last active November 11, 2021 14:08
A example of logging medium complex configuration using YAML on Python 2.7 or 3.2
# -*- coding: utf-8
"""\
A simple demo of logging configuration with YAML (Python 2.7)
=============================================================
Requires PyYAML -> "easy_install PyYAML"
See the recipes for configuring logging with dicts and YAML
- http://docs.python.org/2.7/howto/logging-cookbook.html
- http://stackoverflow.com/questions/10519392/python2-7-logging-configuration-with-yaml
@jboner
jboner / latency.txt
Last active May 3, 2024 15:17
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@bootandy
bootandy / mongodb
Last active October 1, 2015 05:58
monogo notes
cheat sheet:
http://cheat.errtheblog.com/s/mongo
for more on update see:
http://www.mongodb.org/display/DOCS/Updating#Updating-update%28%29
======================== DEV ==============================
---search by date:
db.houses.find({"dateadded": { "$gt" : ISODate("2013-01-01")} } )
-- Get by subdocument key field: