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,calendar | |
def ultimo(num=3,today=None): | |
"""return a list of datetime.date with the last day of num previous months""" | |
if today is None: | |
today = datetime.date.today() | |
return [datetime.date(y,m,calendar.monthrange(y,m)[1]) for \ | |
m,y in (((today.month - i -1) % 12+1, today.year + \ | |
((today.month - i -1) // 12)) for i in range(num+1,0,-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
#!/usr/bin/env python | |
import zip2git | |
from PySide import QtGui | |
# 1. Choose repository (directiory) | |
repodir = QtGui.QFileDialog.getExistingDirectory(QtGui.qApp.activeWindow()) | |
if repodir: | |
# ToDO: 2. List branches in a list and let the user choose one | |
# ToDo: 3. List commits in a list and let the user choose one | |
# ToDo: 4. Check if it would overwrite a file. And if the file is | |
# part of the repo. Ask the user for cofirmation |
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 python3 | |
import bs4 | |
import requests | |
sa = requests.Session() | |
sa.verify = False # workaround | |
# sa.auth = BearerAuth() | |
sa.timeout = 10 |
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
#!/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
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
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
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
#!/usr/bin/env python | |
import zipfile | |
tempdirlin='/home/user/sattemp' | |
tempdirwine='D:\\' | |
converterbin="/windows/Programme/Program Files (x86)/DesignSpark/DesignSpark Mechanical 1.0/sabSatConverter.exe" | |
# add freecad libdir to path | |
import sys | |
sys.path.insert(0,'/usr/local/freecad/lib') |
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()) |
NewerOlder