Skip to content

Instantly share code, notes, and snippets.

View sarahbkim's full-sized avatar

sarahbkim sarahbkim

View GitHub Profile
@sarahbkim
sarahbkim / find_sum.py
Created November 10, 2018 08:23
scratch paper
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
@sarahbkim
sarahbkim / Promises-under-the-hood.md
Created September 21, 2018 04:39 — forked from gvergnaud/Promises-under-the-hood.md
Promises, under the hood.

Promises, under the hood

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.

@sarahbkim
sarahbkim / System Design.md
Created September 17, 2018 15:15 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@sarahbkim
sarahbkim / postmortem.md
Created September 11, 2018 04:18 — forked from mlafeldt/postmortem.md
Example Postmortem from SRE book, pp. 487-491

Shakespeare Sonnet++ Postmortem (incident #465)

Date

2015-10-21

Authors

  • jennifer
  • martym
@sarahbkim
sarahbkim / fqueries.js
Last active October 30, 2017 22:54
metaprogramming
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"
@sarahbkim
sarahbkim / reduce.js
Last active January 25, 2016 02:01
reduce
// 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
};

API workthough

  1. Open a browser

    # start an instance of firefox with selenium-webdriver
    driver = Selenium::WebDriver.for :firefox
    # :chrome -> chrome
    # :ie     -> iexplore
    
  • Go to a specified URL
@sarahbkim
sarahbkim / date_variables.sh
Last active August 29, 2015 14:07
getting date variables in bash
# 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