Skip to content

Instantly share code, notes, and snippets.

View bcamper's full-sized avatar

Brett Camper bcamper

View GitHub Profile
@thisisaaronland
thisisaaronland / gist:55061c8a4c0f0618be58531436540002
Created July 27, 2023 21:53
Exporting Overture places parquet databases to GeoJSONSeq files
#!/bin/sh
# This assumes that you have installed duckdb and that both /usr/local/data/overture/places and
# /usr/local/data/overture/places-geojson exist and that the Overture "places" parquet files have
# been downloaded in to the former. See also: https://github.com/OvertureMaps/data#3-duckdb-sql
for f in /usr/local/data/overture/places/*
do
f=`basename $f`
echo "process $f"
@kinjalkishor
kinjalkishor / game_loops.cpp
Created February 11, 2023 03:07
Game Loops
//----------------------
// Gaffer On Games
// https://gafferongames.com/post/fix_your_timestep/
//----------------------
// Fixed delta time
// If delta time match the display refresh rate, and you can ensure that your update loop takes less than one frame worth of real time.
double t = 0.0;
double dt = 1.0 / 60.0;
while (!quit) {
@torcado194
torcado194 / cleanEdge-shadertoy.glsl
Last active May 31, 2024 11:23
cleanEdge, a pixel art upscaling algorithm for clean rotations
/*** MIT LICENSE
Copyright (c) 2022 torcado
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
@bgolus
bgolus / MatCapTechniques.shader
Created January 29, 2022 00:37
Showing multiple matcap techniques, including a proposed improved method that's no more expensive than the usual fix if you're starting with the world position and world normal.
Shader "Unlit/MatCap Techniques"
{
Properties
{
[NoScaleOffset] _MatCap ("MatCap", 2D) = "white" {}
[KeywordEnum(ViewSpaceNormal, ViewDirectionCross, ViewDirectionAligned)] _MatCapType ("Matcap UV Type", Float) = 2
}
SubShader
{
Tags { "RenderType"="Opaque" }
#!/bin/bash
#
# A script that takes a Twitter data archive, which is produced as a
# set of JavaScript files (different from the regular archive, which
# is CSV and HTML), and converts the `tweet.js` file, which contains
# all of the tweets, into tractable JSON, one tweet per line. It then
# inserts /that/ into a SQLite3 database, and extracts a simple
# relational table of tweets from the JSON. Finally, it runs datasette
# on the resulting database to allow you to explore.
@veltman
veltman / tiles.md
Last active September 27, 2019 22:12
Making a big image zoomable

Making a big image zoomable

When you have a giant image and you want to make it easy to pan and zoom without downloading the whole 50MB image into someone's browser, a nice workaround is to cut that image into tiles at different zoom levels and view it as it were a map. An example where I've used this technique is The "Snowpiercer" Scenario.

One way to cut your big image into the requisite tiles is with gdal2tiles.py.

Alternatively, this Node script will do the cutting after you install node-canvas and mkdirp:

const fs = require("fs"),
@iandees
iandees / README.md
Last active August 22, 2021 21:35
Download and process Bing Buildings into Census tracts.

These are my notes for taking the Microsoft US Building Footprints and splitting them into more manageable chunks based on US Census Tracts.

All of this happened on an m5.xlarge in AWS and used up about ~300GB of EBS over the course of a few hours.

  1. Make a filesystem on the EBS volume and mount it:

    sudo mkfs.xfs /dev/nvme1n1
    mount /dev/nvme1n1 /mnt
    
@chriswhong
chriswhong / gist:762ceac7fb8a1420e7e7adceb770b707
Last active March 3, 2022 09:01
Using ST_AsMVT() and ST_AsMVTGeom() in express to build a vector tile endpoint
/* GET /tiles/:z/:x/:y.mvt */
/* Retreive a vector tile by tileid */
router.get('/tiles/:z/:x/:y.mvt', async (req, res) => {
const { z, x, y } = req.params;
// calculate the bounding polygon for this tile
const bbox = mercator.bbox(x, y, z, false);
// Query the database, using ST_AsMVTGeom() to clip the geometries
// Wrap the whole query with ST_AsMVT(), which will create a protocol buffer
@tdierks
tdierks / modem-speed.py
Created November 28, 2017 18:23
A python script to emulate the bandwidth of a modem at certain speed.
#!/usr/bin/python -u
# Use: modem-speed.py [baud, default 1200]
import sys
from time import sleep
baud = len(sys.argv) > 1 and int(sys.argv[1]) or 1200
cps = baud/10.0 # 10 baud per octet at 8n1
while True: