Skip to content

Instantly share code, notes, and snippets.


M Farkas-Dyck strake

View GitHub Profile
strake / with-ghc
Created Feb 21, 2020
Script to do a shell command with the given GHC version in the PATH
View with-ghc
PATH="$HOME/.ghcup/ghc/$v/bin:$PATH" exec "$@"
View OrdNub.hs
module OrdNub where
import qualified Data.Set as Set
ordNubOn :: Ord b => (a -> b) -> [a] -> [a]
ordNubOn f = go Set.empty
where go _ [] = []
go s (x:xs) | f_x `elem` s = go s xs
| otherwise = x : go (Set.insert f_x s) xs
where f_x = f x

Rust 2018

To begin, let me make this clear: I like Rust. It's a very useful tool, despite the following complaints, and the only one i use for serious systems programming any more. (I was making my own language, but really like having some nice other people do all that hard work for me, so thank you, Rust devs!)

That said, it could be better.

The Standard Library

The standard library has a major flaw: it aborts on failure to allocate memory. This is unacceptable in many of my use cases [1]. If it is acceptable, i am using Haskell, and trust me: you really want to not be competing with Haskell (and its ilk). It is frustrating as it would be easy to use/wrap a fallible API infallibly [2], but not vice versa.

strake / tcpsrv.c
Last active Dec 24, 2015
TCP server: spawn arguments with each connection on fds 0, 1
View tcpsrv.c
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <err.h>
int setreuseaddr (int s, int v) {
strake / htgk.rc
Last active Dec 24, 2015
HyperText GateKeeper: All requests go to given CGI script.
View htgk.rc
fn hdrs {
' while ( x=`{ read | sed 's/:[ ]*/:/' } && ! ~ $#x 0) {
v=`{ echo $x | sed 's/:.*//' | tr - _ }
x=`{ echo $x | sed 's/^[^:]*:[ ]*//' }
You can’t perform that action at this time.