Skip to content

Instantly share code, notes, and snippets.

View nathan-a-macleod's full-sized avatar
📚
Studying

Nathan MacLeod nathan-a-macleod

📚
Studying
View GitHub Profile
@ChaseIngebritson
ChaseIngebritson / tileToMesh.ts
Last active May 31, 2023 21:52
Convert a Mapbox RGB tile to a ThreeJS Mesh
import { PlaneGeometry, DoubleSide, MeshBasicMaterial, Mesh, TextureLoader } from 'three';
const MAPBOX_TOKEN = 'Your token';
async function tileToMesh(x: number, y: number, z: number) {
const url = `https://api.mapbox.com/v4/mapbox.terrain-rgb/${z}/${x}/${y}.pngraw?access_token=${MAPBOX_TOKEN}`;
const pixels = await this.getPixels(url);
const planeSize = Math.sqrt(pixels.length / 4);
@claymcleod
claymcleod / pycurses.py
Last active July 20, 2024 00:12
Python curses example
import sys,os
import curses
def draw_menu(stdscr):
k = 0
cursor_x = 0
cursor_y = 0
# Clear and refresh the screen for a blank canvas
stdscr.clear()
@payne92
payne92 / gist:11090057
Created April 19, 2014 16:49
getch() function to read single char from stdin, w/o waiting for newline (Windows and Unix)
# If Windows getch() available, use that. If not, use a
# Unix version.
try:
import msvcrt
getch = msvcrt.getch
except:
import sys, tty, termios
def _unix_getch():
"""Get a single character from stdin, Unix version"""