When working with API clients there are several distinct areas of concern. Each of these happen in sequence and are used with the goal of receiving a Domain Model at the end.
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
def flatten_dict(d: any): | |
if not isinstance(d, dict): | |
return [] | |
flat_d = _flatten_dict(d) | |
for index in range(len(flat_d)): | |
flat_d[index] = tuple(flat_d[index]) | |
return flat_d |
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
require 'vcr' | |
module HackyVCRHelpers | |
def extract_headers_from(request) | |
{ | |
'content_length' => request.headers.env['CONTENT_LENGTH'], | |
'content_type' => request.headers.env['CONTENT_TYPE'], | |
'http_accept' =>request.headers.env['HTTP_ACCEPT'], | |
'http_host' => request.headers.env['HTTP_HOST'], | |
'path_info' => request.headers.env['PATH_INFO'], |
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
#!/usr/bin/env bash | |
set -ex | |
summary () { | |
# MacOS - local testing | |
# echo "$(stat -f '%z' "$1") $(md5sum "$1")" | |
# Linux | |
echo "$(stat -c '%s' "$1") $(md5sum "$1")" |
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
(define (FUNO L) | |
(cond | |
[(list? L) | |
(cond | |
[(empty? L) 1] | |
[(equal? (length L) 1) (FUNO(first L))] | |
[(* (FUNO(first L)) (FUNO (rest L)))] | |
) | |
] | |
[else L] |
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
def solve(polish_notation): | |
polish_notation = polish_notation.split() | |
operands = [] | |
operators = [] | |
operations = { | |
'+': lambda x, y: x + y, | |
'-': lambda x, y: x - y, | |
'*': lambda x, y: x * y, | |
'/': lambda x, y: x / y | |
} |
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
def solution(n): | |
d = [0] * 30 | |
l = 0 | |
while (n > 0): | |
d[l] = n % 2 | |
n //= 2 | |
l += 1 | |
for p in range(1, l - 1): | |
ok = True | |
print(d[:l-p]) |
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
from collections import Counter | |
def solution_aux(S, groupSize, groups, numberOfAs): | |
print(groups, S, numberOfAs) | |
if len(groups) == 3: | |
if len(S) == 0: | |
print('count') | |
return 1 |
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 LimitedSet { | |
constructor(size) { | |
this.size = size | |
this.queue = [] | |
this.set = new Set() | |
} | |
has(key) { | |
return this.set.has(key) | |
} |
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 Board(object): | |
def __init__(self, wide, tall): | |
self.__wide__ = wide | |
self.__tall__ = tall | |
self.__area__ = [[None for _ in range(wide)] for _ in range(tall)] | |
self.__validate_wide__(wide) | |
self.__validate_tall__(tall) | |
def __validate_wide__(self, wide): |
NewerOlder