Skip to content

Instantly share code, notes, and snippets.

@Mortal
Mortal / Bricklaying.ipynb
Last active September 17, 2016 08:14
Bricklaying
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Mortal
Mortal / 30game-strategy.txt
Last active August 10, 2016 20:44
Add self-defense strategy
rav@gonzales:~/work/30game$ python thirty.py -d
Compute utility-maximizing strategy for 6 6-sided dice...
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
98 98 98 98 98 00 00 00 00 00 00 03 06 09 12 16 21 25 31 37 42 48 50 55 79 72 85 90 94 95 97
96 92 85 61 28 00 01 02 03 04 08 11 15 20 24 30 35 40 44 53 59 67 75 82 88 91
93 86 66 38 13 05 07 10 14 18 22 26 32 39 45 52 58 68 73 81 87
89 74 51 27 17 19 23 29 34 41 47 54 60 69 76 84
83 65 46 33 36 43 49 57 64 71 80
78 63 56 62 70 77
On first roll, do the first possible:
@Mortal
Mortal / compile.py
Created July 31, 2016 20:59
Use dukpy to translate ES6 to ES5 using Babel.js when source file changes (and optionally send error messages to Vim)
import re
import os
import json
import argparse
import functools
import subprocess
import dukpy
import dukpy.babel
@Mortal
Mortal / f.py
Last active April 19, 2016 08:07
Funny fractions
"""
Inspired by http://www.futilitycloset.com/2007/02/02/reductio-ad-absurdum
>>> funny_fractions(100)
16/64 = 1/4
19/95 = 1/5
26/65 = 2/5
49/98 = 4/8 = 1/2
>>> funny_fractions(1000)
[Wed Dec 30 17:25:58.422264 2015] [:error] [pid 6405] [client 130.225.0.251:34996] An Error occurred while handling another error:
exception 'yii\\base\\InvalidConfigException' with message 'A circular dependency is detected for bundle 'frontend\\assets\\AppAsset'.' in /home/cramer/academyhp/advanced/vendor/yiisoft/yii2/web/View.php:293
Stack trace:
#0 /home/cramer/academyhp/advanced/vendor/yiisoft/yii2/web/AssetBundle.php(119): yii\\web\\View->registerAssetBundle('frontend\\assets...')
#1 /home/cramer/academyhp/advanced/frontend/views/layouts/main.php(16): yii\\web\\AssetBundle::register(Object(yii\\web\\View))
#2 /home/cramer/academyhp/advanced/vendor/yiisoft/yii2/base/View.php(325): require('/home/cramer/ac...')
#3 /home/cramer/academyhp/advanced/vendor/yiisoft/yii2/base/View.php(247): yii\\base\\View->renderPhpFile('/home/cramer/ac...', Array)
#4 /home/cramer/academyhp/advanced/vendor/yiisoft/yii2/base/Controller.php(386): yii\\base\\View->renderFile('/home/cramer/ac...', Array, Object(frontend\\controll
[Wed Dec 30 17:11:41.962424 2015] [:error] [pid 6403] [client 130.225.0.251:34788] An Error occurred while handling another error:\nexception 'yii\\base\\InvalidParamException' with message 'The file or directory to be published does not exist: /home/cramer/academyhp/advanced/vendor/bower/jquery/dist' in /home/cramer/academyhp/advanced/vendor/yiisoft/yii2/web/AssetManager.php:452\nStack trace:\n#0 /home/cramer/academyhp/advanced/vendor/yiisoft/yii2/web/AssetBundle.php(163): yii\\web\\AssetManager->publish('/home/cramer/ac...', Array)\n#1 /home/cramer/academyhp/advanced/vendor/yiisoft/yii2/web/AssetManager.php(266): yii\\web\\AssetBundle->publish(Object(yii\\web\\AssetManager))\n#2 /home/cramer/academyhp/advanced/vendor/yiisoft/yii2/web/AssetManager.php(237): yii\\web\\AssetManager->loadBundle('yii\\web\\JqueryA...', Array, true)\n#3 /home/cramer/academyhp/advanced/vendor/yiisoft/yii2/web/View.php(284): yii\\web\\AssetManager->getBundle('yii\\web\\JqueryA...')\n#4 /home/cramer/academyhp/advanced/vendor/yiisoft
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for 2amigos/yii2-chartjs-widget ~2.0 -> satisfiable by 2amigos/yii2-chartjs-widget[2.0.0].
- 2amigos/yii2-chartjs-widget 2.0.0 requires bower-asset/chartjs 1.0.2 -> no matching package found.
Problem 2
- yiisoft/yii2 2.0.6 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- yiisoft/yii2 2.0.5 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
@Mortal
Mortal / sum.py
Created November 26, 2015 14:52
Add multiples of powers of two
import sys
def main(s):
"""
>>> main("2 0 1 4 10 10")
2 * 2 + 1 * 8 + 4 * 16 + 10 * 32 + 10 * 64 = 1036
"""
r = 0
terms = []
@Mortal
Mortal / kasseplot.py
Created September 14, 2015 06:50
kasseplot.py
import requests
import matplotlib.pyplot as plt
def main():
data = requests.get('http://enkasseienfestforening.dk/timetrial/json/').json()
fig, ax1 = plt.subplots()
ax1.set_ylim(0, 5)
xmax = 90
ax1.set_xlim(0, xmax / 5)
@Mortal
Mortal / keybase.md
Created February 23, 2015 18:19
Woo, everyone get on the keybase train

Keybase proof

I hereby claim:

  • I am mortal on github.
  • I am ravv (https://keybase.io/ravv) on keybase.
  • I have a public key whose fingerprint is 9722 E25A D097 620C FA15 CC66 4770 F95A EC3F 673C

To claim this, I am signing this object: