Instantly share code, notes, and snippets.

# Dave Britten dave-britten

Last active September 1, 2015 13:05
Calculate a probability distribution of totals acquired from rolling an arbitrary number of dice, each with an arbitrary configuration of non-negative, integer face values.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 import re dice = [] #Input dice as polynomial coefficients print "Enter face values as non-negative integers, separated by spaces, commas, or semicolons. (e.g. \"1,2;3 4 5 6\")" while True: rawdie = [] #List of face values qty = 1 #Quantity of a single die spec inp = raw_input("Die " + str(len(dice) + 1) + "? ")
Created September 16, 2015 13:48
PYUITest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #Attempt to load a .pyui file and generate code that would produce the same results. #Note: this doesn't actually work yet. from __future__ import print_function infilename = raw_input("Input File?") #infilename = "RegexSandbox.pyui" outfilename = infilename + ".py" f = open(infilename, "r")
Last active August 4, 2017 11:03
Select and resize an image from iOS device's photo library. (Pythonista)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #Gist ID: 9951701907ed328218dd import console import photos from PIL import Image from PIL.ExifTags import TAGS def adjust(dim, newdim): newdim = newdim.strip() try: if newdim[-1] == "%":
Created October 1, 2018 22:35
Compares group membership of 2 or more users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 Function Compare-ADGroupMembership { [CmdletBinding()] Param ( [Parameter(Mandatory=\$true,ValueFromPipeline=\$true)] [Alias('Name')] [string[]]\$Username ) BEGIN { \$groups = @{}