Skip to content

Instantly share code, notes, and snippets.

M Farkas-Dyck strake

Block or report user

Report or block strake

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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
View rust-2018.md

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
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
strake / htgk.rc
Last active Dec 24, 2015
HyperText GateKeeper: All requests go to given CGI script.
View htgk.rc
#!/bin/rc
fn hdrs {
ifs='
' while ( x=`{ read | sed 's/:[ ]*/:/' } && ! ~ $#x 0) {
v=`{ echo $x | sed 's/:.*//' | tr - _ }
x=`{ echo $x | sed 's/^[^:]*:[ ]*//' }
HTTP_$v=$x
}
}
You can’t perform that action at this time.