Skip to content

Instantly share code, notes, and snippets.

View timbledum's full-sized avatar

Marcus Croucher timbledum

  • Auckland, New Zealand
View GitHub Profile
@timbledum
timbledum / tictactoe.py
Last active August 22, 2018 10:09
Response to tic-tac-toe gist.
# Reponse to gist here: https://gist.github.com/Vanyali/b72e9083175794aecc9c718ee40c4205
from itertools import cycle
WIN_CONDITIONS = [
(1, 2, 3),
(4, 5, 6),
(7, 8, 9),
(1, 4, 7),
@timbledum
timbledum / teamscorer.py
Created August 31, 2018 08:00
Processing team scores
>>> from collections import defaultdict
>>> data = """Lions 3, Snakes 3
... Tarantulas 1, FC Awesome 0
... Lions 1, FC Awesome 1
... Tarantulas 3, Snakes 1
... Lions 4, Grouches 0"""
>>> data_list = data.splitlines()
@timbledum
timbledum / renamer.py
Created September 26, 2018 07:48
Renamer
from pathlib import Path
import sys
import easygui
def main():
choices = easygui.multenterbox(
msg="This tool replaces part of the file name for all files and folders in the current folder.",
title="Renamer",
fields=["Old text", "New text"],
values=["(e.g., Aug)", "(e.g., Sep)"],
# coding: utf-8
"""
A module to generate ############### forms given
a template and a spreadsheet.
This script:
1. Connects to a spreadsheet
2. Populates a dictionary with information from the spreadsheet/the entity
3. Populates template files with the information above
@timbledum
timbledum / sample.py
Last active November 4, 2018 02:10
Sample of using new pyxel file format
import pyxel
pyxel.init(128, 128)
resources = pyxel.load("sample.pyxel")
data = {}
data["x"] = 0
data["y"] = 0
@timbledum
timbledum / wizard.py
Created February 14, 2019 02:26
Wizard example
class Weapon:
def __init__(self, types):
self.types = types
def damageDealt(self):
if self.types == "dagger":
damage = 4
elif self.types == "axe":
damage = 6
elif self.types == "staff":
#! /usr/bin/python3
from PyQt5.QtWidgets import (QHBoxLayout, QVBoxLayout,
QComboBox, QCheckBox, QLabel,
QPushButton, QTextEdit, QScrollArea,)
from ..math import charactergen
class Tab:
#! /usr/bin/python3
import sys
from PyQt5.QtWidgets import (QApplication, QWidget, QMainWindow,
QVBoxLayout, QTabWidget)
from .gui import npc, places, items, quest, monsterbuilder
class App(QMainWindow):
def __init__(self):
data = {'Account balances': [{'2008-04-04': 252216},
{'2010-05-17': 3619948},
{'2010-10-25': 590954},
{'2014-10-01': 568340},
{'2016-09-04': 2424784},
{'2018-08-25': 261463}],
'Address book contacts': [{'2017-12-05': 20580060}],
'Age groups': [{'2014-02-17': 37784}, {'2017-12-31': 84011}],
'Ages': [{'2014-09-01': 1287073}],
'Apps installed on devices': [{'2017-12-05': 20580060}],
SIZES = {"s": "Small", "m": "Medium", "l": "Large"}
PRICES = {"s": 1.5, "m": 1.75, "l": 2.0}
SWEETENED = {"s": "Sweetened", "u": "Unsweetened"}
class Beverage:
name = "Beverage"
def __init__(self, size, price):
self.size = size
self.price = price