Skip to content

Instantly share code, notes, and snippets.

@jhermann
jhermann / babun-install.rst
Last active August 2, 2018 17:56
Babun install

Babun Setup for Python Developers

Babun is “A Windows shell you will love!”

It's a turn-key CygWin distribution for developers and is very easy to install and maintain. For a Python developer, Babun allows working in an almost-POSIX environment – with some limitation, of course. This causes less friction when handling FOSS projects that are often biased towards a standard Linux environment, e.g. by using shell scripts for boot-strapping and things like that.

@shymonk
shymonk / customize-save-in-django-admin-inline-form.org
Last active April 14, 2024 02:55
How to customize save in django admin inline form?

Customize Save In Django Admin Inline Form

Background

This is a common case in django ORM.

from django.db import models

class Author(models.Model):
@flisky
flisky / asyncio intro.md
Last active August 6, 2020 03:56
Introduce to AsyncIO

AsyncIO

Prerequisite

Overviews

PEP: 3165
python module name: asyncio, new in Python 3.4
reference implementation: tulip
backport: trollius ( python >= 2.6)

import asyncio
END = b'Bye-bye!\n'
@asyncio.coroutine
def echo_client():
reader, writer = yield from asyncio.open_connection('localhost', 8000)
writer.write(b'Hello, world\n')
writer.write(b'What a fine day it is.\n')
writer.write(END)
@dbehnke
dbehnke / client.py
Created March 18, 2014 19:08
Python AsyncIO Client and Server Example using StreamReader and StreamWriter
"""
client.py - AsyncIO Server using StreamReader and StreamWriter
This will create 200 client connections to a server running server.py
It will handshake and run similar to this:
Server: HELLO
Client: WORLD
@flisky
flisky / goroutine by example
Created November 5, 2013 03:25
Goroutine By Example
Goroutine By Example
====================
尹吉峰 2013/11/05
Python Thread
-------------
```python
import time
import threading
@anandkunal
anandkunal / simple_reverse_proxy.go
Created September 4, 2012 21:12
Simple reverse proxy in Go.
package main
import (
"log"
"net/http"
"net/http/httputil"
"net/url"
)
func main() {
@scttnlsn
scttnlsn / README.md
Created July 30, 2012 22:16
Pub/sub with MongoDB and Node.js

Pub/sub with MongoDB and Node.js

Setup:

$ mongo
> use pubsub
> db.createCollection('messages', { capped: true, size: 100000 })
> db.messages.insert({})
@wayhome
wayhome / tornado_patch.py
Created August 5, 2011 05:00
profile patch for tornado
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Monkey Patch for tornado
"""
import cProfile as profile
from tornado.options import options
from tornado.web import HTTPError
@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(