Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"html/template"
"log"
"net/http"
"os"
)
package main
// An extremely simple web application skeleton
import (
"fmt"
"log"
"net/http"
"os"
)
@llimllib
llimllib / hamming.md
Created December 28, 2020 17:56
One Man's View of Computer Science

Richard W. Hamming

January 1969

One Man's View of Computer Science

Abstract

A number of observations and comments are directed toward suggesting that more than the usual engineering flavor be given to computer science. The engineering

#!/usr/bin/env bash
# assume that if an `nb` dir (presumably a virtualenv) exists, then we don't
# need to do any of the time-consuming stuff
if [ ! -d nb ]; then
python -mvenv nb
# # ipykernel is required for bash_kernel \
nb/bin/pip install \
bash_kernel \
ipykernel \
@llimllib
llimllib / render_shapefile.bash
Last active November 18, 2020 19:22
Render a shapefile to a png and display it in your terminal, in one command
# 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.
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(
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(
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,
#!/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
#!/usr/bin/env python
import math
import pyglet
from pyglet import shapes
WIDTH = 960
HEIGHT = 960
MARGIN = 100