Skip to content

Instantly share code, notes, and snippets.

View tnull's full-sized avatar

Elias Rohrer tnull

View GitHub Profile
@tnull
tnull / sort_compare.rs
Last active March 21, 2022 19:32
Compare different `sort` variants for LDK's `get_route`.
let mut paths_cached = payment_paths.clone();
let instant_cached = Instant::now();
paths_cached.sort_by_cached_key(|path| path.get_total_fee_paid_msat());
println!("Cached sort took: {}", instant_cached.elapsed().as_nanos());
let mut paths_unstable = payment_paths.clone();
let instant_unstable = Instant::now();
paths_unstable.sort_unstable_by_key(|path| path.get_total_fee_paid_msat());
println!("Unstable sort took: {}", instant_unstable.elapsed().as_nanos());
data OwnRecord = OwnRecord { key :: String
, testList :: [Float]
}
testMap :: String -> [Float] -> M.Map String OwnRecord
testMap s fs = foldl (\acc x -> M.insertWith update s x acc) M.empty fs
where
update (OwnRecord s newList) (OwnRecord s oldList) = OwnRecord s (oldList ++ newList)
@tnull
tnull / optparse.hs
Created August 14, 2019 12:06
Optparse
import qualified Options.Applicative as OA
data AppArgs =
AppArgs
{ inFilePath :: !String
, outFilePath :: !String
, sampleFilter :: !Int
}
deriving (Show)
### Keybase proof
I hereby claim:
* I am tnull on github.
* I am tnull (https://keybase.io/tnull) on keybase.
* I have a public key whose fingerprint is FADE EF4A 1161 B73D 852C C16E 4DDE 50E8 1D58 58C3
To claim this, I am signing this object:
@tnull
tnull / erlang_elixir_install.sh
Last active September 20, 2016 14:15
Little script to install erlang 19.0 with dirty schedulers, ssl and hipe support and elixir 1.3.2 (using kerl & kiex)
#!/bin/sh
DESTDIR="$HOME/workspace"
ACTIVATE="$DESTDIR/erlang/activate"
mkdir -p "$DESTDIR"
cd "$DESTDIR"
# get dependencies
sudo apt install autoconf libncurses-dev build-essential libssl-dev m4
@tnull
tnull / newpost.rb
Last active August 29, 2015 14:08 — forked from al3x/newpost.rb
Small ruby script to create a new jekyll post, open the editor, start 'jekyll serve' and open the localhost site in a browser.
#!/usr/bin/env ruby
unless ARGV[0]
puts 'Usage: newpost "the post title"'
exit(-1)
end
jekyll_site_prefix = "."
editor = "open -a Byword"
date_now = Time.now