Skip to content

Instantly share code, notes, and snippets.

@llimllib
llimllib / render_shapefile.bash
Last active Nov 18, 2020
Render a shapefile to a png and display it in your terminal, in one command
View render_shapefile.bash
# make a temporary directory and push it on to the stack
tmp=$(mktemp -d); pushd $tmp && \
# get a US map at 20m resolution and unzip it
curl -s https://www2.census.gov/geo/tiger/GENZ2018/shp/cb_2018_us_region_20m.zip -o us.zip && \
unzip -q us.zip && \
# rasterize the map's only layer, using the `ALAND` feature. Restrict the
# bounding box (-te) to the continental US, because the map includes Alaska
# and Hawaii and Guam, and we're not going to bother with those here
# (sorry!). -ts sets the output size to 1200x800, then we give the input and
# output files.
View a.py
import pyglet
class AWindow(pyglet.window.Window):
def __init__(self):
super(AWindow, self).__init__(100, 100)
self.batch = pyglet.graphics.Batch()
self.circle = pyglet.shapes.Circle(
View a.py
import pyglet
class AWindow(pyglet.window.Window):
def __init__(self):
super(AWindow, self).__init__(100, 100)
self.batch = pyglet.graphics.Batch()
self.circle = pyglet.shapes.Circle(
View a.py
import pyglet
window = pyglet.window.Window()
batch = pyglet.graphics.Batch()
label = pyglet.text.Label(
"Hello, world",
font_name="Times New Roman",
font_size=36,
x=window.width // 2,
y=window.height // 2,
View breakout.py
#!/usr/bin/env python
from enum import Enum
import math
import pyglet
from pyglet import event
from pyglet import shapes
from pyglet.window import key
# * lose game when ball hits bottom
# * change angle when it hits the paddle
View move.py
#!/usr/bin/env python
import math
import pyglet
from pyglet import shapes
WIDTH = 960
HEIGHT = 960
MARGIN = 100
View ball.py
#!/usr/bin/env python
import pyglet
from pyglet import shapes
WIDTH = 960
HEIGHT = 540
RED = (255, 0, 0)
window = pyglet.window.Window(WIDTH, HEIGHT)
@llimllib
llimllib / padcolors.py
Last active Nov 10, 2020
Setting pad colors on the Novation LaunchKey Mini MK3
View padcolors.py
# This file demonstrates how to use midi codes to control the color of the
# keypads on a Novation LaunchKey mini; There is no official documentation of
# it as far as I can tell
#
# the LaunchKey MK2 Programmer's guide is useful, though not accurate to
# details on the MK3 mini:
# https://customer.novationmusic.com/sites/customer/files/novation/downloads/10535/launchkey-mk2-programmers-reference-guide.pdf
import random
import time
@llimllib
llimllib / volume.lua
Last active Jul 7, 2020
A script to use the first knob on my novation keyboard to control my mac's volume
View volume.lua
-- This is a hammerspoon (http://www.hammerspoon.org/) script to hook the
-- volume knob on my keyboard up to my system's volume control
-- https://easings.net/ is great for easing functions
-- I tried easeInExpo, but it was too sharp (return 2 ^ (10 * x - 10))
-- experimentation suggested cubic was the most pleasant. Linear was expectedly
-- awful
function easeIn(x)
return x * x * x
end
View installvoid.sh
# https://voidlinux.org/usage/xbps/ is a handy site for docs that isn't linked
# from the docs page, for whatever reason. Gives good xbps-* examples
# install non-free repository:
sudo xbps-install void-repo-nonfree
# update the system; all installs failed before this:
sudo xbps-install -Su
# xbps is hard to type. Add these aliases to your bashrc if xbps-install is
You can’t perform that action at this time.