Skip to content

Instantly share code, notes, and snippets.

View reynir's full-sized avatar

Reynir Björnsson reynir

  • @roburio
  • Århus, Denmark
View GitHub Profile
@reynir
reynir / output
Created May 7, 2012 22:11 — forked from awreece/output
$ ./command-line-arguments.test --test.bench="Bench"
testing: warning: no tests to run
PASS
BenchmarkConcat 200000 10877 ns/op
BenchmarkJoin 100000 16848 ns/op
BenchmarkBuffer 100000 20729 ns/op
@reynir
reynir / A.j
Created December 5, 2012 07:28
.source A.j
.class public A
.super java/lang/Object
.method public static produce()Lint;
.limit stack 2
.limit locals 0
new int
dup
invokespecial int/<init>()V
def compute_error(partition):
"""Find the majority category of the partition. Count how big
a part of the partition that the majority category is.
Return the ratio of things that are *not* of the majority category."""
categories = map(get_category, partition)
majority = max(set(categories), key=categories.count)
return 1 - (categories.count(majority) / float(len(partition)))
# This is what a typical partition looks like. The inner tuple may
# be very large (in the thousands) and the list of the length may
$ python2 fib.py 32 # Nothing happens for a few secs and then the fibonacci numbers are printed
$ python3 fib.py 32 # The fibonacci numbers are printed one by one with a greater and greater interval
@reynir
reynir / Applicative.idr
Created April 30, 2014 01:02
Interactive proof that fails with a type error
module Verified.Applicative
%default total
class Applicative f => VerifiedApplicative (f : Type -> Type) where
applicativeMap : (x : f a) -> (g : a -> b) ->
map g x = pure g <$> x
applicativeIdentity : (x : f a) -> pure id <$> x = x
applicativeComposition : (x : f a) -> (g1 : f (a -> b)) -> (g2 : f (b -> c)) ->
((pure (.) <$> g2) <$> g1) <$> x = g2 <$> (g1 <$> x)
x : Int
x = 1
y : String
y = "2"
@reynir
reynir / april
Last active August 29, 2015 14:18
April's fool "honey pot" setup
#!/bin/sh
cat << END
Linux atlantis 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u1 x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
@reynir
reynir / test.py
Created April 14, 2015 11:50
ptyprocess
from ptyprocess import PtyProcess
p = PtyProcess.spawn(["/bin/true"])
p.wait()
let cbs = []
for (let i = 0; i < 5; i++) {
cbs.push(function () { console.log(i) })
}
cbs.forEach(function (f) { f() }) // prints "5" five times
@reynir
reynir / EggsToast.java
Created August 29, 2016 13:40 — forked from tonymorris/EggsToast.java
What is the output of this program?
// What is the output of this program?
// a) x = 2
// b) x = 3
// c) compile-error
// d) runtime exception
// e) something else _____
abstract class Eggs {
abstract void m();
Eggs() {