Skip to content

Instantly share code, notes, and snippets.

View hnsl's full-sized avatar
🤠

Hannes Landeholm hnsl

🤠
View GitHub Profile
cmake -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DLLVM_ENABLE_ASSERTIONS:BOOL=ON -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python2 -DCMAKE_INSTALL_PREFIX:PATH=/usr ../llvm
@hnsl
hnsl / gist:03e5953ec151558583cc
Created August 4, 2015 03:05
golang interface experiments
type count int32
type incrementable interface {
Inc()
}
type countable interface {
incrementable
Dec()
@hnsl
hnsl / gist:c20d73d581d578da1a05
Created August 6, 2015 02:59
Haskell reverse polish notation
consumeRPN [] st = last st
consumeRPN (x:xs) st
| x == "+" = consumeRPN xs (ll ++ [l1 + l2])
| x == "-" = consumeRPN xs (ll ++ [l1 - l2])
| x == "*" = consumeRPN xs (ll ++ [l1 * l2])
| x == "/" = consumeRPN xs (ll ++ [l1 / l2])
| otherwise = consumeRPN xs (st ++ [read x])
where
l2 = last st
l1 = last $ init st
@hnsl
hnsl / gist:2ec70a739cadb2af9583
Created August 9, 2015 21:11
hello world with proofs
module Main
total
minusS : (n : Nat) -> (m : Nat) -> LTE m n -> Nat
minusS n m x = n - m
total
decNat : Nat -> Nat
decNat k with (isLTE 1 k)
decNat k | (Yes prf) = minusS k 1 prf
@hnsl
hnsl / gist:4030290c6b22c1723bc6
Created September 18, 2015 21:36
test close
ch := make(chan interface{})
msg := "foo"
go func() {
x := <- ch
if _, ok := x.(string); ok {
jlib.JPrint("%s", x.(string))
}
close(ch)
}()
@hnsl
hnsl / gist:17c5bfbf3d55d08a1883
Last active November 20, 2015 00:12
bandwidth 2
#include <cstdlib>
#include <vector>
#include <climits>
#include <algorithm>
#include <iostream>
class Computer;
class Link {
public:
@hnsl
hnsl / marten.cpp
Last active November 21, 2015 18:36
marten
#include <iostream>
#include <vector>
#include <algorithm>
class Vertex {
public:
// Vertex id in vertexes.
int id;
// Index of vertex begin edge (first).
int idx;
-1.585 *
(
if (((1.262 * a + 1.262 * b) + -0.000) > 0)
then ((1.262 * a + 1.262 * b) + -0.000)
else 0
)
+
1.303 *