This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
''' | |
Drawing the same images to many windows using cairo | |
and zero mq. | |
Requirements: | |
pyzmq, gtk3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_aspect(width, height): | |
""" :return aspect ratio """ | |
return float(width) / float(height) | |
def get_ideal_size(width, height, ideal_aspect): | |
""" | |
:return the size of the largest rectangle with an aspect | |
ratio of 'ideal_aspect' that will fit into width x height. | |
""" | |
aspect = get_aspect(width, height) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import xlrd | |
from pprint import PrettyPrinter | |
def trim_nones(li): | |
""" remove trailing Nones from a list """ | |
while li and li[-1] is None: | |
li.pop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
import Queue | |
import threading | |
import collections | |
class Cursor(object): | |
def __init__(self, worksheet): | |
self.worksheet = worksheet | |
self.col = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "tmp" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeModelForm(forms.ModelForm): | |
def __init__(self, *args, **kwargs): | |
super(MessageModelForm, self).__init__(*args, **kwargs) | |
for f in self.fields.values(): | |
if isinstance(f.widget, widgets.CheckboxInput): | |
f.widget.attrs.update({'class': "checkbox inline"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Superceded by this: https://gist.github.com/stuaxo/9308767 | |
import Queue | |
import sys | |
import time | |
import select | |
import tty | |
import termios | |
from threading import Thread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Interuptible cmd.Cmd. | |
This is useful if you need a long running thread like a GUI event loop. | |
The trick is to run the cmd.Cmd shell in the main thread, and your main | |
loop in another background thread. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
random.seed(1) | |
size(550,450) | |
background(1,1,1) | |
colors=ximport("colors") | |
clr3 = colors.named_color("#DD7100") | |
clr4 = colors.named_color("yellowy") |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.