View eigen.py
import numpy as np | |
A = np.array([[2,1,2.5], [1,3,1], [2.5,1,4]]) | |
# Eigenvalues and -vectors have the property such that: Ax = lx | |
# x ... Eigenvectors | |
# l ... Eigenvalues | |
l, x = np.linalg.eig(A) | |
# it follows: |
View turbo.json
[ | |
{ | |
"ColorSpace": "RGB", | |
"DefaultMap": true, | |
"Name": "Turbo", | |
"RGBPoints": [ | |
0.0, | |
0.18823529411764706, | |
0.07058823529411765, | |
0.23137254901960785, |
View divide by value.py
# What you would normaly do: | |
def some_divison(): | |
flag = True | |
val = 23 | |
divisor = 42 | |
if flag: | |
return val / divisor | |
View freecad_daily_build.sh
#!/bin/bash | |
set -e | |
################################# | |
# NOTE: | |
# This assumes you have a user `builder` and a folder `/home/builder/packages`. | |
# it will clone FreeCAD there and start pbuilder using pdebuild. | |
# For me this works using debian sid. (stretch/buster will probably not work!) | |
# | |
# After the build has finished, it will import the packes into a reprepro | |
# which is setup at /srv/repo |
View ReplaceNonNullPlacements.FCMacro
print("Checking replacing all placements with default.") | |
print("===============================================") | |
for b in App.activeDocument().findObjects("PartDesign::Body"): | |
if not b.Placement.isNull(): | |
print("!!! Body {} has a non null placement --> resetting!".format(b.Label)) | |
b.Placement.Base = FreeCAD.Base.Vector() | |
b.Placement.Rotation = FreeCAD.Base.Rotation() | |
else: | |
print("Body {} looks fine...".format(b.Label)) |
View linear.py
import numpy as np | |
from itertools import combinations | |
import scipy.linalg | |
x = [1.2, 1.3, 1.6, 2.5, 2.3, 2.8] | |
y = [167.0, 180.3, 177.8, 160.4, 179.6, 154.3] | |
z = [-0.3, -0.8, -0.75, -1.21, -1.65, -0.68] | |
f = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6]).transpose() | |
G = np.c_[x, y, z] |
View bottleclass.py
from bottle import Bottle | |
# From http://stackoverflow.com/a/21112077 | |
def routemethod(route, **kwargs): | |
def decorator(f): | |
f.route = route | |
for arg in kwargs: | |
setattr(f, arg, kwargs[arg]) | |
return f | |
return decorator |
View bend_tube.scad
// fine mesh | |
fn = 1000; | |
// epsilon for clean intersection | |
eps = 0.1; | |
module tube(inner=5, outer=10, angle=45, length=250){ | |
// we want the thing in z direction, thus we rotate on x axis | |
View virt-import-win7-from-virtualbox.sh
# Unfortunately virtio seems to not work with win8 (it seems to work with windows 10) | |
virt-install --import --memory 4096 --vcpus 1 --name win8 --os-variant win8 --disk ~/VirtualBox\ VMs/Windows/Windows-disk1.vmdk,format=vmdk |
View new_debian_kvm.sh
#!/bin/bash | |
set -e | |
# Name of the VM | |
IMAGE=some-fancy-name | |
# IP address for VM | |
IP="192.168.122.30" | |
MIRROR=http://mirror.hetzner.de/debian/packages | |
PACKAGES="openssh-server htop vim" |
NewerOlder