Skip to content

Instantly share code, notes, and snippets.

@bramp
bramp / fetch.py
Created May 30, 2024 18:49
A program that fetches past winning numbers and draw results from www.calottery.com
# A program that fetches past winning numbers and draw results from www.calottery.com
# # Setup
# python3 -m venv .venv
# source .venv/bin/activate
# (venv) $ python -m pip install requests requests_cache dotted-notation
#
# # Run
# python fetch.py
#
@bramp
bramp / mac-setup.sh
Last active April 26, 2026 18:58
My quick mac setup
# My Mac Setup
# Using a lot of notes from https://www.robinwieruch.de/mac-setup-web-development/
# Enable intel2arm silcon
sudo softwareupdate --install-rosetta --agree-to-license
# Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install brew packages
@bramp
bramp / safe_cleanup.sh
Last active April 4, 2026 01:32
macOS safe cleanup script (30-day grace period)
#!/bin/bash
# Author: Andrew Brampton (bramp.net)
# Link: https://gist.github.com/bramp/ca45fe6b64fbc7ff398022dbc2e35eb7
# safe_cleanup.sh - Reclaims disk space by clearing files older than 30 days.
DAYS=30
show_space() {
echo "Filesystem Size Used Avail Capacity Mounted on"
df -h / /System/Volumes/Data | tail -n +2
@bramp
bramp / ucode.py
Created October 13, 2011 23:46
Prints some simple information about ucode firmwares such as those used by Intel Wifi cards
#!/usr/bin/python
# Prints some simple information about ucode firmwares
# such as those used by Intel Wifi cards
#
# Version 1.0 Jan 2011
# by Andrew Brampton
#
# Example
# ./ucode.py /lib/firmware/*.ucode
#
@bramp
bramp / make.py
Last active July 2, 2023 18:34
Creates a model of a 3D Hilbert curve, suitable for 3D printing.
#!/usr/bin/env python3
# Creates a model of a 3D Hilbert curve, suitable for 3D printing.
# by Andrew Brampton (bramp.net) 2023
# See https://www.printables.com/model/518431
#
# Usage:
# python3 make.py 4 4 4 --voxelizer voxelmap --spacing 3
# python3 make.py 4 4 4 --voxelizer trimesh --spacing 2
#
@bramp
bramp / 401k.dot
Created November 14, 2017 05:48
401k/IRA flow chart
digraph "401k" {
label = "Assumptions - 2018 - Age < 50 - Single - Income > $135k - 50% company match of 401(k)\n";
"Pay Cheque (Pre-tax)" -> "Pre-tax 401(k)" [ label = "Max $18.5k*" ];
"Pay Cheque (After-tax)" -> "Roth 401(k)" [ label = "Max $18.5k*" ];
"Pay Cheque (After-tax)" -> "After-tax 401(k)" [ label = "Max $27.25k" ];
"Pay Cheque (After-tax)" -> "Bank Account (After-tax)";
@bramp
bramp / mysql_simple_test.go
Created October 1, 2017 19:21
Example of a failing ANTLR MySQL Parser
/**
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@bramp
bramp / CaseChangingStream.go
Created September 28, 2017 14:20
Example antlr.CharStream that changes the case of the input.
/*
Copyright 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@bramp
bramp / clip.class.php
Created November 26, 2011 18:05
PHP Polygon Clipping using the Sutherland-Hodgman algorithm
<?php
/**
* Polygon Clipping
* @author Andrew Brampton me <at> bramp <dot> net
* @url http://bramp.net/blog/2011/11/php-polygon-clipper-using-the-sutherland-hodgman-algorithm/
*
* Based on the Sutherland-Hodgman algorithm (1974).
* http://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm
*
* This approache assumes four clip edges (the bounding box).
@bramp
bramp / turn-on-github-ssl.py
Created June 9, 2016 03:24
Prints a list of all owned repositories with pages.
#!/usr/bin/env python
# Prints a list of all owned repositories with pages.
# by Andrew Brampton 2016 https://bramp.net
#
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#