Skip to content

Instantly share code, notes, and snippets.

View this.js
const a = {
foo: function (target) {
return this === target;
},
bar: function() {
return (target) => this === target;
}
}
b = {
@jeremiah-ang
jeremiah-ang / asyncAwait.js
Created Jun 8, 2020
Converting callback to promises to async/await
View asyncAwait.js
// Async Await
function showLoading() {
console.log('Loading...');
}
function populateTable(data) {
console.log(`populate table with ${data}`);
}
function updatePagination(count) {
console.log(`Pagination: ${count}`);
@jeremiah-ang
jeremiah-ang / README.md
Created Mar 15, 2018
Single-Pass In-Memory Indexing
@jeremiah-ang
jeremiah-ang / execute-java-test.sh
Last active Aug 23, 2017
Execute java project with input and output
View execute-java-test.sh
#!/bin/sh
# Set variables
PROJECT_NAME=$1
PROJECT_NAME_LOWER=$(echo $PROJECT_NAME | tr '[:upper:]' '[:lower:]')
TEST_CASE=$PROJECT_NAME_LOWER$2
PATH_TO_TEST_INPUTS=input
PATH_TO_TEST_OUTPUTS=output
echo "Project: $PROJECT_NAME"
@jeremiah-ang
jeremiah-ang / pattern_in_array_finder.js
Created Jun 20, 2017
Few functions to help search for a matches of a substring in an array
View pattern_in_array_finder.js
var arr = [
'1 Chronicles', '1 Corinthians', '1 John', '1 Kings',
'1 Peter', '1 Samuel', '1 Thessalonians', '1 Timothy',
'2 Chronicles', '2 Corinthians', '2 John', '2 Kings',
'2 Peter', '2 Samuel', '2 Thessalonians', '2 Timothy',
'3 John', 'Acts', 'Amos', 'Colossians',
'Daniel',
'Deuteronomy', 'Ecclesiastes', 'Ephesians', 'Esther',
'Exodus', 'Ezekiel', 'Ezra', 'Galatians',
'Genesis', 'Habakkuk', 'Haggai', 'Hebrews',
@jeremiah-ang
jeremiah-ang / PrettyObjectPrinter
Created Jun 19, 2017
A function to print javascript object nicely
View PrettyObjectPrinter
PrettyObjectPrinter.prototype.objectToString = function (obj, brackets, spacing, space='') {
if (typeof obj != "object")
return obj;
var acc = "";
var commaFlag = false;
for (var key in obj) {
acc += ((commaFlag) ? ",\n" : "") + space + key + ": ";
acc += this.print (obj[key], brackets, spacing, space);
commaFlag = true;