Skip to content

Instantly share code, notes, and snippets.

@ysegorov
ysegorov / app.py
Last active March 30, 2017 12:42
Logger server using edge-triggered epoll
# -*- coding: utf-8 -*-
import os
import errno
import itertools
import socket
import select
import logging
import logging.config
import pickle
@ysegorov
ysegorov / debug.py
Created January 18, 2016 04:04
Django debug helpers
# -*- coding: utf-8 -*-
import functools
import logging
import time
from django.conf import settings
from django.db import connection
@ysegorov
ysegorov / sub.py
Last active March 19, 2019 14:02 — forked from JobsDong/sub.py
tornado's Subprocess class usage example
#!/usr/bin/python2.7
#-*- coding=utf-8 -*-
import shlex
import subprocess
from tornado.gen import coroutine, Task, Return
from tornado.process import Subprocess
from tornado.ioloop import IOLoop
// HTML:
<div class="display-type"></div>
// CSS:
// set the content of an element depending on the media query
@staltz
staltz / introrx.md
Last active July 6, 2024 17:07
The introduction to Reactive Programming you've been missing
@adewes
adewes / redis_lock.py
Last active December 20, 2015 08:49
A Redis-based distributed lock class, based on the solution proposed by Chris Lamb (https://chris-lamb.co.uk/posts/distributing-locking-python-and-redis).
import redis
import time
class LockTimeout(BaseException):
pass
class Lock(object):
"""
Implements a distributed lock using Redis.
@gnarf
gnarf / ..git-pr.md
Last active April 12, 2024 22:00
git pr - Global .gitconfig aliases for Pull Request Managment

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from remotes:

  • git pr 4 - creates local branch pr/4 from the github upstream(if it exists) or origin remote and checks it out
  • git pr 4 someremote - creates local branch pr/4 from someremote remote and checks it out
@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
@FSX
FSX / async_psycopg2.py
Created March 8, 2011 22:11
A module for asynchronous PostgreSQL queries in Tornado.
#!/usr/bin/env python
__author__ = 'Frank Smit <frank@61924.nl>'
__version__ = '0.1.0'
import functools
import psycopg2
from tornado.ioloop import IOLoop, PeriodicCallback
# Copyright (c) 2010, Philip Plante of EndlessPaths.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in