Skip to content

Instantly share code, notes, and snippets.

View destiny0114's full-sized avatar
💣
Never Stop Learning

Keena Levine destiny0114

💣
Never Stop Learning
View GitHub Profile
@destiny0114
destiny0114 / rotation.js
Created December 26, 2024 03:20 — forked from akella/rotation.js
tsl rotation
const rotate2D = Fn(({pos,angle})=>{
const s = sin(angle);
const c = cos(angle);
const m = mat2(c, s, s.mul(-1), c);
return m.mul(pos);
})
const rotate3D = Fn(({pos,axis,angle})=>{
const axisNorm = normalize(axis);
const s = sin(angle);
@destiny0114
destiny0114 / GLSL-Noise.md
Created October 17, 2024 02:05 — 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);
@destiny0114
destiny0114 / oklab.glsl
Created October 6, 2024 08:57 — forked from akella/oklab.glsl
oklab.glsl
float fixedpow(float a, float x)
{
return pow(abs(a), x) * sign(a);
}
float cbrt(float a)
{
return fixedpow(a, 0.3333333333);
}
@destiny0114
destiny0114 / curl.glsl
Created October 6, 2024 08:57 — forked from akella/curl.glsl
curl.glsl
#define PI 3.1415926538
const float EPS = 0.001;
vec4 mod289(vec4 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
float mod289(float x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 permute(vec4 x) {
@destiny0114
destiny0114 / noise.glsl
Created October 6, 2024 08:57 — forked from akella/noise.glsl
noise.glsl
//
// GLSL textureless classic 3D noise "cnoise",
// with an RSL-style periodic variant "pnoise".
// Author: Stefan Gustavson (stefan.gustavson@liu.se)
// Version: 2011-10-11
//
// Many thanks to Ian McEwan of Ashima Arts for the
// ideas for permutation and gradient selection.
//
// Copyright (c) 2011 Stefan Gustavson. All rights reserved.
@destiny0114
destiny0114 / nodejs-express-cookies-example.js
Created October 8, 2021 09:06 — forked from gdm85/nodejs-express-cookies-example.js
How to create session cookies with Node.js + Express
var express = require('express'),
app = express(),
https = require('https'),
fs = require('fs'),
keys = require( "keygrip" )(['secret1', 'secret2']),
cookies = require( "cookies" );
// This line is from the Node.js HTTPS documentation
var options = {
key: fs.readFileSync('private_key_cert.pem'),
@destiny0114
destiny0114 / ultimate-ut-cheat-sheet.md
Created September 18, 2020 05:38 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@destiny0114
destiny0114 / encryption.js
Last active July 11, 2020 08:30
encrypting password using pbkdf2
// https://gist.github.com/Hammster/5ea6ec71fef5cc16f7834f79130ea3a0
const crypto = require('crypto'); // node js core module
// larger numbers mean better security, less
const config = {
// size of the generated hash at least 8 bytes and dont over 20 bytes
hashBytes: 12,
// larger salt means hashed passwords are more resistant to rainbow table, but
// you get diminishing returns pretty fast recommend 16 bytes
saltBytes: 16,
// more iterations means an attacker has to take longer to brute force an
@destiny0114
destiny0114 / track-page-views.js
Created July 9, 2020 07:52
track user how many times view the page
var express = require('express')
var parseurl = require('parseurl')
var session = require('express-session')
var app = express()
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true
@destiny0114
destiny0114 / app.js
Created July 5, 2020 08:40 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./permission"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection