Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Max Voitko mvoitko

🎯
Focusing
View GitHub Profile
@mvoitko
mvoitko / copy.sh
Last active Jan 12, 2021
Copy SSh key to a buffer
View copy.sh
xclip -sel clip < ~/.ssh/id_rsa.pub
@mvoitko
mvoitko / 📊 Weekly development breakdown
Last active Oct 29, 2020
Dynamically updated Activity
View 📊 Weekly development breakdown
Terraform 3 hrs 57 mins █████████▍░░░░░░░░░░░ 45.0%
YAML 2 hrs 44 mins ██████▌░░░░░░░░░░░░░░ 31.2%
Bash 51 mins ██░░░░░░░░░░░░░░░░░░░ 9.7%
Python 40 mins █▌░░░░░░░░░░░░░░░░░░░ 7.7%
Other 25 mins █░░░░░░░░░░░░░░░░░░░░ 4.9%
View bubbleSort.cpp
void bubbleSort(int[] a)
{
int n = a.length;
for (int j = 0; j < n - 1; ++j)
{
for (int i = 0; i < n - j - 1; ++i)
{
if (a[i] > a[i+1])
{
swap(a, i, i+1);
@mvoitko
mvoitko / heap.py
Last active Sep 26, 2020
Min heap Python implementation
View heap.py
from typing import List, Optional, Set, Tuple
class Heap:
def __init__(self, arr: Optional[List[int]] = None):
self._to_delete: Set[int] = set()
if arr:
self.__heapify(arr)
else:
self.__arr: List[int] = []
@mvoitko
mvoitko / Latencies.md
Last active Sep 15, 2020
Every Programmer Should Know These Latency Numbers
View Latencies.md

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
@mvoitko
mvoitko / template.sh
Created Jul 7, 2020
Bash script template
View template.sh
#!/bin/bash
################################################################################
# scriptTemplate
################################################################################
################################################################################
################################################################################
# #
# Copyright (C) 2020 Maksym Voitko #
# max.voitko@gmail.com #
@mvoitko
mvoitko / sys_design_flow.txt
Last active Feb 9, 2020
System Design Flow
View sys_design_flow.txt
Step 1. Requirements clarifications:
1.1 Define use cases with interviewers help.
Who is going to use it?
How are they going to use it?
What does the system do?
What are the inputs and outputs of the system?
1.2 Ask about additional features.
1.3 Remove items that interviewer deems out of scope.
1.4 Assume high availability required. Add as a use case.
@mvoitko
mvoitko / Huffman.java
Created Feb 4, 2020
Huffman coding algorithm
View Huffman.java
// При кодировании информации каждый символ заменяется на свой код.
// Декодирование для префиксных кодов однозначно и выполняется слева направо.
// Чтобы эффективно реализовать процесс декодирования, необходимо хранить информацию о коде в удобной форме.
// Например, можно представить код в виде двоичного дерева, листья которого соответствуют кодируемым символам.
// А путь от вершины дерева до кодируемого символа определяет кодирующую последовательность битов: поворот налево дает 0, направо — 1.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
@mvoitko
mvoitko / read_ints.py
Created Nov 3, 2019
Reading int input for HackerRank
View read_ints.py
def read_tokens():
return input().strip().split()
def read_ints():
return [int(s) for s in read_tokens()]
a, = read_ints() # 1 int
a, b, c = read_ints() # several
View map_bin_search_res.py
import bisect
# very useful for the following kind of data:
# https://taxfoundation.org/2016-tax-brackets/
cuts = [60, 70, 80, 90]
grades = 'FDCBA'
[grades[bisect.bisect(cuts, score)] for score in [32, 64, 70, 85, 90, 99, 100]]