Skip to content

Instantly share code, notes, and snippets.

import os
import httplib
import tornado.web
class ErrorHandler(tornado.web.RequestHandler):
"""Generates an error response with status_code for all requests."""
def __init__(self, application, request, status_code):
tornado.web.RequestHandler.__init__(self, application, request)
self.set_status(status_code)
@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
"""
@zthomas
zthomas / intercom-delete-old-users.js
Last active May 1, 2023 15:28
Script to delete and clear old users from intercom. Useful for lowering the monthly bill
// License: MIT, feel free to use it!
const Intercom = require('intercom-client');
const appId = 'APP_ID'
const apiKey = 'APP_KEY'
const client = new Intercom.Client(appId, apiKey);
const async = require('async-q')
//REF: https://developers.intercom.com/reference#iterating-over-all-users
//WARNING: you can only have one scroll working at once. you need to wait for that scroll to clear to try again
@ivzhao
ivzhao / blah.js
Last active January 3, 2020 13:19
Get Intercom tags count from your browser
// Step 1. Turn on this Chrome plugin to disable Content Security Policy https://chrome.google.com/webstore/detail/disable-content-security/ieelmcmcagommplceebfedjlakkhpden?hl=en
// Step 2. Change your Intercom App Id below.
// Step 3. Go to your Intercom Tags page.
// Step 4. Copy/paste this script in your Chrome console, it will download a .csv file once it's completed.
// Step 5 (Optional) Sometimes you have to toggle the ORIGIN below between .io or .com.
// Your Intercom App Id
var INTERCOM_APP_ID = "REPLACE_WITH_YOUR_ID"
// Origin. Change between https://app.intercom.com or https://app.intercom.io
@toolness
toolness / docker-thoughts.md
Last active March 26, 2019 15:21
Reflections on Docker-based development

Reflections on Docker-based development

Note that these reflections are specifically tailored to a conversation about Docker we're having at 18F, and as such they have a few assumptions:

Advantages