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:
@greenarrow
greenarrow / spherical_translate.scad
Last active December 23, 2015 15:59
OpenSCAD Spherical Translate
/* http://en.wikipedia.org/wiki/Spherical_coordinate_system */
module spherical_translate(value)
{
radius = value[0];
inclination = value[1];
azimuth = value[2];
x = radius * sin(inclination) * cos(azimuth);
y = radius * sin(inclination) * sin(azimuth);
@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
@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 / gsync
Created September 28, 2012 16:39
gsync
#!/bin/bash
set -e
METADIR=".gsync"
ARCHIVE=false
OLDHEAD=""
@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 / 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 / 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 / torrentcontrol
Created October 24, 2010 00:15
torrentcontrol
#!/usr/bin/env python
__doc__ = """Simple script to start and stop all torrents in Transmission
1. Make sure you have installed transmission-remote
2. Enable web client in Transmission (allow only for 127.0.0.1, do not use authentication)
3. Set up cron to start and stop the torrents (optional). e.g.
30 2 * * * path_to_script/torrentcontrol start
0 8 * * * path_to_script/torrentcontrol stop
#!/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