Skip to content

Instantly share code, notes, and snippets.

@polachok
polachok / faq.md
Last active Sep 15, 2018
Futures & tokio FAQ (ru)
View faq.md

Что такое future?

Future это тип, для которого имплементирован трейт Future

Кто вызывает poll()?

Executor. Это может быть ивент-луп, тред пул или что-то еще.

@polachok
polachok / time.rs
Created Mar 29, 2018
chrono ser/de
View time.rs
```
#[derive(Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize, Hash)]
pub struct Time {
// utc timestamp
timestamp: i64,
// timezone offset
offset: i32,
}
@polachok
polachok / yeah_sure.txt
Created May 19, 2017
Go doesn't use libc
View yeah_sure.txt
$ cat test.go
package main
import "os/user"
func main() {
_, _ = user.Current()
}
$ go build test.go
$ gdb ./test
View framed_delimited.rs
struct FramedTransport<T, C> where T: AsyncRead + AsyncWrite + 'static {
inner: length_delimited::Framed<T>,
codec: C,
}
fn framed_delimited<T, C>(framed: length_delimited::Framed<T>, codec: C) -> FramedTransport<T, C>
where T: AsyncRead + AsyncWrite, C: codec::Encoder + codec::Decoder
{
FramedTransport{ inner: framed, codec: codec }
}
@polachok
polachok / cpuinfo
Created Apr 14, 2017
Is hyper slow?
View cpuinfo
vendor_id : GenuineIntel
cpu family : 6
model : 63
model name : Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
stepping : 2
microcode : 0x2e
cpu MHz : 3040.039
cache size : 30720 KB
physical id : 0
siblings : 24
View hub.txt
_____ _____ _____
/\ \ /\ \ /\ \
/::\____\ /::\____\ /::\ \
/:::/ / /:::/ / /::::\ \
/:::/ / /:::/ / /::::::\ \
/:::/ / /:::/ / /:::/\:::\ \
/:::/____/ /:::/ / /:::/__\:::\ \
/::::\ \ /:::/ / /::::\ \:::\ \
/::::::\ \ _____ /:::/ / _____ /::::::\ \:::\ \
/:::/\:::\ \ /\ \ /:::/____/ /\ \ /:::/\:::\ \:::\ ___\
View api.rs
impl AmqpClient {
fn call(&mut self, Request::Channel::Open) -> Future<Channel, AmqpError>
}
impl Channel {
fn declare_queue(&mut self, name: AsRef<str>) -> Future<Queue, AmqpError>
}
impl Queue {
fn consume(&mut self) -> Future<MessageStream, AmqpError>
View lol.txt
[/tmp]% cat test.txt
0
[/tmp]% cat test.php
<?php>
$file = fopen("test.txt", "r");
$buf = '';
while ($buf = fread($file, 1)) {
echo("inside\n");
}
echo("outside\n");
View keybase.md

Keybase proof

I hereby claim:

  • I am polachok on github.
  • I am plhk (https://keybase.io/plhk) on keybase.
  • I have a public key ASASwe7c2tZcJuWggPQoUVWkTx23g7XgkUC955QQVCbk5Ao

To claim this, I am signing this object:

View sukapizdets.txt
fatal error: concurrent map read and map write
goroutine 565633 [running]:
runtime.throw(0x1fb2020, 0x21)
/usr/local/go/src/runtime/panic.go:547 +0x90 fp=0xc8213895a0 sp=0xc821389588
runtime.mapaccess2_faststr(0x175d060, 0xc820a961b0, 0xc821b0f100, 0xf, 0xc8209e8a48, 0x6fc601)
/usr/local/go/src/runtime/hashmap_fast.go:307 +0x5b fp=0xc821389600 sp=0xc8213895a0
github.com/docker/libnetwork.(*sandbox).resolveName(0xc8208ce1e0, 0xc821b0f100, 0xf, 0x1dc7b28, 0x0, 0xc8214ad760, 0x1, 0x1, 0x1dd7200, 0x2, ...)
/go/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/sandbox.go:585 +0x383 fp=0xc8213896f0 sp=0xc821389600
github.com/docker/libnetwork.(*sandbox).ResolveName(0xc8208ce1e0, 0xc821b0f100, 0xf, 0x2, 0x0, 0x0, 0x0, 0x0)