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
PARSE_GIT_BRANCH() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
EMOJI_DOCKER=🐳 | |
EMOJI_FLAG=🇮🇳 | |
EMOJIS_FACES=(😂 🤣 🤔 😄 😆 🙂 😎 😌 🙃 😉 🧐 😏 🤪 😜 😱 😬 🤫 🙄 😈 🙈 🙉 🙊) | |
EMOJIS_HANDS=(🙌 🤝 👌 🤘 🖖 🙏 👏 💪 🤙) | |
RANDOM_EMOJI_FACES() { |
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
!/bin/bash | |
clear | |
echo "" | |
echo "Compiling and Running Java Program..." | |
javac -d ./__prod Main.java | |
echo "" | |
echo "----------------------------------------------------------------------------------------------------------------------------------------------------------------" | |
echo "" | |
java -cp ./__prod Main |
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
/** | |
* Currying function in JavaScript | |
*/ | |
// Normal function definition | |
function multiply(a, b, c) { | |
return a * b * c; | |
} | |
multiply(1, 2, 3); // 👉 Output: 6 |
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 uuidv4() { | |
const init = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"; | |
return init.replace(/[xy]/g, (c) => { | |
const r = Math.random() * 16 | 0; | |
const v = c == 'x' ? r : (r & 0x3 | 0x8); | |
return v.toString(16); | |
}); | |
} |
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
const memoize = (fn) => { | |
const cache = {}; | |
return (...args) => { | |
if (cache[args]) { return cache[args]; } | |
cache[args] = fn.apply(this, args); | |
return cache[args]; | |
}; | |
}; | |
const range = (count) => Array.from({ length: count }, (v, i) => i + 1); |
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
var obj = { | |
values: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34], | |
start: 4, | |
end: 13, | |
*[Symbol.iterator]() { | |
for (var i = this.start; i <= this.end; i++) { | |
yield this.values[i]; | |
} | |
}, | |
}; |
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
var obj = { | |
values: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34], | |
start: 4, | |
end: 13, | |
[Symbol.iterator]() { | |
var idx = this.start; | |
var end = this.end; | |
var it = { | |
next: () => { |
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 idb from 'idb'; | |
var dbPromise = idb.open('test-db', 4, function(upgradeDb) { | |
switch(upgradeDb.oldVersion) { | |
case 0: | |
var keyValStore = upgradeDb.createObjectStore('keyval'); | |
keyValStore.put("world", "hello"); | |
case 1: | |
upgradeDb.createObjectStore('people', { keyPath: 'name' }); | |
case 2: |
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
$(document).ready(() => { | |
const onEvent = (event, eventLog = event) => { | |
let box; | |
let pageCoords; | |
if (event.startsWith('key')) { | |
box = $(document); | |
pageCoords = (e) => `(${e.which})`; | |
} else { | |
box = $('.element'); | |
pageCoords = (e) => `(${e.pageX}, ${e.pageY})`; |
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
const deepCopy = (value) => { // deepCopy by Value | |
let val; | |
if (Array.isArray(value)) { | |
val = [...value]; // Copy by Value | |
} else if (value && typeof value === 'object') { | |
val = { ...value }; // Copy by Value | |
} else { | |
return value; // Returns original value and stops! | |
} |
NewerOlder