Skip to content

Instantly share code, notes, and snippets.

View shvechikov's full-sized avatar

Leonid Shvechikov shvechikov

View GitHub Profile
@koblas
koblas / smtp.py
Created November 11, 2011 15:23
SMTP Client for Tornado
from tornado import ioloop
from tornado import iostream
import socket
class Envelope(object):
def __init__(self, sender, rcpt, body, callback):
self.sender = sender
self.rcpt = rcpt[:]
self.body = body
self.callback = callback
@astanin
astanin / fmtcsv.py
Created March 27, 2012 11:43
Pretty-print CSV file with fixed width columns.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Usage: %prog [width [columns]] < table.csv
Pretty-print CSV file with fixed width columns.
Arguments:
@shvechikov
shvechikov / fmtcsv.py
Created March 27, 2012 12:06 — forked from astanin/fmtcsv.py
Pretty-print CSV file with fixed width columns.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Usage: %prog [width [columns]] < table.csv
Pretty-print CSV file with fixed width columns.
Arguments:
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active November 17, 2024 13:10
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@archeg
archeg / gist:5652752
Created May 26, 2013 13:14
Example of working with notes on Google Spreadsheet
__author__ = 'archeg'
import httplib
import urllib
import urllib2
import re
def URLRequest(url, params, headers, method="GET"):
if method == "POST":
@witsch
witsch / net.devpi.devpi-server.plist
Created August 17, 2013 13:28
run `devpi-server` (http://devpi.net/) using `launchd` on OSX
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.devpi.devpi-server</string>
<key>ProgramArguments</key>
<array>
@jbenet
jbenet / simple-git-branching-model.md
Last active November 9, 2024 04:55
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@ei-grad
ei-grad / local.py
Last active August 29, 2015 14:02
def my_local(init):
key = object()
def getter():
t = _app_ctx_stack.top
l = getattr(t, 'my_locals')
if l is None:
t.my_locals = l = {}
if key not in l:
l[key] = init()
return l[key]
@wolever
wolever / gevent-in-production.rst
Last active July 10, 2018 21:03
Point-form notes about using gevent in production
  • I've been using gevent in production for about 6 years, and I've only encountered a handful of issues:
    • In gevent pre-1.0 there were issues with the DNS resolver
    • I've had a couple of issues with gevent-openssl, which I've fixed by using a custom version: mjs/gevent_openssl#14 and mjs/gevent_openssl#12
    • Celery hangs when gevent is monkeypatched. I haven't figured out why, and this might have been fixed in newer versions of celery (the one I'm using is fairly old).
  • All of my experience using gevent is in fully monkeypatched mode. It's certainky possible to use outside of monkeypatch mode, but I don't know anything about that.
  • See the monkeypatches.py and gevent_.py files for my implementation of monkeypatching.
  • The gevent_.py file contains a couple things: