Skip to content

Instantly share code, notes, and snippets.

// http://www.iquilezles.org/www/articles/palettes/palettes.htm
// to see this function graphed out go to: https://www.desmos.com/calculator/18rq4ybrru
vec3 cosPalette( float t , vec3 brightness, vec3 contrast, vec3 osc, vec3 phase)
{
return brightness + contrast*cos( 6.28318*(osc*t+phase) );
}
vec3 hsb2rgb(vec3 c)
{
@johnhw
johnhw / umap_sparse.py
Last active January 6, 2024 16:09
1 million prime UMAP layout
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
@deanhume
deanhume / text-detection.js
Created May 22, 2017 14:16
Text Detection - Shape Detection API
var image = document.getElementById('image');
// Does the current browser support the text detection API?
if (window.TextDetector) {
let textDetector = new TextDetector();
textDetector.detect(theImage)
.then(detectedTextBlocks => {
// Loop through the results
for (const textBlock of detectedTextBlocks) {

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@nabucosound
nabucosound / heroku_env_copy.sh
Created December 30, 2013 12:40
Script to copy environment variables from an existing heroku app to another one
#!/bin/bash
# Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
@oscarrenalias
oscarrenalias / gist:3914875
Created October 18, 2012 21:35
Cheatsheet Play enumerators, enumeratees, iterators and iteratees
// --- cheat sheet ---
//
// Enumerator &> -> filters the output of the enumerator through an Enumeratee
// Enumerator >>> -> alias for andThen; adds the output of the second enumerator after the first one is done
// Enumerator |>> -> feeds the output of the enumerator into the given iteratee for processing
// --- end of cheat sheet ---
// Example
// Iteratee that sums up the size of the input: