Skip to content

Instantly share code, notes, and snippets.

@greg76
greg76 / pocketmine.sh
Last active March 26, 2020 10:54
simple shell script to run pocketmine as a service/daemon
#!/bin/sh
### BEGIN INIT INFO
# Provides: pocketmine
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@greg76
greg76 / display.py
Last active March 14, 2018 22:06
simple script to display either the arguments or the first lines of whatever is being piped into it to an SSD1306 driven oled screen
#!/usr/bin/python3
import sys
import Adafruit_GPIO.SPI as SPI
import Adafruit_SSD1306
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
disp = Adafruit_SSD1306.SSD1306_128_32(rst=None)
@greg76
greg76 / NASM.sublime-build
Created September 19, 2018 20:26
Build and run x86 asm files on MacOS with NASM and DosBox
{
"shell": true,
"env": {
"DOSBOX": "/Applications/DOSBox.app/Contents/MacOS/DOSBox"
},
"cmd": ["nasm -f bin ${file} -o ${file_base_name}.com && \\$DOSBOX -c \"MOUNT C ${file_path}\" ${file_base_name}.com"],
"file_regex": "^(.+):([0-9]+)()?: error: (.*)$",
"working_dir": "${file_path}",
"selector": "source.assembly",
}
@greg76
greg76 / aws-polly.py
Created November 9, 2018 13:13
simple example on how to "text-to-speech" with amazon's polly service
#!/usr/bin/env python3
from boto3 import client
from contextlib import closing
polly = client("polly", 'us-east-1')
voice = 'Brian'
response = polly.synthesize_speech(
Text='''Imagine how your bullet points turn into presenter notes!
@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
import math
import random
import pyxel
class Intro:
def __init__(self):
pyxel.init(160, 120, caption="Twin Sectors")
self.amplitude = 10
@greg76
greg76 / xmas.py
Last active December 28, 2019 21:52
simple xmas tree based on hackernews article
#!/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 / matrix.py
Last active January 25, 2020 16:09
simple code rain effect from the movie Matrix
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 / emoji_terrain.py
Created March 21, 2020 22:18
terrain generation
import random
import math
size = (40, 25)
field_types = "🏔⛰🌲🌳🌴🏜🌊"
def voronoi_map():
no_seeds = 20
seeds = [
{
@greg76
greg76 / tilted-chessboard.py
Last active May 18, 2020 06:02
recreated a tiny effect in python. for the lulz.
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 / homebrew-top.py
Last active September 14, 2021 18:09
fastest growing homebrew packages
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}