Skip to content

Instantly share code, notes, and snippets.

@commanda
commanda / promises_reduce.js
Last active September 6, 2016 21:50 — forked from anvk/promises_reduce.js
Sequential execution of Promises using reduce()
function createPromiseForFunction(e, functionThatTakesOneItem)
{
return new Promise((resolve, reject) => {
resolve(functionThatTakesOneItem(e));
});
}
@commanda
commanda / gist:62cd8bd1928306329b5e3fe02edd51ef
Created June 2, 2016 16:18 — forked from quietcricket/gist:1593632
Fuzzy string match objective-c (Levenshtein Distance Algorithm)
-(float)compareString:(NSString *)originalString withString:(NSString *)comparisonString
{
// Normalize strings
[originalString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[comparisonString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
originalString = [originalString lowercaseString];
comparisonString = [comparisonString lowercaseString];
// Step 1 (Steps follow description at http://www.merriampark.com/ld.htm)