Skip to content

Instantly share code, notes, and snippets.

@roehst
roehst / README.md
Last active December 3, 2022 17:48
Soccer Tactics based on Minimal Spanning Trees

I now this is very naive, but after watching a few soccer games I was vary curious to see if minimal spanning trees between soccer players could somehow model soccer tactics.

The file above can be opened in a browser, with no dependencies.

@roehst
roehst / fibonacci.ml
Created April 8, 2021 21:50
Fibonacci server with Dream
let state : (int * int) list ref = ref []
let rec fibonacci (n : int) : int =
if n <= 1 then 1
else
match List.assoc_opt n !state with
| Some v -> begin
print_string "Cache hit :)";
print_newline ();
v
@roehst
roehst / original.py
Last active May 18, 2020 13:50
Reducing memory usage in Pandas
def reduce_mem_usage(df, verbose=True):
numerics = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']
start_mem = df.memory_usage().sum() / 1024**2
for col in df.columns:
col_type = df[col].dtypes
if col_type in numerics:
c_min = df[col].min()
c_max = df[col].max()
if str(col_type)[:3] == 'int':
if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:
import random
import ast
def generate_code(scope):
stmts = []
for _ in range(5):
stmts.append(generate_statement(scope))
stmts.append(random.choice(scope))
return "\n".join(stmts)
@roehst
roehst / Direction.idr
Last active December 9, 2018 23:42
Simple verification in Idris
module Main
data Direction = North | South | West | East
turn : Direction -> Direction
turn North = East
turn South = West
turn West = North
turn East = South
@roehst
roehst / functional.ex
Created November 6, 2018 16:01
Refactor some functional compositions
defmodule Functional do
def run() do
source = """
def f(xs, f) do
Enum.map(xs, f) |> Enum.join(",")
Enum.map(xs, f) |> Enum.into(",")
end
"""
ast = Code.string_to_quoted!(source)
@roehst
roehst / CredoBugOnABC.ex
Created October 23, 2018 18:17
Credo Bug On ABC
defmodule CredoBugOnABC do
"""
This is an interactive bug report :)
Load it on IEx.
"""
def test() do
@roehst
roehst / ElixirASM.ex
Created October 22, 2018 20:15
ASM can be parsed with Elixir
# just try ASM.example on IEx
# assembly-ish code parses alright
defmodule ASM do
def example() do
quote do
section data
msg db "hello, world"
len equ - msg
@roehst
roehst / 1.ex
Last active October 15, 2018 18:46
def eval(num) when is_number(num) do
num
end
@roehst
roehst / keybase.md
Created October 11, 2018 15:42
keybase.md

Keybase proof

I hereby claim:

  • I am roehst on github.
  • I am roehst (https://keybase.io/roehst) on keybase.
  • I have a public key ASDz5GKEsxxSYl2CEs5RxOZCyHI5CSeBPmLsRe19yKCFcgo

To claim this, I am signing this object: