Skip to content

Instantly share code, notes, and snippets.

@Mortal
Mortal / wmts-dimensions.html
Created June 28, 2019 11:24
Example of using a custom tileLoadFunction to switch to a different tileserver when a tileserver is down.
<!--
Example of using a custom tileLoadFunction to switch to a different tileserver
when a tileserver is down.
Based on the example at https://openlayers.org/en/latest/examples/wmts-dimensions.html
-->
<!DOCTYPE html>
<html>
<head>
<title>WMTS Tile Transitions</title>
"""
Suppose the better places a bet of one dollar and wins x dollars with probability p;
with probability 1-p the bookmaker keeps the one dollar.
The expected profit for the bookmaker is (1-p) - x p
= 1 - p (1 + x)
If we want the profit greater than zero, the odds x must be
1 - p (1 + x) > 0
{
"basic": {
"license key": "***REMOVED SENSITIVE VALUE***",
"date": "Sun, 21 Jan 2018 16:50:13 +0000",
"ownCloud version": "10.0.4.4",
"ownCloud version string": "10.0.4",
"ownCloud edition": "Community",
"server OS": "Linux",
"server OS version": "Linux lyra.strova.dk 4.4.0-042stab127.2 #1 SMP Thu Jan 4 16:41:44 MSK 2018 x86_64",
"server SAPI": "fpm-fcgi",
@Mortal
Mortal / Night_Vale_download.sh
Created November 2, 2017 19:39
Download all Night Vale episodes
#!/bin/sh
[ -e "117.mp3" ] || curl -Lo "117.mp3" "http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/nightvale/11720-20eGemony20Part201_20_Canadian20Club_.mp3?dest-id=149715"
[ -e "116.mp3" ] || curl -Lo "116.mp3" "http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/nightvale/11620-20Council20Member20Flynn2C20Part203.mp3?dest-id=149715"
[ -e "115.mp3" ] || curl -Lo "115.mp3" "http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/nightvale/11520-20Council20Member20Flynn2C20Part202.mp3?dest-id=149715"
# Skip 'It Makes A Sound: Episode 1, Are You Listening?'
# Skip 'I Only Listen to the Mountain Goats: Episode 1, The Best Ever Death Metal Band in Denton'
[ -e "114.mp3" ] || curl -Lo "114.mp3" "http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/nightvale/11420-20Council20Member20Flynn2C20Part201.mp3?dest-id=149715"
[ -e "113.mp3" ] || curl -Lo "113.mp3" "http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/nightvale/11320-20Niecelet.mp3?dest-id=149715"
[ -e "112.mp3" ] || curl -L
@Mortal
Mortal / foo.py
Last active September 5, 2017 09:14 — forked from Grokzen/Symmetrical ManyToMany Filter Horizontal in Django Admin.py
Symmetrical ManyToMany Filter Horizontal in Django Admin
# Based on post from:
# https://snipt.net/chrisdpratt/symmetrical-manytomany-filter-horizontal-in-django-admin/#L-26
"""
When adding a many-to-many (m2m) relationship in Django, you can use a nice
filter-style multiple select widget to manage entries. However, Django only
lets you edit the m2m relationship this way on the forward model. The only
built-in method in Django to edit the reverse relationship in the admin is
through an InlineModelAdmin.
@Mortal
Mortal / my_scalar_formatter.py
Created August 8, 2017 06:12
Nicer offset in matplotlib
import matplotlib.pyplot as plt
from matplotlib.ticker import ScalarFormatter
#import seaborn as sns
class MyScalarFormatter(ScalarFormatter):
def get_offset(self):
a = self.get_scale_string()
b = self.get_offset_string()
if a or b:
import re
import email
import email.header
import email.message
import email.utils
# import collections
# import pprint
This file has been truncated, but you can view the full file.
Mar 11 21:26:58 alcyone systemd[1]: Reloading Laptop Mode Tools.
Mar 11 21:26:58 alcyone laptop_mode[9215]: Laptop Mode Tools invoked by parent: 1
Mar 11 21:26:58 alcyone laptop_mode[9215]: Determining power state from /sys/class/power_supply/AC/online.
Mar 11 21:26:58 alcyone laptop_mode[9215]: Not trying other options, already found a power supply.
Mar 11 21:26:58 alcyone laptop-mode[9239]: Battery level polling is disabled.
Mar 11 21:26:58 alcyone laptop_mode[9215]: Battery level polling is disabled.
Mar 11 21:26:58 alcyone laptop-mode[9241]: Prelim lock acquisition on descriptor 8 with pid 9215
Mar 11 21:26:58 alcyone laptop_mode[9215]: Prelim lock acquisition on descriptor 8 with pid 9215
Mar 11 21:26:58 alcyone laptop_mode[9215]: Prelim lock acquisition on descriptor 9 with pid 9215
Mar 11 21:26:58 alcyone laptop_mode[9215]: Now invoking lmt_main_function with arguments -- auto
Mar 03 08:11:56 alcyone systemd[1]: Starting Laptop Mode Tools...
Mar 03 08:11:56 alcyone laptop_mode[387]: You have a broken battery. Cannot determine actual state
Mar 03 08:11:56 alcyone laptop_mode[387]: Please report this to the linux-acpi developers
Mar 03 08:11:56 alcyone laptop_mode[387]: Not determining any state from this device: /sys/class/power_supply/BAT0
Mar 03 08:11:58 alcyone laptop_mode[387]: You have a broken battery. Cannot determine actual state
Mar 03 08:11:58 alcyone laptop_mode[387]: Please report this to the linux-acpi developers
Mar 03 08:11:58 alcyone laptop_mode[387]: Not determining any state from this device: /sys/class/power_supply/BAT0
Mar 03 08:11:58 alcyone laptop_mode[387]: enabled, active
Mar 03 08:11:58 alcyone laptop_mode[387]: Missing TX power level argument.
Mar 03 08:11:58 alcyone laptop_mode[387]: Failed to set power saving mode for wireless card
@Mortal
Mortal / compress.py
Created September 17, 2016 18:52
HTML compressor
import io
import sys
import html5lib
from xml.etree.ElementTree import ElementTree
def element_to_html(element):
with io.BytesIO() as buf:
# We cannot use default_namespace,
# since it incorrectly errors on unnamespaced attributes