Skip to content

Instantly share code, notes, and snippets.

View jpwhitaker's full-sized avatar

JP Whitaker jpwhitaker

  • Aiea, HI
View GitHub Profile
@jpwhitaker
jpwhitaker / GLSL-Noise.md
Created October 7, 2023 07:06 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@jpwhitaker
jpwhitaker / postgresapp_unix_socket.md
Created June 15, 2021 21:37 — forked from matiaskorhonen/postgresapp_unix_socket.md
Setup Postgres.app to allow connections via unix sockets

These are instructions to setup Postgres.app to allow connections over unix sockets. These instructions were written for macOS Sierra (10.12) and Postgres.app 9.6.0

  1. Run Postgres.app once so that the configuration is initialized in ~/Library/Application Support/Postgres/var-9.6/
  2. Quit Postgres.app
  3. Open ~/Library/Application Support/Postgres/var-9.6/postgresql.conf in your favorite text editor
  4. Uncomment the line unix_socket_directories = '/tmp' and change it to unix_socket_directories = '/var/pgsql_socket,/tmp'
  5. Run sudo mkdir -p /var/pgsql_socket
  6. Run sudo chmod 770 /var/pgsql_socket
  7. Run sudo chown root:staff /var/pgsql_socket
@jpwhitaker
jpwhitaker / unsubscribe.js
Last active September 10, 2018 08:00
Tricky-ass unsubscribe
//returns a function used to unsubscribe the listener
const subscribe = (listener) => {
listeners.push(listener);
return () =>{
listeners = listeners.filter( l => l !== listener);
}
}
//for example
function hn_filter(/* terms1, terms2, ..., termsN, removeMisses */) {
var termSets = Array.prototype.slice.call(arguments),
removeMisses = typeof(termSets[termSets.length - 1]) === 'boolean' ? termSets.pop() : false,
haystack = document.querySelectorAll('span.comment');
return Array.prototype.slice.call(haystack).filter(function(post) {
var hit = termSets.reduce(function(result, terms) {
return terms.reduce(function(result, term) {
var index = post.innerHTML.search(new RegExp(term, 'i'));
if (index === -1) return result;
post.innerHTML = [