Skip to content

Instantly share code, notes, and snippets.

@crmne
crmne / md5crypt.py
Created August 15, 2010 10:44
UNIX and Apache compatible MD5 password encryption
#!/usr/bin/env python
# Based on FreeBSD src/lib/libcrypt/crypt.c 1.2
# http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/lib/libcrypt/crypt.c?rev=1.2&content-type=text/plain
# Original license:
# * "THE BEER-WARE LICENSE" (Revision 42):
# * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
# * can do whatever you want with this stuff. If we meet some day, and you think
# * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
@DamianZaremba
DamianZaremba / retrieve.py
Created September 3, 2011 16:54
Quick py hack to scrape table data from wikipedia (ISO codes right now)
#!/usr/bin/env python
import urllib
import sys
import json
from mwlib import parser
from mwlib.refine import compat
if __name__ == "__main__":
params = urllib.urlencode({
"format": "json",
@thehans
thehans / Extrusions.py
Created November 26, 2011 23:23
Parametric Aluminum Extrusion Module
from math import sqrt
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,
@sparr
sparr / T-Slot Nut.py
Created November 28, 2011 01:44
Parametric Printable T-Slot Nut
from __future__ import division # allows floating point division from integers
from FreeCAD import Base
import sys
import math
try:
path = App.ConfigGet('UserHomePath') + '/FreeCad/Mod'
i = sys.path.index(path)
except:
sys.path.append(path)
@thehans
thehans / MeasureCircle.py
Created November 30, 2011 05:34
A FreeCAD script for the purpose of inspecting the radius and center of circles in 3D models
from FreeCAD import Base
class MeasureCircle:
"""This class will report the computed radius and center of a circle or arc given 3 vertices.
A line is drawn from the first vertex to the center of the circle, which may be used for future measurements.
Just select the vertices and the result will be shown in Report View
Edges may also be selected and count as two vertices.
If two edges are selected one of the vertices in the second edge is not used in the calculation"""
def __init__(self):
self.points = []
@thehans
thehans / EasyPart.py
Created February 11, 2012 03:55
Helper functions for improving FreeCAD's Python API
import math as _math
from math import ceil, exp, floor, log as ln, log10 as log, pow, sqrt
from FreeCAD import Base
import Part
# Trigonometric wrappers
def acos(x):
"""Return the arc cosine of x, in degrees."""
return _math.degrees(_math.acos(x))
@rmcgibbo
rmcgibbo / pr.md
Created November 1, 2012 02:57 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@joferkington
joferkington / datacursor.py
Created January 22, 2012 22:15
Matplotlib data cursor
from matplotlib import cbook
class DataCursor(object):
"""A simple data cursor widget that displays the x,y location of a
matplotlib artist when it is selected."""
def __init__(self, artists, tolerance=5, offsets=(-20, 20),
template='x: %0.2f\ny: %0.2f', display_all=False):
"""Create the data cursor and connect it to the relevant figure.
*artists* is the matplotlib artist or sequence of artists that will be
selected.
@thehans
thehans / Protractor.py
Created December 1, 2011 04:06
Protractor script for FreeCAD, measures angle between two edges
from FreeCAD import Base
import math
class Protractor:
"""Reports the angle between two edges.
Select the edges and the result will be shown in Report View"""
def __init__(self):
self.firstEdge = None
Gui.Selection.addObserver(self)
FreeCAD.Console.PrintMessage("Select any 2 edges\n")
@doobeh
doobeh / home.html
Created January 19, 2016 14:04
More complete example of FieldList with FormField
<form method="post" action="">
{{ form.name}}
{{ form.hidden_tag() }}
<br/>
{% for entry in form.hours %}
{{ loop.index0|dow }}
{{ entry() }}
{% endfor %}
<input type="submit"/>
</form>