You all know that to create a new Promise you need to define it this way:
new Promise((resolve, reject) => {
...
resolve(someValue)
})
You are passing a callback that defines the specific behavior of your promise.
import unittest | |
def has_pair_with_sum(a_list, target): | |
if len(a_list) < 2: | |
return False | |
i, j = 0, len(a_list) - 1 | |
while i < j: | |
min_value = a_list[i] |
" Section: General Config {{{1 | |
" ---------------------------- | |
set shell=zsh " Set bash as the prompt for Vim | |
set backspace=2 " Backspace deletes like most programs in insert mode | |
set ruler " show the cursor position all the time | |
set laststatus=2 " Always display the status line | |
set shiftround | |
set scrolloff=3 | |
set list listchars=tab:»·,trail:· " Display extra whitespace characters | |
set hidden |
Picking the right architecture = Picking the right battles + Managing trade-offs
const schema = [ | |
{ klass: 'Places', validvalues: [ 'Chain', 'Category' ], validOperators: [ '$and', '$or' ] }, | |
{ klass: 'Chain', validvalues: [], validOperators: ['$in', '$nin'] }, | |
{ klass: 'Category', validvalues: [], validOperators: ['$in', '$nin'] } | |
] | |
function generateSubqueries(klass, validvalues) { | |
validvalues.forEach((subquery) => { | |
klass.prototype[`add${subquery}`] = function(operator, value) { |
FROM factual/docker-cdh5-swissarmy:latest | |
RUN apt-get -y update | |
CMD curl -XPOST "http://admin.prod.factual.com/geopulse/send_stale_designs" |
// custom implementation of reduce fn just for fun | |
Array.prototype.myReduce = function(fn, customStart) { | |
var result = customStart ? customStart : null; | |
for(var i=0;i<this.length;i++) { | |
result = fn(result, this[i]) | |
} | |
return result | |
}; | |
# set date variables | |
TODAY=`date --date= +%Y-%m-%d` | |
FIRST_DAY_PREVIOUS_MONTH=`date --date="-1 month" +%Y-%m-01` | |
LAST_DAY_PREVIOUS_MONTH=`date -d "-$(date +%d) days" +%Y-%m-%d` | |
#get english month | |
ENGLISH_MONTH=`date "+%B"` | |
# Get today's quarter and year |