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);
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const random = (upto = 20, offset = 1) => { | |
const correction = Math.max(upto, upto * 1000); | |
return ~~(Math.random() * correction) % upto + offset; | |
}; | |
const populateArr = (count = 20) => { | |
const numbers = []; | |
for (let i = 0; i < count; i++) { | |
numbers.push(random()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// think of this as a DB | |
const users = [ | |
{ username: "name1234", password: "password" }, | |
{ username: "user1234", password: "pass" } | |
]; | |
// username and password of the user | |
const username = "name1234"; | |
const password = "password"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getRandomHex = () => Math.random().toString(16).substring(2); | |
const getTimeHex = () => Date.now().toString(16); | |
const getUniqueID = () => `${getRandomHex()}-${getTimeHex()}`; | |
console.log(getUniqueID()); // c3767dde3c52b-1858ae49650 | |
console.log(getUniqueID()); // afea12d2bf3ee-1858ae49b2e | |
console.log(getUniqueID()); // c935374b52dc4-1858ae49e6b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sqrt = function(x) { | |
var isGoodEnough = function(guess) { | |
return Math.abs(guess * guess - x) / x < 0.001; | |
}; | |
var improve = function(guess) { | |
return (guess + x / guess) / 2; | |
}; | |
var sqrIter = function(guess) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const numberTexts = { | |
0: 'zero', | |
1: 'one', | |
2: 'two', | |
3: 'three', | |
4: 'four', | |
5: 'five', | |
6: 'six', | |
7: 'seven', | |
8: 'eight', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const logs = { | |
online: [], | |
offline: [], | |
typing: [] | |
}; | |
let currentStatus = ''; | |
let timer = new Date(); | |
const getDateFormat = date => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from 'react'; | |
import data from './data'; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
flowData: [] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getValue = (value, successFn, errorFn) => { | |
new Promise((res, rej) => { | |
if (value > 100) { | |
res(value * 2); | |
} else { | |
rej(value / 2); | |
} | |
}) | |
.then(data => { | |
successFn(data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const names = ['Antonia Lane', 'Reya Castillo', 'Ayla Owen', 'Ahmed Adams', 'Gerrard Douglas', 'Kaif Greenwood', 'Piper Redmond', 'Jago Decker', 'Reya Castillo']; | |
const selectedName = 'Reya Castillo'; | |
let count = 0; | |
// using for loop [the most efficient] | |
for (let i = 0; i < names.length; i++) { | |
count += selectedName === names[i]; | |
} |
NewerOlder