Skip to content

Instantly share code, notes, and snippets.

View mw44118's full-sized avatar
🤠

W. Matthew Wilson mw44118

🤠
View GitHub Profile
@mw44118
mw44118 / rollwithadvantage.py
Created March 8, 2021 02:41
Looks at relative value of rolling with advantage vs 1d20+1, 1d20+3, 1d20+5
def _1d20():
return random.choice(range(1, 21))
def roll_with_advantage():
return max([_1d20(), _1d20()])
if __name__ == "__main__":
score = collections.defaultdict(int)
@mw44118
mw44118 / gist:50b438d2d3d75624b7a2
Last active November 24, 2015 19:04
View a tab-delimited text file in your terminal
column -s' ' -n -t datafile.txt | less -S
class Centipede(object):
def __init__(self):
self.legs = list()
self.stomach = list()
def __call__(self, val):
self.stomach.append(val)
class Centipede(object):
def __init__(self):
self.legs = list()
self.stomach = list()
def __call__(self, val):
self.stomach.append(val)
def __str__(self):
@mw44118
mw44118 / gist:c14d0a9e09b30ac28749
Created May 11, 2015 19:01
Cleveland Heights Levy votes
vim: set expandtab ts=4 sw=4 filetype=python fileencoding=utf8:
import re
# Data from
# http://boe.cuyahogacounty.us/pdf_boe/en-US/ElectionResults2015/May2015/05052015UnoffialResultsbyPrecinctTotal.HTM
raw = """
0022 CLEVELAND HEIGHTS -01-A 46 32 0 0
0023 CLEVELAND HEIGHTS -01-B 60 28 0 0
$ netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth3
@mw44118
mw44118 / slow query
Created February 20, 2015 19:46
slow query!
with current_config as
(
select *
from refractometer_config_history
where now()::timestamp without time zone <@ effective
)
select rmsh.sump_id, rr.refractometer_reading, current_config.*
from refractometer_readings rr
@mw44118
mw44118 / app.js
Last active August 29, 2015 14:09
can't get camera to open already-saved videos
self.pick_success = function (path_to_video) {
self.video_path(path_to_video);
};
self.pick_error = function (msg) {
navigator.notification.alert(msg);
};
self.pick_saved_video = function () {
@mw44118
mw44118 / ugmo.py
Created December 10, 2013 02:23
Silly example of defining a class inside another class
class A(object):
def __init__(self, f, mood):
self.f = f
self.mood = mood
def make_class(self):
class C(object):
@mw44118
mw44118 / gist:5807137
Created June 18, 2013 16:51
Wasted time on this syntax error
d1 = dict(
user_id=99,
display_name='Matt Wilson')
d2 = dict(
email_address='matt@tplus1.com',
**d1,)