Skip to content

Instantly share code, notes, and snippets.

@wolph
wolph / colortest.py
Last active March 30, 2024 02:44
Testing 256 color shells using background colors and automatic shell width detection
#!/usr/bin/env python
from __future__ import print_function
import os
import shutil
import subprocess
def get_width(default=80):
'''Attempt to detect console width and default to 80'''
@boyxuper
boyxuper / h2_tornado.py
Last active August 14, 2016 14:55
WIP: hyper-h2 + tornado 4.1
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import io
import ssl
import sys
import copy
import base64
import socket
import httplib
@drAlberT
drAlberT / CS_git-commands-reference.md
Last active December 16, 2017 15:55
Git / GitHub CheatSheet

Git / GitHub CheatSheet

Quick reference for git / GitHub daily workflow

Git

create branches

  • create the local branch
@jayswan
jayswan / gist:a8d9920ef74516a02fe1
Last active March 11, 2022 15:33
Elasticsearch Python bulk index API example
>>> import itertools
>>> import string
>>> from elasticsearch import Elasticsearch,helpers
es = Elasticsearch()
>>> # k is a generator expression that produces
... # a series of dictionaries containing test data.
... # The test data are just letter permutations
... # created with itertools.permutations.
... #
... # We then reference k as the iterator that's
@bdarnell
bdarnell / gist:8553378
Created January 22, 2014 04:12
Example for StaticFileHandler.get_absolute_path
# For http://stackoverflow.com/questions/21248222/how-can-tornado-serve-a-single-static-file-at-an-arbitrary-location/21248691?noredirect=1#comment32053685_21248691
class MyFileHandler(StaticFileHandler):
def initialize(self, file_mapping, **kwargs):
self.file_mapping = file_mapping
super(MyFileHandler, self).initialize(**kwargs)
@classmethod
def get_absolute_path(cls, root, path):
return StaticFileHandler.get_absolute_path(root, self.file_mapping.get(path, path))
@toolness
toolness / gencert.py
Last active June 22, 2023 11:52
Python script to create server SSL certs and sign them with a custom CA.
#! /usr/bin/python
"""
This simple script makes it easy to create server certificates
that are signed by your own Certificate Authority.
Mostly, this script just automates the workflow explained
in http://www.tc.umn.edu/~brams006/selfsign.html.
Before using this script, you'll need to create a private
@Arthraim
Arthraim / bottle_example.py
Created May 27, 2011 04:27
a python web framework bottle's example
#coding: utf-8
from bottle import route, error, post, get, run, static_file, abort, redirect, response, request, template
@route('/')
@route('/index.html')
def index():
return '<a href="/hello">Go to Hello World page</a>'
@route('/hello')
def hello():
@rctay
rctay / .gitmodules
Created December 24, 2010 07:12
tornado: chunked handler (RFC2616)
[submodule "iostream_callback"]
path = iostream_callback
url = git://gist.github.com/753987.git