Skip to content

Instantly share code, notes, and snippets.

View jhnsnc's full-sized avatar
🐢
Slow to respond on Github. Most personal projects are on hold, sorry! 🙇

Chris Johnson jhnsnc

🐢
Slow to respond on Github. Most personal projects are on hold, sorry! 🙇
View GitHub Profile
function colorInterpolate(t) {
var color1 = 0xffcc00;
var color2 = 0x0066ff;
var r = Math.floor((color2>>16)*t + (color1>>16)*(1-t));
var g = Math.floor((color2>>8&0xff)*t + (color1>>8&0xff)*(1-t));
var b = Math.floor((color2&0xff)*t + (color1&0xff)*(1-t));
return '#' + ((1<<24)+(r<<16)+(g<<8)+b).toString(16).slice(1);
}
@jhnsnc
jhnsnc / glsl-function-snippets.glsl
Last active April 20, 2017 00:34
GLSL Function Snippets
// Sineless hash - Dave Hoskins ( https://www.shadertoy.com/view/4djSRW )
// License: CC BY-SA v4.0 (this function only)
float hash11(float p)
{
const float HASHSCALE1 = .1031;
vec3 p3 = fract(vec3(p) * HASHSCALE1);
p3 += dot(p3, p3.yzx + 19.19);
return fract((p3.x + p3.y) * p3.z);
}
@jhnsnc
jhnsnc / install-nvm-node-npm.sh
Created October 2, 2017 20:26
Snippet to install NVM and set it up with a stable version of Node/NPM
#-------------------------------------------------------------------------------
# Install NVM
#-------------------------------------------------------------------------------
echo -e "Installing nvm, our Node version manager..." true
NVM_DIR="$HOME/.nvm"
if [[ -e "$NVM_DIR" ]]; then
echo -e "Already installed. Moving on..."
@jhnsnc
jhnsnc / ClassNames.js
Created January 26, 2018 01:05
Utility class for adding/removing class names by chaining function calls rather than doing manual string manipulation
/**
* Conditionally add/remove classes and render the result to a class list string
*
* @param {...string} initialClasses - initial class names to add
*/
export class ClassNames {
constructor(...initialClasses) {
this.arrClasses_ = initialClasses;
this.breakUpSpaces_();
return this;