Skip to content

Instantly share code, notes, and snippets.

version: '2'
networks:
custom:
driver: bridge
ipam:
driver: default
config:
-
subnet: 172.16.238.0/24
@kpp
kpp / test.rs
Created September 26, 2017 14:39
use nom::*;
use cookie_factory::*;
use bytes::BytesMut;
use std::io;
use tokio_io::codec::{Decoder, Encoder};
trait FromBytes : Sized {
fn from_bytes(i: &[u8]) -> IResult<&[u8], Self>;
}
@kpp
kpp / test.rs
Created September 29, 2017 15:09
use nom::*;
use cookie_factory::*;
use bytes::BytesMut;
use std::io;
use tokio_io::codec::{Decoder, Encoder};
trait FromBytes : Sized {
fn from_bytes(i: &[u8]) -> IResult<&[u8], Self>;
}
@kpp
kpp / tcp server.md
Last active December 20, 2017 14:15
TCP_Secure_Connection
  status: NO_STATUS | CONNECTED | UNCONFIRMED | CONFIRMED
  identifier: UID, autoincremented across all connections in TCP_Server
  public_key: PK of the connection (taken from handshake)
  connections: inited with zeros, keeps links to clients to communicate with
    NUM_CLIENT_CONNECTIONS: (256 - NUM_RESERVED_PORTS)
    NUM_RESERVED_PORTS: 16
    struct {
        uint8_t status; /* 0 if not used, 1 if other is offline, 2 if other is online. */
@kpp
kpp / snake.sh
Created December 7, 2017 20:26
Snake game written in bash shell script
#!/bin/bash
# author: sir@cmpwn.com
# Run ./snake.sh
# Arrow keys or wasd to move
c=`tput cols`;L=`tput lines`
let x=$c/2;let y=$L/2;d=0;le=3;t="$y;$x";i=0;j=0;S=0
A(){ let i=($RANDOM%$c);let j=($RANDOM%$L);};A
B(){ printf $*;};C(){ B "\x1B[$1";};D(){ C "$1H";}
F(){ D "0;0";C 2J;C "?25h";printf "GAME OVER\nSCORE: $S\n";exit;};trap F INT
@kpp
kpp / miths.md
Last active February 26, 2018 14:24
habr article

Эта статья - квинтэссенция срача.

Q. Безопасен ли Rust? Можно ли его использовать в проде?

A. Институт программных систем Общества Макса Планка плотно занимается этой проблемой в проекте под названием RustBelt. На январь 2018 формально(sic!) доказаны следующие постулаты:

  • Система типов, принципы владения (ownership), времени жизни (lifetime) корректны
  • Программа безопасна, если все участки кода внутри unsafe безопасны
humbug@home:~/zetox$ git diff | cat
diff --git a/Cargo.toml b/Cargo.toml
index 9206765..b4f0b15 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -33,7 +33,7 @@ bytes = "0.4"
byteorder = "1"
futures = "0.1"
log = "0.4"
-sodiumoxide = "0.0.16"
language: rust
os:
- linux
- osx
rust:
- 1.26.0
- stable
- beta
- nightly
@kpp
kpp / Cargo.toml
Created December 11, 2018 10:52
Heapless string for comrade qw1
[package]
name = "stack_string"
version = "0.1.0"
authors = ["Roman Proskuryakov <humbug@deeptown.org>"]
edition = "2018"
[dependencies]
libc = { version = "0.2", default-features = false }
heapless = { version = "0.4" }
extern crate common;
use common::measure_and_print;
use std::collections::{BinaryHeap, HashMap};
use std::io;
#[derive(Debug, Eq, PartialEq)]
enum NodeKind {
Leaf(u8),
Branch(Box<Node>, Box<Node>),