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/env python | |
"""usage: diffblame.py START..END [path]""" | |
import os,sys,subprocess | |
gitpath = subprocess.Popen(["git", "rev-parse","--show-toplevel"],\ | |
stdout=subprocess.PIPE).communicate()[0].strip() | |
diff = subprocess.Popen(["git", "diff","-U0"]+sys.argv[1:],\ | |
stdout=subprocess.PIPE).communicate()[0] | |
for l in diff.splitlines(): | |
if l=='': |
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 FreeCAD | |
def segments2points(segments,degree): | |
pts=segments[0].getPoles()[0:1] | |
for seg in segments: | |
if seg.Degree < degree: | |
seg.Increase(degree) | |
pts.extend(seg.getPoles()[1:]) | |
return pts | |
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 FreeCAD,OpenSCADFeatures | |
for obj in FreeCAD.ActiveDocument.Objects: | |
if obj.TypeId == "Part::FeaturePython" and hasattr(obj,'Proxy') and isinstance(obj.Proxy,OpenSCADFeatures.CGALFeature) \ | |
and len(obj.Children) == 2: | |
print [(child.TypeId,child.PropertiesList) for child in obj.Children] | |
if obj.Children[0].TypeId in ['Part::Cylinder','Part::Sphere']: | |
OpenSCADFeatures.OffsetShape(obj,obj.Children[1],float(obj.Children[0].Radius)) | |
obj.touch() | |
elif obj.Children[1].TypeId in ['Part::Cylinder','Part::Sphere']: | |
OpenSCADFeatures.OffsetShape(obj,obj.Children[0],float(obj.Children[1].Radius)) |
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 hexplacement(plm): | |
fhex="*[float.fromhex(s) for s in %s]" | |
fstr="FreeCAD.Placement(FreeCAD.Vector(%s),FreeCAD.Rotation(%s))" | |
t=[f.hex() for f in plm.Base] | |
r=[f.hex() for f in plm.Rotation.Q] | |
return fstr % (fhex % t, fhex % r ) | |
if __name__=='__main__': | |
import FreeCAD | |
print hexplacement(FreeCAD.Placement()) |
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 unicodedata | |
def encodechar(c): | |
i=ord(c) | |
if i >= 32 and i <=122 and \ | |
c not in '\'\"/\\^_~`|': | |
return c | |
else: | |
if not isinstance(c,unicode): | |
c=unicode(c) | |
name = unicodedata.name(c,None) |
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 FreeCAD | |
import Part | |
def rayshape(phi=0,z=0,r=1e3): | |
import math | |
x=r*math.cos(phi) | |
y=r*math.sin(phi) | |
l=Part.Line(FreeCAD.Vector(0,0,z),FreeCAD.Vector(x,y,z)) | |
return l.toShape() |
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 phppost(subject,message,url,forum,username,password): | |
import mechanize | |
import time | |
br = mechanize.Browser() | |
br.open(url+'/ucp.php?mode=login') | |
loginform = tuple(br.forms())[1] | |
br.form=loginform | |
loginform.find_control("username").value=username | |
loginform.find_control("password").value=password | |
loginform.find_control("viewonline").set_single(True) |
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/env python | |
def blobhash(str1): | |
import hashlib | |
hash1=hashlib.sha1("blob %d\0" % len(str1)) | |
hash1.update(str1) | |
return hash1.hexdigest() | |
def walk(dir1,extension=".py"): | |
import os | |
for root, dirs, files in os.walk(dir1): |
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 FreeCAD | |
def checkwire(w): | |
"""steps through every edge of a wire and checks the orientation""" | |
pos=w.Vertexes[0].Point | |
for i,e in enumerate(w.Edges): | |
if e.Orientation == "Forward": | |
vs=e.Vertexes | |
else: | |
vs=e.Vertexes[::-1] |
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 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)) |
OlderNewer