Skip to content

Instantly share code, notes, and snippets.

let directions = &["down", "left", "up", "right"];
while !stop {
for direction in directions {
turn += 1;
for _ in 0..times {
if counter < numbers_len {
stop = self.move_cursor(&mut x, &mut y, direction);
if numbers[counter] == 1 {
pub fn generate_primes(max: u64) -> Vec&lt;u64&gt; {
let mut candidates: Vec&lt;u64&gt; = vec![1; max as usize + 1];
candidates[0] = 0;
candidates[1] = 0;
let max_sqrt = (max as f64).sqrt() as u64 + 1;
for number in 2..max_sqrt {
let mut multiplied = number * number;
while multiplied < max + 1 {
candidates[multiplied as usize] = 0;
import time
from ansible.utils import display
from ansible.module_utils.basic import *
import logging
import logging.handlers
LOG_PATH = '/tmp/hi.log'
log_handler = logging.handlers.WatchedFileHandler(filename=LOG_PATH)
formatter = logging.Formatter(
@sireliah
sireliah / .vimrc
Created January 20, 2019 22:45
vimrc
filetype indent plugin on
nnoremap <C-S-Down> :m .+1<CR>==
nnoremap <C-S-Up> :m .-2<CR>==
@sireliah
sireliah / sublime_configs.json
Created January 4, 2019 09:53
sublime configs
// Anaconda
{
"pep8_max_line_length": 119,
"pep8": true,
"python_interpreter": "python3.7",
"anaconda_linting": true,
"mypy": true,
"mypy_mypypath": "/usr/bin/mypy",
"mypy_silent_imports": true,
@sireliah
sireliah / tree_scraper.py
Last active May 3, 2020 10:31
Scrapper to get trees from mapa.um.warszawa.pl
"""
Scraper that gets the tree data from mapa.um.warszawa.pl for given boundaries.
Note that:
- EPSG:2178 projection is used (http://spatialreference.org/ref/epsg/2178/)
- Coordinates range for Warsaw are simplified to fit in a box
- the box is divided into 2000x2000 tiles to reduce the request size
Bxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
Thoughts on the archeology of code
Software development as a part of human culture.
Programming is commonly considered highly logical and strict process that is related rather to mathematics and "science" rather than antropology or even humanities. But is it indeed?
High level code such as Python or Java is designed to resemble the natural language to make programming effort more natural and easier for human programmers. In the early days of computing, writing programs was much more closely related to the actual binary operations executed on the machine level. If you wanted to calculate a logarithm of an natural number, there was no built in function. You had only a couple of hardware implemented operations in the ALU (Arithmetic Logic Unit) such as AND/OR, addition, bit shift and you needed to perform them on the binary level and then interpret the result as an integer. This is how EDVAC computer worked.
High level code came with
Kafka messages are ethernal
Kafka is wonderful tool for building event driven systems and it's becoming more and more popular every year. Many companies use Kafka as just message bus, but some use Kafka as source-of-truth for event sourced platforms.
If you are playing with event sourcing, there is a good chance that you have topics that have very long retention time - maybe months or more. It means that the message once pushed to the topic will be there for a while, because your application will consume messages from a topic many times. I won't go into details, but key idea of event sourcing is keeping the history (in the correct order) of all changes applied to some object, let's say - contents of shopping cart.
The funny fact about Kafka is that if you push a message to a topic, the message will stay there unchanged, because messages in Kafka are immutable. That's fine, right? No one will mess with your history. But wait, if no one can change messages and your topic will keep them for months or even ye
extern crate hyper;
extern crate futures;
use hyper::{Body, Method, Request, Response, StatusCode};
use hyper::server::Service;
use futures::future::Future;
struct SomeAPIService;
@sireliah
sireliah / huffman_coding_implementation.rs
Last active June 11, 2017 17:06
My attempt to implement Huffman coding algorithm in Rust
#![feature(box_patterns, box_syntax)]
use std::collections::HashMap;
/// "z" is our lifetime parameter.
#[derive(Debug)]
struct Node<'z> {
symbol: &'z str,
prob: f32,
/// Box reallocates the node from stack to heap. Otherwise, the compiler will complain that "recursive type `Node` has infinite size"