Skip to content

Instantly share code, notes, and snippets.

@greg76
greg76 / race.py
Created November 4, 2022 12:46
emojie animals racing in the terminal
View race.py
import os
import time
import random
animals = "🐅🐆🦓🦣🐘🦛🦏🐪🦒🦘🦬🐃🐂🐄🐎🐖🐏🦙🐐🦌🐕🐈🐓🐇🦝"
#animals = "🐶🐱🐭🐰🦊🐻🐼🦁🐯🐨🐻🐮"
width = os.get_terminal_size().columns - 2
pos = [width] * len(animals)
@greg76
greg76 / bootstrap.sh
Last active September 30, 2022 13:20 — forked from GrfxGuru/bootstrap_mac.sh
Bootstrap for setting up a new macOS machine
View bootstrap.sh
#!/usr/bin/env bash
#
# Bootstrap script for setting up a macOS machine
#
# Requires xcode and tools!
xcode-select -p || exit "XCode must be installed! (use the app store)"
echo "Starting bootstrapping"
@greg76
greg76 / panic.py
Created March 31, 2022 15:18
check the time of the last kernel panic on you mac
View panic.py
import os
import datetime
with os.popen("nvram -p") as out:
ts_line = next((line for line in out.readlines() if line.startswith("panicmedic-timestamps")), None)
if ts_line:
ts_hex = ts_line.split("\t")[-1]
ts_int = int(ts_hex, 16)
ts = datetime.datetime.fromtimestamp(ts_int // 1000000)
print(f"Last kernel panic: {ts}")
@greg76
greg76 / wordle.py
Last active February 14, 2022 09:42
what are the best words to start wordle with?
View wordle.py
import collections
with open("words.txt") as f:
# let's read the words from the file, but ignore anything that ends with s
# just to remove plurals
words = [line.strip() for line in f.read().splitlines() if line[4] != "s"]
# how often the different letter occur?
occurances = collections.Counter()
for word in words:
@greg76
greg76 / homebrew-top.py
Last active September 14, 2021 18:09
fastest growing homebrew packages
View homebrew-top.py
import locale
import requests
import tabulate
locale.setlocale(locale.LC_ALL, "en_US")
# available snapshots: 30, 90, 365 days
data_ranges = {"new": 30, "old": 90}
@greg76
greg76 / tilted-chessboard.py
Last active May 18, 2020 06:02
recreated a tiny effect in python. for the lulz.
View tilted-chessboard.py
import pyxel
class Intro:
def __init__(self):
pyxel.init(160, 120, caption="Greg was here")
self.timer = 0
pyxel.run(self.update, self.draw)
def update(self):
@greg76
greg76 / emoji_terrain.py
Created March 21, 2020 22:18
terrain generation
View emoji_terrain.py
import random
import math
size = (40, 25)
field_types = "🏔⛰🌲🌳🌴🏜🌊"
def voronoi_map():
no_seeds = 20
seeds = [
{
@greg76
greg76 / matrix.py
Last active January 25, 2020 16:09
simple code rain effect from the movie Matrix
View matrix.py
import random
import pyxel
class Matrix:
def __init__(self):
pyxel.init(160, 120, caption="there's no spoon")
self.loop = 0
self.width = pyxel.width // 4
@greg76
greg76 / xmas.py
Last active December 28, 2019 21:52
simple xmas tree based on hackernews article
View xmas.py
#!/usr/bin/env python3
import math
import pyxel
class Intro:
def __init__(self):
pyxel.init(160, 120, caption="xmas")
self.xm = pyxel.width // 2
@greg76
greg76 / scroll.py
Last active May 4, 2020 10:11
old school sinus text demoscene effect for starting experimenting with pyxel retro game engine
View scroll.py
import math
import random
import pyxel
class Intro:
def __init__(self):
pyxel.init(160, 120, caption="Twin Sectors")
self.amplitude = 10