Skip to content

Instantly share code, notes, and snippets.

use async_trait::async_trait;
use core::{future::Future, pin::Pin};
use futures::join;
use http::{header::UPGRADE, StatusCode};
use hyper::{body::HttpBody, client::HttpConnector, Body, Client, Request, Response};
use tracing::debug;
#[async_trait]
pub trait HttpBackend {
async fn make_request(&self, request: Request<Body>) -> crate::error::Result<Response<Body>>;
@gcharnock
gcharnock / jetbrains-toolbox.strace
Created August 22, 2017 11:49
strace of jetbrains toolbox in ni
GC Warning: Failed to expand heap by 402653184 bytes
/nix/store/d6vb0y42apgavxdq4c3dlr2rm39y2h79-jetbrains-fhs
execve("/nix/store/66f85w6hw07gjjsf10pvblf37gl8zc3z-jetbrains-toolbox/jetbrains-toolbox-1.4.2492/jetbrains-toolbox", ["/nix/store/66f85w6hw07gjjsf10pvb"...], [/* 17 vars */]) = 0
brk(NULL) = 0x25b6000
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f07bbaad000
access("/etc/ld-nix.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/run/opengl-driver/lib/tls/x86_64/libfuse.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/run/opengl-driver/lib/tls/x86_64", 0x7fffe4664410) = -1 ENOENT (No such file or directory)
open("/run/opengl-driver/lib/tls/libfuse.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/run/opengl-driver/lib/tls", 0x7fffe4664410) = -1 ENOENT (No such file or directory)
#! /nix/store/r6b2lipkz6mlhzhcnhsh9i3r6wiqdysj-ruby-2.3.3/bin/ruby
#!/usr/bin/env ruby
# Bind mounts hierarchy: from => to (relative)
# If 'to' is nil, path will be the same
mounts = { '/' => 'host',
'/proc' => nil,
'/sys' => nil,
'/nix' => nil,
'/tmp' => nil,
@gcharnock
gcharnock / gist:29cbe573ef555b23e75ab4cb7fa40e9b
Created May 11, 2017 17:29
My take on getting my head around http://theamazingking.com/crypto-diff.php while also learning some Reust
const SBOX: [u8; 16] = [3, 14, 1, 10, 4, 9, 5, 6, 8, 11, 15, 2, 13, 12, 0, 7];
const INV_SBOX: [u8; 16] = [14, 2, 11, 0, 4, 6, 7, 15, 8, 5, 3, 9, 13, 12, 1, 10];
fn toy_cipher(p: u8, k0: u8, k1: u8) -> u8 {
return k1 ^ SBOX[(p ^ k0) as usize];
}
fn find_diffs() -> Vec<Vec<Differential>> {
module Tree
mutual
data Node : (Nat) -> a -> Type where
Leaf : a -> Node 1 a
Node2 : FingerTree n a -> FingerTree m a -> Node (n + m) a
Node3 : FingerTree n a -> FingerTree m a -> FingerTree p a -> Node (n + m + p) a
data FingerTree : Nat -> a -> Type where
Saved package config for ghc-mod-5.0.1 written by Cabal-1.21.0.0 using ghc-7.8
LocalBuildInfo {configFlags = ConfigFlags {configPrograms = [], configProgramPaths = [], configProgramArgs = [], configProgramPathExtra = [], configHcFlavor = Flag GHC, configHcPath = NoFlag, configHcPkg = NoFlag, configVanillaLib = Flag True, configProfLib = Flag False, configSharedLib = NoFlag, configDynExe = Flag False, configProfExe = Flag False, configConfigureArgs = [], configOptimization = Flag NormalOptimisation, configProgPrefix = Flag "", configProgSuffix = Flag "", configInstallDirs = InstallDirs {prefix = Flag "/home/gareth/src/ghc-mod/.cabal-sandbox", bindir = Flag "$prefix/bin", libdir = Flag "$prefix/lib", libsubdir = Flag "$arch-$os-$compiler/$pkgkey", dynlibdir = NoFlag, libexecdir = Flag "$prefix/libexec", progdir = NoFlag, includedir = NoFlag, datadir = Flag "$prefix/share", datasubdir = Flag "$arch-$os-$compiler/$pkgid", docdir = Flag "$datadir/doc/$arch-$os-$compiler/$pkgid", mandir = NoFlag, htmldir = Flag "$d
@gcharnock
gcharnock / thread_template.cpp
Created June 22, 2011 22:03
Code that hangs on barrier.wait()
/*
compile: g++ thread_template.cpp -lboost_thread
Outputs:
BOOST_VERSION = 104200
Starting thread 0
Starting thread 1
Thread 0 waiting for work
Thread 1 waiting for work
@gcharnock
gcharnock / gist:783832
Created January 18, 2011 01:12
Elegant way to walk a tree at compile time - that doesn't work
import std.typetuple;
template staticReduce(alias F,T...) {
static if(T.length==0) {
alias TypeTuple!() staticReduce;
} else static if(T.length==1) {
enum staticReduce=T[0];
} else {
enum staticReduce=staticReduce!(F,TypeTuple!(F!(T[0],T[1]),T[2..$]));
@gcharnock
gcharnock / gist:783771
Created January 18, 2011 00:21
staticReduce template
import std.typetuple;
template staticReduce(alias F,T...) {
static if(T.length==0) {
alias TypeTuple!() staticReduce;
} else static if(T.length==1) {
enum staticReduce=T[0];
} else {
enum staticReduce=staticReduce!(F,TypeTuple!(F!(T[0],T[1]),T[2..$]));
}