Skip to content

Instantly share code, notes, and snippets.

View flyx's full-sized avatar

Felix Krause flyx

View GitHub Profile
@flyx
flyx / foo.adb
Created May 3, 2012 20:20
Example package where a "protected" scope would be nice
package Foo is
type A is abstract tagged null record;
-- some functionality A provides
procedure Bar (Object : A);
-- some part of this functionality that depends
-- on the specific child-classes of A
-- this function should not be visible to other
-- packages, but it has to be visible to packages
@flyx
flyx / bla.adelheid
Created May 7, 2012 19:45
Quelltext der imaginäre Programmiersprache Adelheid 2005
Paket Eigenheim ist
Sorte Geschirr ist Stapel (Positiver Bereich <>) von Teller;
Paket Tellerhaufen ist neuer Haufen mit (Gegenstand => Teller);
Aufgabe Küche_Machen ist
Einsprungspunkt Dreckiges_Geschirr_Kommt (Dreckiges_Geschirr : Geschirr);
Ende von Küche_Machen;
@flyx
flyx / updateExecutableIcon.py
Created June 21, 2012 13:16
Updates the icon of a windows executable file.
import win32api, win32con
import os, os.path
import struct
import math
def checkPath(path, mode):
if not os.path.exists(path) or not os.path.isfile(path):
raise ValueError("{0} does not exist or isn't a file.".format(path))
if not os.access(path, mode):
raise ValueError("Insufficient permissions: {0}".format(path))
with Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
procedure Test is
subtype Random_Range is Integer range -10 .. 10;
package Random_X is new Ada.Numerics.Discrete_Random(Random_Range);
use Random_X;
Gen : Generator;
begin
loop
function Calculate_Size return Natural;
-- illegal because call to Calculate_Size is non-static
Size : constant := Calculate_Size;
-- requires Size to be a static constant.
type Some_Type is mod 2 ** Size;
@flyx
flyx / test.adb
Created August 21, 2012 18:50
Trying to use Ada 2012 features
with Ada.Text_IO;
procedure Test is
type Int_Array is array (1 .. 64) of aliased Integer;
subtype Index is Integer range 1 .. 4;
type Ref_Element (Data : not null access Integer) is limited null record
with Implicit_Dereference => Data;
@flyx
flyx / gist:3826404
Created October 3, 2012 11:04
problems with Ada syntax highlighting and indentation handling
with Ada.Finalization; -- package import
generic -- indent++
Foo : Integer;
package Bar is -- indend--; indent++
package Child is -- indend++
type T is new Ada.Finalization.Controlled
with null record; -- NO package import
end Child; -- indend--
@flyx
flyx / gist:3826729
Created October 3, 2012 12:43
passing struct from Ada to OpenCL C
// kernel
typedef struct {
int2 offset;
int2 center;
} viewport;
kernel void renderkernel(viewport vp) {
// just accessing the struct crashes
int a = vp.offset;
@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