Skip to content

Instantly share code, notes, and snippets.

View Mk-Etlinger's full-sized avatar

Mike Etlinger Mk-Etlinger

  • Grand Rapids
View GitHub Profile
@Mk-Etlinger
Mk-Etlinger / flights.ts
Last active October 31, 2025 05:00
Capital RX Backend Design Problem
// Design a system for interfacing with multiple flight APIs
// Technical Requirements:
//
// 1. The system should be flexible enough to trivially add new flight APIs
// 2. The flight responses should conform to an internal schema/interface
// Questions:
//
// 1. How many different APIs/Data sources do we need to interact with?
When wanting to use composition for your components, how do you handle cases where you always need to map items
for things like Radio Group or Accordion Items?
For example: https://chakra-ui.com/docs/disclosure/accordion
<Accordion>
// How can I encapsulate this without losing composition? Is it even worth it?
// In the case where we need to have other developers use this composition, how do we ensure they use it correctly?
// Using TypeScript btw
@Mk-Etlinger
Mk-Etlinger / hr-pairSum-v3.js
Created February 13, 2020 20:56
Hacker Rank pairSum challenge
function pairSum(data, target) {
const pairMatches = {};
for(let i = 0; i < data.length; i++) {
const number = data[i];
const difference = (target - number);
if (pairMatches[number]) {
return true;
}
@Mk-Etlinger
Mk-Etlinger / hr-pairSum-v2.js
Last active February 12, 2020 22:16
Hacker Rank - pairSum v2
function pairSum(data, target) {
let sumMatchesTarget;
data.forEach((currentNumber, index) => {
if (sumMatchesTarget) { return; }
const dataFiltered = removeCurrentIndex(data, index);
sumMatchesTarget = dataFiltered.some(nextNumber => {
const sum = (currentNumber + nextNumber);
@Mk-Etlinger
Mk-Etlinger / hr-pairSum-v1.js
Last active February 13, 2020 18:14
pairSum Solution
/*
* Complete the 'pairSum' function below.
*
* The function is expected to return a BOOLEAN.
* The function accepts following parameters:
* 1. INTEGER_ARRAY array
* 2. INTEGER target
*/
function pairSum(array, target) {
for(let i = 0; i < array.length; i++) {
@Mk-Etlinger
Mk-Etlinger / README.md
Created June 7, 2019 15:11 — forked from benjaminbarbe/README.md
Nginx proxy to S3 with caching
@Mk-Etlinger
Mk-Etlinger / setup.php
Created November 20, 2018 17:49
From setup.php
add_action('init', function(){
session_set_cookie_params( 0 );
if(!session_id())
session_start();
}, 1);
class ExpressionEvaluator
def self.parse(string)
complex_exps = string.scan(/-\s\d+\s\d+/)
simple_exps = string.gsub(/-\s\d+\s\d+/, '')
complex_sum(complex_exps) + simple_sum(simple_exps)
end
def self.complex_sum(array)
array.reduce(0) { |sum, exp| sum + (exp.split[1].to_i - exp.split[2].to_i) }
end
class ExpressionEvaluator
def self.parse(string)
complex_exps = string.scan(/-\s\d+\s\d+/)
simple_exps = string.gsub(/-\s\d+\s\d+/, '')
complex_sum(complex_exps) + simple_sum(simple_exps)
end
end
def self.parse(string)
sum = 0
char_array = string.split
char_array.each_with_index do |char, i|
sum += char.to_i
next unless char == '-' && char_array[i + 2]
if char_array[i + 2].to_i == 0
char_array[i + 1] = char + char_array[i + 1]
else
char_array[i + 2] = char + char_array[i + 2]