Skip to content

Instantly share code, notes, and snippets.

@5263
5263 / decode_post_datamtrix.py
Created September 10, 2011 19:45
Decodes Informations from Deutsche Post Datamatrix Codes
#!/usr/bin/env python
import sys
import datetime
frankierart={
0x01:'Stampit 2003',
0x02:'0x02???',
0x03:'Frankit',
0x05:'Filiale',
0x07:'Frankierservice Infopost/Infobrief',
0x08:'Premiumadress',
@5263
5263 / gist:1209263
Last active September 27, 2015 04:08
Calc Checksums for ean (isbn13) and isbn10
def isbn13t10(str1):
if len(str1)==13 and str1.startswith('978') and \
str1[12]==checksum(str1[0:12]):
return '%s%s' %(str1[3:12],isbnchecksum(str1[3:12]))
def isbn10t13(str1):
if len(str1)==10 and \
str1[9].upper()==isbnchecksum(str1[0:9]):
ean12='978%s'% str1[0:9]
return '%s%s' % (ean12,checksum(ean12))
@5263
5263 / Extrusions.py
Created February 7, 2012 13:51 — forked from thehans/Extrusions.py
Parametric Aluminum Extrusion Module
import math
from FreeCAD import Base
#Main class for general extrusion related methods
class ExtrusionProfile():
def __init__(self, profile):
self.profile = profile
def makeExtrusion(self, p1, p2, rotateAngle=0):
"""Generates an extrusion which connects between two points,
@5263
5263 / ncevn.py
Created February 24, 2012 13:51
Parser for netcologne itimized bills
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Netcologne itemized bill paraser
the csv file should be in the same directory and named nc-*
"""
knownprefix = {
#internatinal
'+30':'Griechenland',
@5263
5263 / ImportCSG.html
Created March 12, 2012 13:57
Mirror of Importer of OpenSCAD CSG files for FreeCAD by Keith Sloan
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<frameset rows="*" cols="150,*" framespacing="0" frameborder="no" border="0">
<frame src="../menu.html" name="leftFrame" scrolling="No" noresize="noresize" id="leftFrame" />
<frame src="ImportCSG_main.html" name="mainFrame" id="mainFrame" />
@5263
5263 / Export.html
Created March 23, 2012 15:51
Mirror of Exporter of OpenSCAD CSG files for FreeCAD by Keith Sloan
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<frameset rows="*" cols="147,*" framespacing="0" frameborder="no" border="0">
<frame src="../menu.html" name="leftFrame" scrolling="No" noresize="noresize" id="leftFrame" />
<frame src="Export_main.html" name="mainFrame" id="mainFrame" />
@5263
5263 / blender-nurbs-selfcontained.py
Last active March 20, 2023 12:07
NURBS export for Blender and import for FreeCAD
#!/usr/bin/env python
freecadfunctions="""#!/usr/env/bin python
#python 2
import FreeCAD,Part
def pointstopoles1D(points):
return zip(*[(FreeCAD.Vector(point[0:3]),point[3]) for point in points])
def pointstopoles(points,cu):
poles=[]
@5263
5263 / gist:2842792
Created May 31, 2012 11:31
WIP: ISO261 Thread script for FreeCAD
import Part, FreeCAD, math
iso261pitchregular={1.0:0.25, 1.1:0.25, 1.2:0.25,
1.4:0.30,
1.6:0.35, 1.8:0.35,
2.0:0.4,
2.2:0.45, 2.5:0.45,
3.0:0.5,
3.5:0.6,
4.0:0.7,
4.5:0.75,
@5263
5263 / mailbox.py
Created June 28, 2012 19:10
List new e-mails from IMAP mailbox ordered by spamscore
#!/usr/bin/env python
import imaplib,getpass
import email
import email.header
import email.utils
import re
def decodestr(str1):
str2,enc=email.header.decode_header(str1)[0]
if enc:
return str2.decode(enc)
@5263
5263 / gist:3041500
Created July 3, 2012 18:13
FreeCAD interpolate surface
import FreeCAD
f1=open("surface.dat")
coords=[]
miny=1
for line in f1.readlines():
sline=line.strip()
if sline and not sline.startswith('#'):
ycoord=len(coords)
lcoords=[]
for xcoord, num in enumerate(sline.split()):