Skip to content

Instantly share code, notes, and snippets.

View co3moz's full-sized avatar
🍗
increasing the entropy

Doğan Derya co3moz

🍗
increasing the entropy
View GitHub Profile
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active June 20, 2024 09:08
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);
@neilmendoza
neilmendoza / gist:4512992
Last active June 9, 2023 14:22
Function to return matrix for rotation about an arbitrary axis in GLSL.
mat4 rotationMatrix(vec3 axis, float angle)
{
axis = normalize(axis);
float s = sin(angle);
float c = cos(angle);
float oc = 1.0 - c;
return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
@danherbert-epam
danherbert-epam / directory.js
Last active October 8, 2016 19:17
Cross-Platflorm node.js directory node module, which includes mkdir and mkdirSync utilities which behave like the UNIX command "mkdir -p" which can be given a path with lots of non-existent nested directories and create any that are missing. One thing missing here that could be added in the future is the optional 'mode' argument, which exists in…
var fs = require('fs');
var pathSep = require('path').sep;
var directory = module.exports = {};
directory.mkdirSync = function __directory_mkdirSync__(path) {
var dirs = path.split(pathSep);
var root = "";