Skip to content

Instantly share code, notes, and snippets.

View argggg pandas.md

This is the story of how it took me about 3 hours to pull a key from a census data index into its own column.

The censusdata library returns dataframes that have an index object:

In [1]: import censusdata

In [2]: df = censusdata.download('acs5', 2015, censusdata.censusgeo([('state', '23'), ('county', '005'), ('block group', '*')]), [('C02003_001E')]).head()

In [3]: df
View main.go
package main
import (
"fmt"
"html/template"
"log"
"net/http"
"os"
)
View main.go
package main
// An extremely simple web application skeleton
import (
"fmt"
"log"
"net/http"
"os"
)
@llimllib
llimllib / hamming.md
Created Dec 28, 2020
One Man's View of Computer Science
View hamming.md

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

View notebook
#!/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 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