Skip to content

Instantly share code, notes, and snippets.

View AnthonyBriggs's full-sized avatar

Anthony Briggs AnthonyBriggs

  • Melbourne, Australia
View GitHub Profile
@AnthonyBriggs
AnthonyBriggs / project_names.py
Last active November 3, 2024 23:48
Project codename generator
#!/usr/bin/env python3
"""
Project naming scheme (roughly; funny trumps the rules):
<weird/funny animal> + <word which should be rude but isn't>
Useful if management / fellow developers are taking themselves too seriously."""
import random
directive = """ENGAGE COMMENCE EXECUTE DEPLOY BEGIN ACTIVATE INITIATE SECURE UNDERTAKE LAUNCH """.split()
@AnthonyBriggs
AnthonyBriggs / alien.py
Created October 8, 2018 03:33
Script that can create a PygameZero executable with Pyinstaller
"""
Mostly-working pyinstaller hack to get a PyGame zero executable
All data files included, and --onefile will compress everything down to ~15MB
Note that Pyinstaller moves everything to an internal directory, sys._MEIPASS,
and runs from that, so we have to explicitly use that path when loading the
game file.
@AnthonyBriggs
AnthonyBriggs / joystick_demo.py
Created September 10, 2018 13:32
Mu/PygameZero/Kenney.nl demo code
"""
Demo code for Mu/PygameZero using kenney.nl graphics.
There's a short video demo at https://www.youtube.com/watch?v=b2IPNCJtUL4.
NOTE: this relies on two patches to Mu which aren't yet in
the main PgZero repository, one which adds joystick
support, and another which adds a flip property to
the Actor class.
"""
@AnthonyBriggs
AnthonyBriggs / mu_joystick_test.py
Created August 28, 2018 23:55
Sample script to get joystick input from my version of pgzero
# Write your code here :-)
# Pygame -> pgzero joystick hackery :)
import pygame
import pgzero
pygame.joystick.init()
joysticks = [pygame.joystick.Joystick(x) for x in range(pygame.joystick.get_count())]
inited = [j.init() for j in joysticks]
print(joysticks)
@AnthonyBriggs
AnthonyBriggs / shakespeare.py
Created June 7, 2018 05:23
Write an Shakespeare!
"""Write an Shakespeare!"""
### What are these words call'd that stands hard by?
try:
words = open('shakespeare.txt').read().split()
print(len(words), "total words in shakespeare.txt")
except FileNotFoundError:
print("No, hath not? Rosalind lacks, then, the shakespeare.txt")
@AnthonyBriggs
AnthonyBriggs / my_turtle.py
Created January 30, 2018 02:49
A fractal turtle L-system thing
"""Fancy turtle L-system thing
Messing around at lunchtime :)
Inspired by https://bitaesthetics.com/posts/fractal-generation-with-l-systems.html"""
# Maybe this runs under Python 2? Who knows? Not sure what the turtle
# changes between 2 and 3 are
from __future__ import print_function
"""Script to mass-convert all the Python 2 files in a directory to Python 3."""
import os
import sys
try:
target = sys.argv[1]
if target.endswith('"'):
target = target[:-1]
@AnthonyBriggs
AnthonyBriggs / pycodestyle_errors.py
Last active July 10, 2017 13:26
Rough code to scrape pycodestyle for errors and output .rst-ish
"""Rough script to scrape pycodestyle.py and intro.rst for error codes and descriptions, then generate something .rst-ish"""
import collections
import re
import pycodestyle
ErrorCode = collections.namedtuple("ErrorCode", field_names=("code", "short_msg", "long_msg"))
@AnthonyBriggs
AnthonyBriggs / clicka.sh
Created October 31, 2014 11:03
Useful xmacro script for *clicker games
#!/bin/bash
# sudo apt-get install xmacro
# Run this in a window alongside your browser,
# then you have 2 seconds to quickly mouse over
sleep 2;
for (( ;; ))
do