Skip to content

Instantly share code, notes, and snippets.

@danlkv
danlkv / mykey.gpg
Created April 26, 2021 17:06
GPG public key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGNBGCG8nABDACaWwPzmW1Cn1Z4YddKly4ljJyK86xQExW2F00zyqwnpV1V01e4
1WIGKndRsT3QLxsnyxhfBENvf/tEyB/PHE/ujVE7+ZJliazWFaWa8wmC7gfgdxGE
QkTqVx5orKp+KSJKPtFGUr/6mSqiKcLv2HjyEciVDu31k+0qLqQeAaWqU33tgref
bpbjI3Qil9El6+dwjY/5ICRCfm4l7MLBoHR94PsRWuhnEUC6/UjyjdPjyyCKb/dm
fo5aFx+ibpal16SVsPffPjmZg0WG4vjrfyiomRazn27n0i0j4hL2jh6fzNJty0oe
U4QjakZmFp28sRhtyulTKvPBN/HlVrbz3bzhZa1xLPkM6PsgsZNZ76AaZFmeJ3qv
e3mYKHOVoKqywNMS4P3bOd7seJSeVwKqUHxU4fX2yXkVYHtMYStuiWDeX3pap2Y2
jlXzA/S/kN+EqQD9rElmsNoQVyWjibwikpf601E4I0fHmJugcaIrsNQDUOUZd7/R
@danlkv
danlkv / test_treebo_task_6_queue_timeout.md
Last active November 4, 2020 16:52
Test task: queue with timeout

Queue with timeout

A FIFO (First in first out) queue has two main methods:

  1. put(), with puts an element to the queue,
  2. get(), which returns next element.

If queue is empty, get() blocks.

Task

@danlkv
danlkv / test_treebo_task_5_github_api.md
Created November 3, 2020 17:30
Test task: Github API

Filter commit history of github

Task

Get commits of a repository and return info about commits that contain a search query (string) in commit message.

Inputs:

  1. Repository url
  2. String to search for
@danlkv
danlkv / test_treebo_task_4_health_event_notifier.md
Last active November 2, 2020 05:48
Test task: System health event notifier

System health event notifier

Problem setting

Suppose you have a remote system behind an API. The system is reactive: you send something to it, and it is expected to do something in result. There is an API endpoint (sink) that receives requests and a callback (source) that sends responses.

Sink is just a python function that eventually calls an http endpoint. Source could be implemented as webhook or a generator, but we'll focus on the latter case.

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC8tWC2RnWqGNzcsZRkvi2TGltGf+zyM+9w9A2LHqeG8UnVy3/Pu+njmz3I6GWLGOXrRUU5HGJdTxl2UG7qVgMVVVjVwrV9EOgj4We5e6kYNUnCay9sVIgKRpxJeNo1mwBHEXzryAoNNbgGCMTpA+kEc8SAMAsoahFP/nHdYZqRXd5UxG25AmpczOe6FiaktyUjinfTnfMVAGVvrEm7OVgeXfUriBp6Mjjg9ZRHc02f3miHMywFZWkxqaEkTsM0gubymt8ivXGbY8p7/Gk2xpF958yACoZXvxH7amyUekaDKAE2S8Xhur+HeGZTw/YCbCDQZ0iA/MCBNkAmOu0/1Zppdip8rBhT9EPAu/hUy3DaOk+NXW/nZnlV4FL+hiity82oVqInX/TQvD5SA7d5WbxvvpYcBlCdY19BGqt2pzH1Y8B6BptfpYw1duxJE4eJ2MghvM7faSnScx48m9/FYgkv7fzGqwSWGtvi2+Q8zPPL1x53iB3lFQrdykFOoHEug38= dali@archlinux
@danlkv
danlkv / cmake
Last active June 17, 2020 22:14
Exatn install fails
-- The CXX compiler identification is GNU 10.1.0
-- The Fortran compiler identification is GNU 10.1.0
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working Fortran compiler: /usr/bin/gfortran

Webhook url, Integromat->Treebo

http://test.treebo.io:5002/webhooks/generic_webhook/test123

POST request. Payload format - JSON

{
    phone: str,

text: str

UNIX Philosophy

  1. Write programs that do one thing and do it well.
  2. Write programs to work together.
  3. Write programs to handle text streams, because that is a universal interface.

Different concerns

  • Parse the file
  • Simulate circuit

Interpolate dict

Intro

Let's say you have a text string that greets a person, 'Hello, Mark!'. If you write a program for this greeting you might want to compose the string for any name of the person. One way to do this is to have a template string, 'Hello, ${user_name}!' and then use a function that will replace the ${...} with value of variable user_name. This is usually called string interpolation.

We want to have a dict interpolation, where the same is done for a nested structure. For example, if you have a dictionary, {'user':'User_id${uid}'}, and a variable uid=1, we want to get

Timer module

Implement functionality of a timer in event-action paradigm.

The API of the timer should be the following:

class TimerModule:
  
 ## Actions