Skip to content

Instantly share code, notes, and snippets.

View povilasb's full-sized avatar
🏗️

Povilas Balciunas povilasb

🏗️
View GitHub Profile
@povilasb
povilasb / task1.cpp
Last active February 19, 2021 08:08
Misc simple C++ samples
#include <iostream>
using namespace std;
class Rectangle {
public:
int width;
int height;
Rectangle(int width, int height) {
this->width = width;
@povilasb
povilasb / netsim.md
Created May 16, 2019 15:01
netsim 5 min presentation
<domain type='kvm'>
<name>reactos</name>
<uuid>3ea9f890-f2d9-4c25-b6c7-fb14e254f14c</uuid>
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
<vcpu placement='static'>2</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-2.11'>hvm</type>
<boot dev='hd'/>
</os>
@povilasb
povilasb / socket_buffers.py
Created April 9, 2019 09:46
socket TX/RX buffer sizes
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
w_buf = sock.getsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF)
r_buf = sock.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF)
print(w_buf, r_buf)
thread 'Crust-Event-Loop' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:345:21
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:70
@povilasb
povilasb / quinn_panic.txt
Created April 4, 2019 06:50
smth is wrong with the timestamps
thread 'Crust-Event-Loop' panicked at 'specified instant was later than self', src/libstd/sys/unix/time.rs:292:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:70
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:58
at src/libstd/panicking.rs:200
@povilasb
povilasb / test_connection.rs
Last active April 3, 2019 10:02
quinn connection drop tests
use unwrap::unwrap;
use std::sync::Arc;
use std::cell::RefCell;
use std::rc::Rc;
use tokio::runtime::current_thread::{self, Runtime};
use futures::{future, Future, Stream};
struct TestContext {
/// Hold connections so that streams wouldn't be closed prematurely
connections: Vec<quinn::Connection>,

Keybase proof

I hereby claim:

  • I am povilasb on github.
  • I am povilasb (https://keybase.io/povilasb) on keybase.
  • I have a public key whose fingerprint is 8AB4 799B 3E90 98A2 0226 03D0 7C08 9599 2F98 4CA8

To claim this, I am signing this object:

@povilasb
povilasb / socket_limits.py
Last active February 6, 2019 17:47
Try to bind as many UDP/TCP sockets as possible
import socket
from typing import List
def main():
socks = udp_sockets(1021)
print(len(socks))
def udp_sockets(n: int) -> List[socket.socket]:
#[cfg(target_os = "linux")]
#[test]
fn keep_alive() {
let mut evloop = Core::new().unwrap();
let network = Network::new(&evloop.handle());
let network_handle = network.handle();
let (server_addr_tx, server_addr_rx) = oneshot::channel();
let (plug_client, mut plug_server) = IpPlug::new_pair();