Skip to content

Instantly share code, notes, and snippets.

View MichaelWalker-git's full-sized avatar

Michael Walker MichaelWalker-git

View GitHub Profile
@MichaelWalker-git
MichaelWalker-git / combine_textract_json.py
Created April 25, 2024 15:39
Combine raw textract files
# I tried doing this in a lambda for 110 Textract files, but it exceeded the 10GB memory limitation
# Lambda approach
# combined_data = []
# response = s3_client.list_objects_v2(Bucket=bucket, Prefix=prefix)
# if 'Contents' in response:
# files = sorted(response['Contents'], key=lambda x: x['Key'])
@MichaelWalker-git
MichaelWalker-git / System Design.md
Created January 24, 2019 21:48 — 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?
let map = new Map();
map.set("a", 1);
map.set("b", 2);
map.set("c", 3);
let obj = Array.from(map).reduce((obj, [key, value]) => (
Object.assign(obj, { [key]: value }) // Be careful! Maps can have non-String keys; object literals can't.
), {});
console.log(obj); // => { a: 1, b: 2, c: 3 }
function oneArray(arr) {
return arr.reduce(function (first, next) {
return first.concat(Array.isArray(next) ? oneArray(next) : next);
}, []);
}
oneArray([[1,2,[3]],4]);
function solution(X, A) {
// write your code in JavaScript (Node.js 0.12)
var count = new Array(X);
for ( var i=0; i < A.length; i++) {
var info = {
minute : i,
count : 1
};
Given non empty, zero indexed array (A)
A has n integers (1 < n < 100000)
A represents number of mushrooms growing in a consecutive spots along the road
Given integers k and m
k = spot on the road and m = number of moves
In one move, she moves to an adjacent spot
function prefixSums(A){
var leng = A.length;
p = [0] * (leng +1);
for(var i = 0; i< leng+1; i++){
P[i] = P[i-1] + A[i-1];
}
return P;
}
/*
You are given N counters, initially set to 0, and you have two possible operations on them:
• increase(X) − counter X is increased by 1,
• max counter − all counters are set to the maximum value of any counter.
A non-empty zero-indexed array A of M integers is given. This array represents consecutive operations:
• if A[K] = X, such that 1 ≤ X ≤ N, then operation K is increase(X),
• if A[K] = N + 1 then operation K is max counter.
function solution(A) {
var min = 1;
A.sort(function(a,b){
// Sort the array explicit way
return a - b;
});
for (var i in A) {
if (A[i] > -1 && A[i] == min) {
min++;
function tapeEquilibrium(A) {
var p, i;
var leftSum = 0, rightSum = 0;
var totalSum = 0;
var lastMin, currentMin;
var leng = A.length;
if (leng == 2) { return Math.abs(A[0] - A[1]); }
if (leng == 1) { return Math.abs(A[0]); }
//edge cases where the length is 1 or 2