This file contains hidden or 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
| #![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" |
This file contains hidden or 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
| extern crate hyper; | |
| extern crate futures; | |
| use hyper::{Body, Method, Request, Response, StatusCode}; | |
| use hyper::server::Service; | |
| use futures::future::Future; | |
| struct SomeAPIService; |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| """ | |
| 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 |
This file contains hidden or 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
| // 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, |
This file contains hidden or 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
| filetype indent plugin on | |
| nnoremap <C-S-Down> :m .+1<CR>== | |
| nnoremap <C-S-Up> :m .-2<CR>== |
This file contains hidden or 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
| 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( |
This file contains hidden or 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
| pub fn generate_primes(max: u64) -> Vec<u64> { | |
| let mut candidates: Vec<u64> = 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; |
This file contains hidden or 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
| 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 { |
OlderNewer