Skip to content

Instantly share code, notes, and snippets.

View wizo06's full-sized avatar

wizo wizo06

View GitHub Profile
@wizo06
wizo06 / getLongestSubstring.js
Last active June 9, 2018 22:30
To run: "node getLongestSubstring.js <string>". Get longest substring in alphabetical order from a string. Javascript-specific methods were avoided as much as possible. Complexity is O(n).
/*
* Assume s is a string of lower case characters.
*
* Write a program that prints the longest substring of s
* in which the letters occur in alphabetical order.
*
* For example, if s = 'azcbobobegghakl', then your program should print
* "Longest substring in alphabetical order is: beggh"
*
* In the case of ties, print the first substring.
@wizo06
wizo06 / asyncJS-test
Created May 19, 2018 15:19
snippet to test if a function has async calls inside it
var work = process._getActiveHandles().length + process._getActiveRequests().length;
foo();
var newWork = (process._getActiveHandles().length + process._getActiveRequests().length) - work;
if(newWork > 0) {
console.log("asynchronous work took place.");
}