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
| use std::sync::mpsc; | |
| use std::thread; | |
| pub fn start_counter() -> (mpsc::Sender<u64>, thread::JoinHandle<()>) { | |
| let (sender, receiver) = mpsc::channel::<u64>(); | |
| let join_handle = thread::spawn(move || { | |
| let mut counter: u64 = 0; | |
| for msg in receiver { | |
| counter = counter + msg; |
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
| const calculate = (n, k) => { | |
| const exponent = (-k * (k - 1)) / (2 * n) | |
| return 1 - Math.E ** exponent | |
| } | |
| // where `n` is the number of possible unique hashes | |
| // where `k` is the number of values created | |
| // calculate(100000, 25) => 0.0029955044966269995 aka 0.29% chance of collision |
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
| openapi: 3.0.0 | |
| info: | |
| title: Suggest API v1.0 | |
| version: '1.0' | |
| description: Location suggestions for tickets search. | |
| contact: | |
| name: Pavel Lazureykis | |
| email: lazureykis@gmail.com | |
| url: 'https://t.me/lazureykis' | |
| servers: |
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
| docker rm $(docker ps -q -f 'status=exited') | |
| docker rmi $(docker images -q -f 'dangling=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
| #!/bin/sh | |
| ps aux | grep ruby | grep -v grep | awk '{print $2}' | xargs kill |
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
| module Middleware | |
| class Logger | |
| def initialize(app, logger) | |
| @app = app | |
| @logger = logger | |
| end | |
| def call(env) | |
| headers = env.select {|k,v| k.start_with? 'HTTP_'} |
go build -buildmode=c-shared -o sum.so sum.go
ruby link.rb
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
| [core] | |
| repositoryformatversion = 0 | |
| filemode = true | |
| bare = false | |
| logallrefupdates = true | |
| pager = "less" | |
| [format] | |
| pretty = "oneline" | |
| [color] | |
| ui = auto |