Skip to content

Instantly share code, notes, and snippets.

@greenarrow
greenarrow / sigpipe.py
Created February 13, 2015 12:30
How to make Python play nicely with pipes
import sys
import errno
def main():
for i in range(20):
print i
if __name__ == "__main__":
# ensure buffer is flushed before we handle SIGPIPE
try:
#!/usr/bin/env python
# LGPLv2 yadda yadda yadda, do whatever, yadda yadda yadda, bum it in the gob, yadda yadda yadda
import bluetooth, datetime, optparse, time, os, user, pynotify, tempfile, twitter, sys
# Install required packages on Ubuntu:
# sudo aptitude install python-twitter python-notify python-bluetooth festival
# Set these values if you wish to use Twitter (you probably won't, but then I didn't really want too but it happended anyway)
r"""Simple module for quick document manipulation from the gedit Python console
Example:
import doc
d = doc.Doc(window)
d.set_lines( ['one', 'two', 'three'] )
d.append('\n')
d.append('four')
lines = d.get_lines()
lines.reverse()
#!/usr/bin/env python
import os, re, time, pexpect
print dir(pexpect)
class CaptureError(Exception):
pass
class WebCapture():
def __init__(self, filename, url, title):
self.filename = filename
@greenarrow
greenarrow / cleanthumb.py
Created October 29, 2010 08:50
Delete Gnome thumbnails for a list of given locations
#!/usr/bin/env python
__doc__ = """
Deletes Gnome thumbnails for a given list of directories.
Very much helped by http://software.maexotic.de/python/cleanthumbs/
"""
import os, optparse, Image, urllib
@greenarrow
greenarrow / scuddle.py
Created October 7, 2011 15:51
Scuddle
#!/usr/bin/env python
"""
Pass in SoundCloud page URLs as arguments and all MP3s will be downloaded into the current directory.
This is a demonstration only and you should almost definitely not use it.
"""
import urllib
import re
@greenarrow
greenarrow / fetch.py
Created December 2, 2011 17:55
Auto slice favourites from thingiverse
#!/usr/bin/env python
import urllib
import re
import os
BASE = "http://www.thingiverse.com"
USER = "greenarrow"
# Find all things on a page
@greenarrow
greenarrow / gsync
Created September 28, 2012 16:39
gsync
#!/bin/bash
set -e
METADIR=".gsync"
ARCHIVE=false
OLDHEAD=""
@greenarrow
greenarrow / plasticdb.py
Created March 18, 2013 21:14
plasticdb - Simple tool for 3D printer filament calibration For the best 3D printing results the "steps per e" should be calibrated for each different filament. Plasticdb makes that an easier task. Works best with matterQ (http://matterq.org).
#!/usr/bin/env python
import os
import sys
import subprocess
import tempfile
import shutil
# The file that stores all the data
@greenarrow
greenarrow / gerber_lib.py
Created May 22, 2013 21:31
Incomplete gerber to OpenSCAD (PCB)
"""
GNU licence:
RepRap Gerber Plotter is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
RepRap Gerber Plotter is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. You should have received a copy of
the GNU General Public License along with File Hunter; if not, write to