Skip to content

Instantly share code, notes, and snippets.

View miikka's full-sized avatar

Miikka Koskinen miikka

View GitHub Profile
import contextvars
import logging
import uuid
import tornado.ioloop
import tornado.web
logger = logging.getLogger(__name__)
request_id_var = contextvars.ContextVar("request_id")
@miikka
miikka / day9.ijs
Created December 21, 2018 06:09
Advent of Code 2018
left =: 4 : 0
if. y = 0 do. x - 1
else. <: y
end.
)
right =: 4 : 0
if. y = x do. 1
else. >:y
end.
@miikka
miikka / deps.edn
Created March 9, 2018 17:37
run `clj -m cljs.main` to get a REPL
{:deps {org.clojure/clojurescript {:mvn/version "1.10.145"}
org.clojure/test.check {:mvn/version "0.10.0-alpha2"}}}
@miikka
miikka / cumulative.py
Last active August 10, 2017 14:59
Cumulative committer count data from a git repo
#!/usr/bin/env python3
# git log --format="%ae,%at" | python cumulative.py
from datetime import date
import fileinput
committers = dict()
for line in fileinput.input():
author, time = line.split(",")
@miikka
miikka / dne.v
Created January 26, 2017 19:58
Double negation elimination
Axiom a1 : forall A B, A -> (B -> A).
Axiom a2 : forall A B, (~B -> ~A) -> (A -> B).
Theorem dne :
forall A, ~~A -> A.
Proof.
intros A P.
generalize P.
apply a2, a2, a1, P.
Qed.
@miikka
miikka / sprite.py
Last active October 17, 2016 10:08
Generate random symmetric sprites in the terminal
#!/usr/bin/env python
# Inspired by this tweet: https://twitter.com/AtticusBones/status/787936821892317184
from __future__ import division
import atexit
import curses
import math
import random
import sys
@miikka
miikka / example.clj
Last active August 16, 2016 10:57
clojure.spec version of ring-swagger's README example
(ns example
(:require [clojure.spec :as spec]
[ring.swagger.swagger2 :as rs]
[schema.core :as s]))
(spec/def ::id string?)
(spec/def ::name string?)
(spec/def ::street string?)
(spec/def ::city #{"tre" "hki"})
from collections import defaultdict, namedtuple
import numpy as np
def visible_cap_central_angle(altitude):
earth_radius = 6371.0
return np.arctan2(np.sqrt(altitude * (altitude + 2 * earth_radius)),
earth_radius)
def hav(x):
return np.sin(x/2)**2
@miikka
miikka / schema.py
Last active November 25, 2023 20:09
Using Hypothesis to generate XML based on RELAX-NG
import string
from lxml import etree
from lxml.etree import QName
from lxml.builder import E
from hypothesis import strategies as st
NS = "http://relaxng.org/ns/structure/1.0"