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 random | |
cars, donkeys = 0, 0 | |
trials = 10000 | |
doors = ['a', 'b', 'c'] | |
for i in range(trials): | |
# place the car behind a random door | |
car_door = random.choice(doors) | |
# choose first door at random | |
first_choice = random.choice(doors) |
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
http://blog.sadphaeton.com/2009/01/20/python-development-windows-part-2-installing-easyinstallcould-be-easier.html |
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 httplib2 | |
import StringIO | |
from PIL import Image | |
def get_tiles(): | |
h = httplib2.Http('.cache') | |
base = 'http://www.jcu.edu.au/maps/townsville/interactive/mapimages/' | |
# get lvl 16 zoom tiles | |
for x in range(59482, 59486): | |
for y in range(36353,36357): |
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
// an array of JButtons | |
JButton[][] buttons = new JButton[4][4]; | |
/* actually creates each of the sixteen JButton objects and sets | |
each button's text to look something like "Button [1][2]" (depending on row and column) */ | |
for (int i=0; i < buttons.length; i++) { | |
for (int j=0; j < buttons[i].length; j++) { | |
buttons[i][j] = new JButton("Button [" + i + "][" + j + "]"); | |
} | |
} |
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
// an array of JButtons | |
JButton[][] buttons = new JButton[4][4]; | |
/* actually creates each of the sixteen JButton objects and sets | |
each button's text to look something like "Button [1][2]" (depending on row and column) */ | |
for (int i=0; i < buttons.length; i++) { | |
for (int j=0; j < buttons[i].length; j++) { | |
buttons[i][j] = new JButton("Button [" + i + "][" + j + "]"); | |
} | |
} |
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
// prints out something like "Apple 27 (GRANNY_SMITH, 3)" | |
public String toString() { | |
return String.format("Apple %d (%s, %s)",size,type,batchNumber); | |
} | |
public static void main(String[] args) { | |
Random random = new Random(); // this is the line missing from the workshop pdf | |
final int SIZE = random.nextInt(5) + 1; | |
Apple[] apples = new Apple[SIZE]; // a randomly sized apples array | |
for (int i = 0; i < SIZE; ++i) { |
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
# some button class somewhere that you didn't write. | |
class Button(): | |
def __init__(self,functionToExecuteOnClick): | |
self.clickFunction = functionToExecuteOnClick | |
# does a bunch of other cool stuff to display button - you were too slack to write this code, that's why you're using their button in the first place. | |
# pretend this is private. other classes shouldn't be calling this method |
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
#!/bin/bash | |
# Run from terminal like enter-caps ./wireshark | |
export PS1="#$PS1" | |
export WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1 | |
caps=cap_net_admin,cap_net_raw | |
sudo -E capsh --keep=1 --caps="cap_setuid,cap_setgid,cap_setpcap+ep $caps+eip" --user=[my_hardcoded_username] --addamb="$caps" -- -c "$@" | |
echo "...Exiting enter-caps" |