Skip to content

Instantly share code, notes, and snippets.


Vinay Sajip vsajip

View GitHub Profile
#!/usr/bin/env python3
import sys
import socket
import select
def command(name, args=None):
return {'name': name, 'args': args}
def readcmd():
from nonlocal_ import nonlocal_
def foo():
a = 1
def bar():
a = 2
return a
View xorg.conf
Section "Device"
Identifier "VNC Device"
Driver "vesa"
Section "Screen"
Identifier "VNC Screen"
Device "VNC Device"
Monitor "VNC Monitor"
SubSection "Display"
#!/usr/bin/env python
# Copyright 2001-2002 by Vinay Sajip. All Rights Reserved.
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of Vinay Sajip
# not be used in advertising or publicity pertaining to distribution
vsajip /
Last active Aug 29, 2015
Script to find blockers to Python 3 adoption across all of PyPI
from collections import Counter
import logging
from pprint import pprint
import sys
import caniusepython3
from caniusepython3.dependencies import blocking_dependencies
logger = logging.getLogger(__name__)
View vcvarsall.bat.patch
--- C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.txt
+++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
@@ -16,23 +16,23 @@
goto :eof
-if not exist "%~dp0bin\amd64\vcvarsamd64.bat" goto missing
-call "%~dp0bin\amd64\vcvarsamd64.bat"
+if not exist "%~dp0bin\vcvars64.bat" goto missing
+call "%~dp0bin\vcvars64.bat"
View logwriter
# Copyright 2009 Vinay Sajip
import logging
logger = logging.getLogger(__name__)
class LogWriter:
def __init__(self, logger):
self.logger = logger
import logging.handlers
import smtplib
class BufferingSMTPHandler(logging.handlers.BufferingHandler):
def __init__(self, mailhost, fromaddr, toaddrs, subject, capacity):
logging.handlers.BufferingHandler.__init__(self, capacity)
self.mailhost = mailhost
self.mailport = None
self.fromaddr = fromaddr
if isinstance(toaddrs, (str, unicode)):
# Copyright (C) 2009 Vinay Sajip.
# Licensed under the PSF licence.
# Exploratory code to convert %-format strings to {}-format.
import re
PATTERN = re.compile(r'''
% # specifier start
vsajip / index.html
Last active Sep 23, 2015
Example graph
View index.html
<!DOCTYPE html>
<title>Example graph</title>
<meta charset="utf-8">
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
width: 960px;
height: 500px;
position: relative;