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 boto3 | |
# Generated through IAM | |
aws_access_key_id = '' | |
aws_secret_access_key = '' | |
region_name = 'us-west-2' | |
sns = boto3.client('sns', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, region_name=region_name) | |
# Number including region code e.g. +44 for UK numbers |
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
def make_registrar(): | |
registry = {} | |
def registrar(func): | |
registry[func.__name__] = func | |
def wrapper(*args, **kwargs): | |
# Note - Modify function here | |
return func(*args, **kwargs) | |
return wrapper |
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
void OnGUI() | |
{ | |
const int crossHairWidth = 10; | |
const int crossHairHeight = 10; | |
GUI.Box(new Rect(Screen.width/2 - crossHairWidth/2, Screen.height/2 - crossHairHeight/2, crossHairWidth, crossHairHeight), ""); | |
} |
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 | |
switch_choice = 0 | |
stay_choice = 0 | |
samples = 100000 | |
for i in range(samples): | |
selected_door = random.randint(0, 2) | |
correct_door = random.randint(0, 2) | |
if selected_door == correct_door: |
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
from openpyxl import load_workbook | |
workbook = load_workbook('data.xlsx') | |
sheets = workbook.get_sheet_names() | |
# Read first sheet | |
worksheet = workbook.get_sheet_by_name(sheets[0]) | |
for row in worksheet.iter_rows(): | |
for cell in row: | |
# Print out all values that belong to the cell object |
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
// This code will automatically save the current canvas as a .png file. | |
// Its useful as it can be placed in a loop to grab multiple canvas frames, I use it to create thumbnail gifs for my blog | |
// Only seems to work with Chrome | |
// Get the canvas | |
var canvas = document.getElementById("canvas"); | |
// Convert the canvas to data | |
var image = canvas.toDataURL(); | |
// Create a link | |
var aDownloadLink = document.createElement('a'); |
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 math | |
import random | |
count = 0 | |
n = 100000 | |
for i in range(n): | |
x_pos = random.uniform(0, 1) | |
y_pos = random.uniform(0, 1) | |
if x_pos**2 + y_pos**2 <= 1.0: |