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 | |
# Set the start date one year ago | |
# gdate for OSX; use date for linux | |
start_date=$(gdate -d "1 year ago" +'%Y-%m-%d') | |
echo $start_date | |
# Get the list of unique committers in the past year; filter out email address name to reduce duplicates | |
unique_committers=$(git shortlog -se --since="$start_date" | sed -e 's/^\s*[[:digit:]]*\s*//' | sort -u | uniq) |
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
class Buffer { | |
constructor(promises) { | |
this.buffer = null; | |
/** | |
* Collection of resolved promises | |
* @type {Set} | |
*/ | |
this._set = new Set(); | |
// Init | |
this._init(promises); |
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 testStr = 'Let us go us then you you and I.'; | |
function noRepeat1(str) { | |
const arr = str.split(' '); | |
return arr.reduce(function(prev, curr, index) { | |
if (arr.lastIndexOf(curr) === index) { | |
prev.push(curr); | |
} | |
return prev; | |
}, []).join(' ') |
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 debounce(fn, time) { | |
var timeoutId; | |
return function() { | |
if (timeoutId) { | |
return; | |
}; | |
fn.apply(this, arguments); | |
timeoutId = setTimeout(function(){ | |
timeoutId = null; | |
}, time); |
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 testArr = [1,2,[3,4, [5,6,7], 8], 9, 10]; | |
function flatten(item) { | |
return item.reduce(function(prev, curr) { | |
if (!Array.isArray(curr)) { | |
prev.push(curr); | |
} else { | |
prev = prev.concat(flatten(curr)); | |
} | |
return prev; |
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 getFunctionName(line) { | |
var m =line.match(/var (.*)= function/); | |
if (m.length < 1) { | |
m = line.match(/function([^\(]+)/); | |
} | |
return m[1] || false; | |
}; |
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
# Check if every item in a list is the equals some value | |
if status[0] == 'COMPLETED' and len(set(status)) == 1: | |
return True | |
else: | |
return False | |
# use a generator to create an in memory list of TRUE or FALSE | |
# and then use all() to iterate over the list | |
if len(LIST) > 0 and all(x == 'foo' for x in LIST): |