Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Mirko Bonasorte fcracker79

🎯
Focusing
Block or report user

Report or block fcracker79

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pymi_passages.py
import datetime
import random
import typing
import unittest
from collections import OrderedDict
class Passage:
def __init__(self, aos: datetime.datetime):
self.aos = aos
@fcracker79
fcracker79 / kafka-cheat-sheet.md
Created Apr 8, 2018 — forked from ursuad/kafka-cheat-sheet.md
Quick command reference for Apache Kafka
View kafka-cheat-sheet.md

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

View join_generators.py
import itertools
import typing
from pprint import pprint
def full_join(d1: typing.Optional[dict], d2: typing.Optional[dict]) -> typing.Optional[dict]:
if d1 is None or d2 is None:
return None
return {k: d1.get(k, d2.get(k)) for k in itertools.chain(d1, d2)}
View add_method.py
import collections
_ApiMethod = collections.namedtuple('_ApiMethod', ['name', 'path', 'http_method', 'query_params'])
API = [
_ApiMethod('print_hello', 'api/hello', "GET", ['limit']),
]
View search.py
import itertools
import pprint
import typing
_SELECTED = 5
_MAX_VALUE = 40
values = list(range(1, _MAX_VALUE + 1))
_REQUIRED_SUM = _MAX_VALUE // 2
View subprocess.py
import subprocess
class RunCmd(object):
def __init__(self, cmd):
self.cmd = cmd
def cmd_run(self):
subprocess.call(self.cmd, shell=True)
View defaults.py
import itertools
def a_default_value():
return 1
def b_default_value():
return 'hello'
@fcracker79
fcracker79 / readloud.rs
Created Jun 29, 2019
RustHero Rustlab Florence 2019
View readloud.rs
use std::str;
struct ReadLoud<'a> {
current_element: Option<u32>,
numbers_iterator: str::Chars<'a>,
next_elements: Vec<u32>
}
impl <'a> ReadLoud<'a> {
View gist:e51b6bcb123188627a3fdb008e6c38ef
struct NiceStructure<'a, T: Iterator<Item=&'a u32>> {
it: T
}
fn f<'a, T: Iterator<Item=&'a u32>>(it: &mut NiceStructure<'a, T>) {
// This does not work: cannot move out of borrowed content
// for x in it.it {
// println!("Element {:?}", x);
// }
// This works
View gist:2a895137b8874a40d4bd4854a7f509be
use std::sync::Arc;
use std::thread;
use std::time::Duration;
fn main() {
let ref_counter = Arc::new(true);
for i in 0..10 {
let cur_ref_counter = Arc::clone(&ref_counter);
thread::spawn(move || {
thread::sleep(Duration::from_secs(i + 1));
You can’t perform that action at this time.