Skip to content

Instantly share code, notes, and snippets.

@aderaaij
aderaaij / GLSL-Noise.md
Created October 4, 2022 21:45 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

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);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
@aderaaij
aderaaij / webpack.config.js
Created February 1, 2018 17:20
A minimal webpack config for vuejs
const webpack = require('webpack');
const path = require('path');
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './build'),
filename: 'bundle.js',
},
module: {
@aderaaij
aderaaij / ramda.js
Last active January 29, 2018 08:00
/*
* Using the library ramda, what is the result of the following code?
* R.reduce((acc,x) => R.compose(R.flip(R.prepend)(acc), R.sum,R.map(R.add(1)))([x,...acc]), [0])([13, 28]);
* Explain each of the steps the best you can.
*/
const R = require('ramda');
// Reduce function iterating over [13, 28]
// starting point: [0]
const test = R.reduce(
@aderaaij
aderaaij / gist:c13997758b4202bb8a20b71e0cd0a48f
Created December 14, 2017 16:53 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
const text = text.replace(/\s(?=[^\s]*$)/g, ' ');
@aderaaij
aderaaij / es6-spread-operator.js
Last active July 25, 2018 09:27
The spread operator can expand(spread) any iterable like an array or a string.
const avengers = ['Thor', 'The Hulk', 'Captain America'];
let guardians = ['Star Lord', 'Gamorra', 'Drax', 'Rocket', 'Groot'];
// Spread out arrays in a new array and put a new value in between them
const heroes = [...avengers, 'Loki', ...guardians];
// Adding new stuff to an array just got easier too
guardians = [...guardians, 'Mantis', 'Yondu', 'Nebula'];
// Or simply making a TRUE copy of an array
const avengersCopy = [...avengers];
@aderaaij
aderaaij / es6-find-findindex.js
Created November 14, 2017 23:39
`array.find()` and `array.findIndex()` do pretty much what you expect. They go over each item of an array so you can return the value you want, which is especially handy when you're looking for something in particular in an array of objects (and even more handy when that array of objects is keyless. Example time
const users = [
{
"_id": "5a0b7a6441a687091332f11b",
"index": 0,
"guid": "0d3bba05-ecde-4237-b53e-0bd474239ee2",
"isActive": false,
"balance": "$2,144.22",
"picture": "http://placehold.it/32x32",
"age": 32,
"eyeColor": "green",
@aderaaij
aderaaij / es6-array-of.js
Created November 14, 2017 22:39
Basically, take in whatever in `array.of()` and return an array https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Global_Objects/Array/of
const team = Array.of('Black Panther', 'Wolverine', 'X-23', 'Sabertooth');
console.log(team);
@aderaaij
aderaaij / es6-array-from.html
Last active November 14, 2017 23:13
There are several occasions where you get an array-like value, which isn't actually an array. The most common occasion is when you do `document.querySelectorAll()`, which returns a nodelist instead of an Array. Another possibility is when you use a function which takes in multiple arguments, and you use the `arguments` keyword to retrieve those.…
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Array .from()</title>
</head>
<body>
<ul class="heroes">
<li>Hulk</li>
<li>Thor</li>
// https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Statements/for...in
const hulk = {
color: 'Green',
size: 'Large',
weight: 500,
power: 'Super Strength',
};
for (const prop in hulk) {
console.log(`${prop}: ${hulk[prop]}`);