Skip to content

Instantly share code, notes, and snippets.

View BideoWego's full-sized avatar
:octocat:
Yarp

Chris Scavello BideoWego

:octocat:
Yarp
View GitHub Profile
@BideoWego
BideoWego / whatIsThisJawn.js
Created April 12, 2024 19:12
Wanna FAFO what a jawn is? Use this javascript function!
/**
* Wanna FAFO what a jawn is? Use this function!
* @param {*} jawn The jawn. Any jawn.
* @returns {string} What the jawn is...
*/
function whatIsThisJawn(jawn) {
let answer = 'Yo this jawn is';
if (jawn === undefined || jawn === null) {
return `${answer} ${jawn}`;
@BideoWego
BideoWego / artful.js
Created April 17, 2019 18:52
Spell `artful` with arrays, logic, and numbers
([[1 == []][0] + []][0][1]) + ([[0 == []][0] + []][0][1]) + ([[0 == []][0] + []][0][0]) + ([[] + [][0]][0][4]) + ([[] + [][0]][0][0]) + ([[1 == []][0] + []][0][2])
@BideoWego
BideoWego / say.js
Created January 11, 2019 21:29
Say something with speech synthesis in the browser or compatible JS APIs
function say(phrase) {
speechSynthesis.speak(new SpeechSynthesisUtterance(phrase));
}
// Ex.
say('Happy Friday :)');
@BideoWego
BideoWego / estimated_time_remaining.js
Last active December 6, 2018 16:20
Calculate and output the estimated time remaining on a large number of batched promises and asynchronous tasks
var NUM_COUNT = 1000;
var _nums;
function _everyFiveWaitASecond() {
var chunk = function(i, results) {
results = results || [];
console.log('chunk(', i, ')');
if (!_nums.length) {
@BideoWego
BideoWego / linked_list.js
Created November 21, 2018 20:25
Simple linked list implementation in javascript
class Node {
constructor(value, next) {
this.value = value;
this.next = next;
}
}
class LinkedList {
constructor() {
this.head = null;
@BideoWego
BideoWego / promises.js
Created September 14, 2018 14:41
Error handling and stack traces in promise chain catches etc...
function eq(a, b) {
return new Promise(function(resolve, reject) {
a === b ?
resolve(`${ a } === ${ b }`) :
reject(`${ a } !== ${ b }`);
});
}
function eqs(a, b) {
return new Promise(function(resolve, reject) {
@BideoWego
BideoWego / 2d_array_util_functions.js
Last active June 11, 2018 17:47
2D array utility functions
/**
* Creates and returns a 2D array range from the source array
* @param {Array} array - The source array
* @param {number} y - The y position from which to start the range
* @param {number} x - The x position from which to start the range
* @param {number} h - The height of the range
* @param {number} w - The width of the range
* @returns {Array} The selected range
*/
@BideoWego
BideoWego / .bashrc
Created June 8, 2018 15:12
My Windows Dotfiles
echo ''
echo "Hello $(whoami)!"
echo ''
# ------------------------------------
# Directory Shortcuts
# ------------------------------------
alias back='cd $OLDPWD'
alias up='cd ..'
@BideoWego
BideoWego / comments.snippet.json
Created May 16, 2018 00:35
VSCode Snippets and Settings
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
@BideoWego
BideoWego / chunk.js
Created April 30, 2018 22:44
JavaScript chunk array generator example
function * chunkGen(collection, size=2, i=0) {
for (; i < collection.length; i += size) {
yield collection.slice(i, i + size);
}
}
function chunk(collection, size=1) {
const chunked = [];
const gen = chunkGen(collection, size);
let c = gen.next();