Skip to content

Instantly share code, notes, and snippets.

"""
In one of the neighborhoods in Sofia, there's a very popular drinking game, called Game of Bottles.
The game is unusual, because it combines math & drinking:
In a standard 2D plain (usually a football field), different bottles are arranged. Each bottle has position, described by (x, y) coordinates.
In order to walk between bottles, you can use only horizontal and vertical lines - no diagonals.
You can visit a bottle only once.
Your task is to find the best way(s) to walk between bottles that will give you the smallest walking distance.
"""
You are playing a coin-flipping game with your friend.
The rules are:
You toss a coin n times, writing down the results. H for heads and T for tails.
After n tosses, the winner is the one who has the longest consecutive win-streak.
Write a program that reads from the standard input one line - a comma-separated string of H and T and outputs:
H wins! if H wins according to the game rules.
'''
We are living in 2D world and we are running out of water! We are migrating to KEPLER-186F, the new planet that NASA discovered, but it is a slow migration because that planet is far far away.
Luckily we still have some big lakes full of clean water. We need to know exactly how much water is in every lake.
Write a program that takes the lake structure and calculates the amount of water there.
Few important things:
Our lakes live in a 2D grid of 1x1 squares.
"""
Strings and Numbers
You are given a string s that consists of characters, that encode digits & characters that encode nothing. Your goal is to return the sum of all numbers in that string.
Number encoding
In our string s, the digits from 0 to 9 are encoded as follows:
9 is encoded with the most repeated character in s.
@stanislavkozlovski
stanislavkozlovski / pika.py
Created October 5, 2017 07:33
A consumer connection via Pika
class BaseRabbitMQConsumerConnection:
"""
This is the base class of a RabbitMQ consumer, it sets up and maintains the connection.
Classes should inherit this and define the needed static variables to be able to properly set up a connection
A handler object must also be sent, one who processes the message. see: on_message method
The RabbitMQ connection which is part of the async event loop and receives notifications for it to send out
If RabbitMQ closes the connection, it will reopen it. You should
look at the output, as there are limited reasons why the connection may
https://github.com/defunkt/gist.git
https://github.com/defunkt/gist.git

Quickrun a test on a single agent node

export JSON_SPEC=./tests/spec/simple_produce_bench.json # JSON file with the appropriate specification
./bin/trogdor.sh agent -n node0 -c ./config/trogdor.conf --exec $JSON_SPEC

Spin up Trogdor cluster consisting of 1 Agent and the Coordinator

./bin/trogdor.sh coordinator -c ./config/trogdor.conf -n node0
./bin/trogdor.sh agent -c ./config/trogdor.conf -n node0
KafkaService-0-140353367942288
├── worker7
│   ├── kafka-data-logs-1
│   │   ├── __consumer_offsets-1
│   │   ├── __consumer_offsets-2
│   │   └── test_topic_1-0
│   └── kafka-data-logs-2
│   ├── __consumer_offsets-0
│   └── test_topic_2-0
├── worker8