Skip to content

Instantly share code, notes, and snippets.

View mueslo's full-sized avatar
⚛️

mueslo

⚛️
  • Dresden, Germany
View GitHub Profile
@mueslo
mueslo / pyparsing_2.3.1_bug.py
Last active February 11, 2019 15:11
PyParsing 2.3.1 Bug
from pyparsing import (Word, Literal, Regex, Keyword, CaselessKeyword, Forward,
Group, OneOrMore, ZeroOrMore, alphas, nums, Suppress,
delimitedList, CharsNotIn, Empty, Optional, Or,
restOfLine)
IDENTIFIER = Word(alphas + "_", alphas + nums + "_")
(LPAREN, RPAREN, LBRACK, RBRACK, LBRACE, RBRACE,
SEMI, COMMA, EQUAL, DQUOTE) = map(Suppress, "()[]{};,=\"")
@mueslo
mueslo / ddns_ud.sh
Last active July 22, 2023 11:31
Dynamic A-Record DNS Updater for united-domains.de (OpenWRT/LEDE)
#!/bin/sh
# requires: wget, ca-certificates, grep
#rm /tmp/cookies.txt
cookiefile="/tmp/cookies.txt"
#domain should contain "domain_id-record_id"
domain_id=$(echo $domain | tr "-" "\n" | sed -n "1p")
record_id=$(echo $domain | tr "-" "\n" | sed -n "2p")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am mueslo on github.
  • I am mueslo (https://keybase.io/mueslo) on keybase.
  • I have a public key whose fingerprint is C5CC 9C3D 6BD1 E836 D45C 92E2 14C7 0D20 DDA2 39C2

To claim this, I am signing this object:

@mueslo
mueslo / aggdmg.py
Last active August 29, 2015 14:06
Calculates damage probabilities
#!/usr/bin/env python2
import fractions
import itertools
import operator
import numbers
import collections
class OutcomeProb(object):
'''combines probabilistic outcomes with operator.add'''
def __init__(self, *args, **kwargs):
#!/usr/bin/env python2
import numpy as np
#ELO basics
# Expected result given 2 elo scores:
def expected(r1, r2):
sigma = 400.
return 1./(1.+pow(10., (r2-r1)/sigma))
def chooseallmin(x,f):
if len(x)==0: return x
vals = map(f, x)
minval = min(vals)
return [x[i] for i,e in enumerate(vals) if e==minval]
@mueslo
mueslo / gist:7700906
Last active December 29, 2015 16:59
mueslo's somewhat-optimized BFS for rg.org
import numpy as np
maxl = 19*19
enemy_cell = maxl+1
friendly_cell = maxl+2
#we need this to retrace our steps
def argmax(x):
i = np.nanargmax(x)
while len(x)>0 and x[i] in [enemy_cell,friendly_cell,np.inf]:
x[i] = -np.inf
@mueslo
mueslo / mueslobot_v0.0.1_
Last active December 28, 2015 18:39
erere
import rg
import numpy as np
class Robot:
#desirability of certain number of neighbours:
# num 0 1 2 3 4
des_en = [0, 1, -2, -3, -4] #Enemy
des_tn = [0, 1, 2, 1, 0] #Team
direction = {
(1,0) : "right",