This file contains 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
Array.prototype.getItemCount = function (val) { | |
var count = 0, i = -1; | |
while ((i = this.indexOf(val, i + 1)) != -1) { | |
count++; | |
} | |
return count; | |
}; | |
Array.prototype.sortObjectsWithSingleKeyByValue = function (isAscending) { | |
return (isAscending) ? this.sort((a, b) => a[Object.keys(a)[0]] - b[Object.keys(b)[0]]) : this.sort((a, b) => b[Object.keys(b)[0]] - a[Object.keys(a)[0]]); |
This file contains 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
//exec() family of functions | |
#include <stdio.h> | |
#include <unistd.h> | |
int main(int argc, char **argv){ | |
pid_t id; | |
id = vfork(); | |
if(id == 0){ |
This file contains 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
function randomInt(a = 0, b = 0) { return (a + window.crypto.getRandomValues(new Uint32Array(1))[0] % Math.abs(b - a)).toString(); } | |
String.prototype.nRepeat = function (n) { return '_'.repeat(n).split('').map(x => this.toString()); } | |
String.prototype.removeVowels = function (n) { return this.toString().replace(/a|e|i|o|u/g,''); } | |
function toss() { return Boolean(Math.round(Math.random())); } | |
let domain = '@gmail.com'.nRepeat(7).concat(['@live.com', '@yahoo.com', '@hotmail.com']); // Giving more weight to gmail domains | |
let names = ['Tony Stark', 'Bruce Wayne', 'Steve Rogers', 'Clark Kent']; | |
function randomDomain() { return domain[randomInt(0, domain.length)]; } |
This file contains 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
let prefix = ['98', '78', '97', '96', '89', '99', '70', '79', '90', '94', '76', '84', '86', '81']; | |
function randomInt(a = 0, b = 0) { return (a + window.crypto.getRandomValues(new Uint8Array(1))[0] % Math.abs(b - a)).toString(); } | |
Uint32Array.prototype.unique = function () { return this.filter((v, i) => ( this.indexOf(v) == i )); } | |
function numbers(n = 16384, usePrefix, len) { | |
let seed = randomInt(0,99999999); | |
let numbers = window.crypto.getRandomValues(new Uint32Array(n)).unique(); | |
numbers.forEach((n) => { | |
let pfx = usePrefix ? prefix[n % prefix.length] : ''; |
This file contains 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
// Basic Random Date Generator | |
function randomInt(a = 0, b = 0) { return (a + window.crypto.getRandomValues(new Uint8Array(1))[0] % Math.abs(b - a + 1)); } | |
function log(json) { | |
for (key in arguments) { | |
let string = JSON.stringify(arguments[key], null, ' '); | |
document.body.innerHTML += `<pre>${string}</pre> `; | |
} | |
console.log(...arguments); | |
document.body.innerHTML += '<br>'; |
This file contains 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 Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (..) | |
import List | |
main = Html.beginnerProgram { model = model, view = view, update = update } | |
type alias Todo = { text: String } | |
type alias Model = { todos: List Todo, newTodo: String } |
This file contains 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
{ | |
"dependencies": { | |
"node-sass-chokidar": "^1.3.0", | |
"npm-run-all": "^4.1.3" | |
}, | |
"scripts": { | |
"test": "react-scripts test --env=jsdom", | |
"eject": "react-scripts eject", | |
"build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/", | |
"watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive", |
This file contains 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 { waitFor } from './waitFor'; | |
let unrelatedStuffValue = false; | |
async function test() { | |
const result = await waitFor(() => unrelatedStuffValue); | |
console.log('Result: ', result); // Result: true | |
} | |
async function unrelatedAsyncStuff() { |
This file contains 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
if (!window.OffscreenCanvas) { | |
window.OffscreenCanvas = class OffscreenCanvas { | |
constructor(width, height) { | |
this.canvas = document.createElement('canvas'); | |
this.canvas.width = width; | |
this.canvas.height = height; | |
this.canvas.transferToImageBitmap = () => { | |
const ctx = this.canvas.getContext('2d'); | |
if (!ctx) return; |
OlderNewer