Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am paradoor on github.
  • I am fopdudel (https://keybase.io/fopdudel) on keybase.
  • I have a public key ASDlYjqPzMc98cfhaVwks5IUU7YAyVY_krCChcuo4xCGBgo

To claim this, I am signing this object:

@revsuine
revsuine / monty_hall.py
Created February 22, 2019 19:43
A demonstration of the Monty Hall problem.
#!/usr/bin/python3
"""A demonstration of the Monty Hall problem."""
import argparse
import random
import json
# n is the number of times you switch, and also the number of times you don't switch
# accuracy increases as n increases
@revsuine
revsuine / get_startswith_substring.py
Last active April 18, 2018 15:01
Simple helper function to return what substring a string starts with.
def get_startswith_substring(string: str, substrings):
"""
Gets the substring that another string starts with.
:param string: The larger string, eg "The quick brown fox jumps over the lazy dog."
:param substrings: The list or tuple of substrings you want to check against, e.g. ["foo", "bar", "Th"]
:return: If found, a string (that comes from substrings). If not found, None. e.g. "Th"
:raises: TypeError if substrings is not a list or tuple.
"""
if not (isinstance(substrings, list) or isinstance(substrings, tuple)):
raise TypeError
@revsuine
revsuine / .bashrc
Last active February 22, 2019 19:46
Add an easy calculator to bash. Append this to `~/.bashrc`.
# make `echo "$calculation" | bc` much easier to type.
# if `calc` is already in use, feel free to change it to something else.
calc () { echo "$@" | bc; }