Skip to content

Instantly share code, notes, and snippets.

@polachok
polachok / gist:ab0937985d57b0398ad8
Last active July 7, 2023 13:50
Building statically linked binaries with rust

glibc is not statically linkable (because reasons, mainly nss), so you have to link against another libc. Fortunately, rust developers made binary builds of std linked with musl libc available in beta and nightly channels. Which means that all you need is:

  • std linked with musl

    • http://static.rust-lang.org/dist/$(date -v -1d +'%Y-%m-%d')/rust-std-beta-x86_64-unknown-linux-musl.tar.gz
  • "normal" std for build scripts

    • http://static.rust-lang.org/dist/$(date -v -1d +'%Y-%m-%d')/rust-std-beta-x86_64-unknown-linux-gnu.tar.gz
@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> {
[/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");
@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,
}
package main
import "syscall"
import "log"
import "runtime"
import "flag"
import "fmt"
import "strconv"
import "os"
import "os/signal"
@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