Skip to content

Instantly share code, notes, and snippets.

@polachok
polachok / twisted.txt
Created April 6, 2022 16:46
nix-shell on ubuntu
$ nix-shell https://github.com/NixOS/nixpkgs/archive/941b4b8f048a383366e24c12022e99c87db09db6.tar.gz -A python39Packages.twisted
Sourcing python-remove-tests-dir-hook
Sourcing python-catch-conflicts-hook.sh
Sourcing python-remove-bin-bytecode-hook.sh
Sourcing setuptools-build-hook
Using setuptoolsBuildPhase
Using setuptoolsShellHook
Sourcing pip-install-hook
Using pipInstallPhase
Sourcing python-imports-check-hook.sh
{ config, pkgs, ... }:
{
imports =
[
./hardware-configuration.nix
];
nixpkgs.config = {
allowUnfree = true;
packageOverrides = pkgs: {
unstable = import <nixos-unstable> {
@polachok
polachok / faq.md
Last active September 15, 2018 22:06
Futures & tokio FAQ (ru)

Что такое future?

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

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

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

@polachok
polachok / time.rs
Created March 29, 2018 21:07
chrono ser/de
```
#[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 12:21
Go doesn't use libc
$ cat test.go
package main
import "os/user"
func main() {
_, _ = user.Current()
}
$ go build test.go
$ gdb ./test
@polachok
polachok / framed_delimited.rs
Created May 16, 2017 16:05
Framed delimited?
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 April 14, 2017 08:52
Is hyper slow?
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
_____ _____ _____
/\ \ /\ \ /\ \
/::\____\ /::\____\ /::\ \
/:::/ / /:::/ / /::::\ \
/:::/ / /:::/ / /::::::\ \
/:::/ / /:::/ / /:::/\:::\ \
/:::/____/ /:::/ / /:::/__\:::\ \
/::::\ \ /:::/ / /::::\ \:::\ \
/::::::\ \ _____ /:::/ / _____ /::::::\ \:::\ \
/:::/\:::\ \ /\ \ /:::/____/ /\ \ /:::/\:::\ \:::\ ___\
@polachok
polachok / api.rs
Last active December 22, 2016 21:24
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>
[/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");