Skip to content

Instantly share code, notes, and snippets.

Avatar

Anthony Briggs AnthonyBriggs

  • Melbourne, Australia
View GitHub Profile
@AnthonyBriggs
AnthonyBriggs / project_names.py
Last active Jan 25, 2021
Project codename generator
View project_names.py
#!/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
thing = """PROJECT OPERATION PLAN PROGRAM DIRECTIVE ASSIGNMENT OBJECTIVE INCIDENT SCENARIO""".split()
@AnthonyBriggs
AnthonyBriggs / alien.py
Created Oct 8, 2018
Script that can create a PygameZero executable with Pyinstaller
View alien.py
"""
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 Sep 10, 2018
Mu/PygameZero/Kenney.nl demo code
View joystick_demo.py
"""
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 Aug 28, 2018
Sample script to get joystick input from my version of pgzero
View mu_joystick_test.py
# 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)
View shakespeare.py
"""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 Jan 30, 2018
A fractal turtle L-system thing
View my_turtle.py
"""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
View convert_2to3.py
"""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 Jul 10, 2017
Rough code to scrape pycodestyle for errors and output .rst-ish
View pycodestyle_errors.py
"""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 Oct 31, 2014
Useful xmacro script for *clicker games
View clicka.sh
#!/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