Skip to content

Instantly share code, notes, and snippets.

View rmoehn's full-sized avatar

Richard Möhn rmoehn

View GitHub Profile
@rmoehn
rmoehn / none_bug_driver.py
Last active May 26, 2018 05:13
Naive driver for debugging oughtinc/patchwork#4
import sys
from patchwork.actions import Reply, Unlock
from patchwork.datastore import Datastore
from patchwork.scheduling import RootQuestionSession, Scheduler
from patchwork.text_manipulation import make_link_texts
def main():
db = Datastore()
sched = Scheduler(db)
@rmoehn
rmoehn / dump-1489371711841.cljs
Created March 13, 2017 02:21
ClojureScript REPL dump
cljs.user=> (.text (js/jQuery "#title") "bla")
ERROR - jQuery is not defined
cljs.user=> (rand)
0.4304687375015359
cljs.user=> '(meeow)
(meeow)
cljs.user=> (m3-C1 1)
ERROR - cljs.core.m3_C1.call is not a function
cljs.user=> m3-C1
-862048943
@rmoehn
rmoehn / README.md
Last active November 11, 2016 02:14
Q-learning for the OffSwitchCartPole-v0

forgym.py can be found in the context of its repo here. I made this Gist, so that I can include it with my OpenAI Gym upload.

For much more interesting information than this short script and the reward graph, have a look at (Non-)Interruptibility of Sarsa(λ) and Q-Learning.

@rmoehn
rmoehn / user.clj
Created October 22, 2016 04:50
Clojure is the new Perl – Loading Markdown files into Jupyter Notebooks/IPython Notebooks using Specter and Cheshire
(ns user
(:require [clojure.java.io :as io]
[clojure.string :as string]
[cheshire.core :as cheshire]
[com.rpl.specter :as s]))
;;; Dependencies: [org.clojure/clojure "1.9.0-alpha13"]
;;; [cheshire "5.6.3"]
;;; [com.rpl/specter "0.13.0"]]
@rmoehn
rmoehn / Dockerfile
Last active December 28, 2017 01:50
Dockerfile for running Anki inside a Docker Container on Debian Stable
# Credits:
#
# - http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
# - https://github.com/jfrazelle/dockerfiles/blob/master/spotify/Dockerfile
#
# Note:
#
# This Dockerfile sets up everything for studying Japanese with Anki. ADAPT
# comments point to what you'll probably need to adapt to your situation.
#
@rmoehn
rmoehn / paragraphs.py
Created February 17, 2016 14:34
Makes strings from triple-quoted string literals usable.
import re
import textwrap
def paragraphs(u):
"""
Makes strings from triple-quoted string literals usable.
When you write a string as a triple-quoted literal, you end up with
something that has superfluous newlines and lots of empty space from the
indentation, like this::
@rmoehn
rmoehn / cleaning-robot.clj
Last active August 29, 2015 14:15
Most likely chain of rooms a cleaning robot has visited given initial and final state
(ns user)
;;; See http://sparetimeteaching.dk/note_collections/2015%20Winter.pdf, A Functional Fever Fantasy
(def trans-probs {:living-room
{:living-room 0
:office 0.3
:kitchen 0.5
:desk 0
:bedroom 0.2}
@rmoehn
rmoehn / README-ALP4.md
Last active August 29, 2015 13:57
Two concurrency course solutions in Go

Selected Solutions to Concurrency Course Exercises

In 2013 I took the course in nonsequential programming at my university. The programming language used was Google Go and here are the solutions to two of the exercises.

  • smokers.go is a solution to the cigarette smokers problem. Contains a fancy ASCII art animation.
  • p2p-chat.go is peer-to-peer chat using the algorithm of Ricart and Agrawala for mutual exclusion. This is probably not the usual way to do things and, not using a Lamport clock, only works with multiple processes on one machine. However, it might still be interesting.

License

The MIT License (MIT)

@rmoehn
rmoehn / ddist-manuscripts
Last active August 29, 2015 13:57
Manuscripts for oral exam in distributed systems
01 Remote Procedure Call + RMI
------------------------------
Motivation and Idea
- server offers some service, client wants to use it
- traditional: socket connection to server, use some text-oriented
protocol with requests and responses (fx HTTP) – PIC!
- idea: want to use the the server's service just as if it was another
library; function call whose body is executed remotely – PIC!
@rmoehn
rmoehn / Bilbo
Created February 25, 2014 16:57
Send emails to multiple people without them seeing the others' addresses and without using Bcc
#!/usr/bin/perl
use 5.18.0;
use warnings;
use strict;
use autodie qw(:all);
use Perl6::Slurp;
my $bodyfile = shift @ARGV;
my $subject = shift @ARGV;