Skip to content

Instantly share code, notes, and snippets.

View flyx's full-sized avatar

Felix Krause flyx

View GitHub Profile
@flyx
flyx / gist:3839295
Created October 5, 2012 11:16
OpenSCAD stuff
module earth() {
sphere(r=2, $fn=200);
}
module chock() {
polyhedron(
points=[[0,0,2], [0,0,-2], [2,0.6,2], [2, 0.6, -2], [2, -0.6, 2],
[2, -0.6, -2] ],
triangles=[[0, 1, 2], [1, 3, 2], [0, 4, 1], [1, 4, 5], [2, 3, 5], [2, 5, 4],
[0, 2, 4], [1, 5, 3]]
@flyx
flyx / gist:3923850
Created October 20, 2012 16:30
foo
def authenticated(func):
def wrapped_func():
if 'userid' in session:
return func(user=db_session.query(User).filter(User.id == session['userid']).one())
else:
return redirect('/user/login')
return wrapped_func
@app.route('/')
@authenticated
@flyx
flyx / gist:4078399
Created November 15, 2012 12:24
enterprisey method
IPoint SetDistance (IPoint point, double newDistance) {
return Dispatcher.Instance.CreatePoint (point.X, point.Y, point.Z, (float)newDistance, point.Heading);
}
type Model is interface;
type Model_Reference is access all Model'Class;
type Container is tagged record
Contents : Model_Reference;
end record;
procedure Set_Model (Object : in out Container; Value : Model'Class) is
begin
template <typename TValue, typename TPred>
BinarySearchTree<TValue, TPred>::BinarySearchTree() {
//...
}
def rec_permutations(prefix, remaining):
if len(remaining) == 1:
yield prefix + remaining
else:
for e in remaining:
new_remaining = remaining[:] # copy
new_remaining.remove(e)
for p in rec_permutations(prefix + [e], new_remaining):
yield p
#include <iostream>
using namespace std;
struct A {
void put() {
cout << "A" << endl;
}
virtual void vPut() {
cout << "A" << endl;
@flyx
flyx / gist:6099315
Last active December 20, 2015 08:19
-- compilation unit 1:
generic
type T is private;
package Unit is
-- ...
end Unit;
-- compilation unit 2:
@flyx
flyx / multimap.ads
Last active December 21, 2015 05:29
with Ada.Containers.Vectors;
with Ada.Containers.Hashed_Maps;
generic
type Key_Type is private;
with package Element_Vectors is new Ada.Containers.Vectors (<>);
with function Hash (Key : Key_Type) return Ada.Containers.Hash_Type;
with function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
package Multimaps is
package Parent is new Ada.Containers.Hashed_Maps
passdb passwd-file {
args = /home/vmail/%d/passwd
}
passdb pam {
args = session=yes dovecot
}
userdb static {
args = uid=vmail gid=dovecot home=/home/vmail/%d/%u