Skip to content

Instantly share code, notes, and snippets.

@dwest
dwest / yes.c
Created June 13, 2017 14:58
yes.c mucking about
/* See https://www.reddit.com/r/unix/comments/6gxduc/how_is_gnu_yes_so_fast/ for what this is all about, all credit to the original authors. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main() {
char yes[2] = "y\n";
int pagesize = getpagesize() * 8;
char *buff = malloc(pagesize);

Keybase proof

I hereby claim:

  • I am dwest on github.
  • I am dwest (https://keybase.io/dwest) on keybase.
  • I have a public key whose fingerprint is B550 6D17 2342 65F6 2E99 D0A2 B64E E00A DC55 C4FF

To claim this, I am signing this object:

@dwest
dwest / DOMStringMap IEncodeClojure
Created July 14, 2015 03:22
Convert a DOMStringMap into a Clojurescript object
(extend-type js/DOMStringMap
IEncodeClojure
(-js->clj [x options]
(let [result (atom {})]
(goog.object/forEach x
(fn [val key obj]
(when-not (re-matches #"^cljs.*" key)
(swap! result assoc (keyword key) val))))
(deref result))))