Skip to content

Instantly share code, notes, and snippets.

View johnniehard's full-sized avatar
🚀
Making it happen!

Johnnie Hård johnniehard

🚀
Making it happen!
View GitHub Profile
@danvk
danvk / sprite-custom-layer.tsx
Created October 1, 2019 18:00
Mapbox custom layer which renders multiple models in a THREE.js scene
import MapboxGL, {LngLatLike, MercatorCoordinate} from 'mapbox-gl';
import React, {useEffect, useState} from 'react';
import {withMap} from 'react-mapbox-gl/lib-esm/context';
import {FeatureCollection} from 'geojson';
import * as THREE from 'three';
import {GLTFLoader} from 'three/examples/jsm/loaders/GLTFLoader';
export interface SpritePaint {
gltfPath: string;
@hypercompetent
hypercompetent / nmToRGB.js
Created April 17, 2019 20:36
JavaScript nm to RGB color function
nmToRGB: function(wavelength){
var Gamma = 0.80,
IntensityMax = 255,
factor, red, green, blue;
if((wavelength >= 380) && (wavelength<440)){
red = -(wavelength - 440) / (440 - 380);
green = 0.0;
blue = 1.0;
}else if((wavelength >= 440) && (wavelength<490)){
red = 0.0;
@mwfogleman
mwfogleman / gtd_basb_templates.org
Last active December 14, 2023 19:50
GTD/BASB Templates for Emacs and Org-Mode
@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
@perrygeo
perrygeo / Dockerfile
Last active February 27, 2023 12:00
Minimal debian image with Python 3.6 and geo python tools
FROM python:3.6-slim-stretch
ADD requirements.txt /tmp/requirements.txt
RUN apt-get update && \
apt-get install -y \
build-essential \
make \
gcc \
locales \
@koreyou
koreyou / shuf
Created January 6, 2018 09:31
Linux shuf command with seed option
#!/bin/bash
# seeding adopted from https://stackoverflow.com/a/41962458/7820599
get_seeded_random()
{
seed="$1";
openssl enc -aes-256-ctr -pass pass:"$seed" -nosalt \
</dev/zero 2>/dev/null;
}
@budRich
budRich / README.md
Last active October 23, 2021 17:06
zen mode in i3wm

2021.10.23

Make windows floating before moving them to origin workspace.

2021.10.19

Use workspace name when appropriate.

2021.10.18

@jkohlin
jkohlin / index.html
Created June 28, 2017 10:58
Frequency and amplitude visualiser using web audio API
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Web audio API</title>
<style>
</style>
</head>
<body>
<button id="play-btn" style="display:none;">play/pause</button>
@oscarmorrison
oscarmorrison / d3Importer.js
Last active March 6, 2024 12:50
Modularly import only the D3.js modules you require
import { line, curve, curveCatmullRom } from "d3-shape";
import { scaleTime, scaleLinear } from "d3-scale";
import { axisBottom, axisLeft } from 'd3-axis';
import { timeParse, isoFormat } from "d3-time-format";
import { select } from "d3-selection";
import { extent, max, min } from "d3-array";
export default {
line: line,
scaleTime: scaleTime,
@diegopacheco
diegopacheco / pyaudio-ubuntu-install.md
Last active March 28, 2024 21:33
How to Install pyaudio ubuntu 16.04 LTS?
sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
sudo apt-get install ffmpeg libav-tools
sudo pip install pyaudio