Skip to content

Instantly share code, notes, and snippets.

@stowell
stowell / natalia.md
Last active August 29, 2015 14:17
Natalia Revuelta Clews

For love of Fidel

Natalia Revuelta Clews, Havana socialite and mistress of Fidel Castro, died on February 27th, aged 89

Mar 21st 2015

WHEN she had been married four years to Orlando Fernández, a cardiologist twice her age, Naty Revuelta grew restless in the big, beautiful house in Vedado. Each morning, when the shutters were opened on the smell of jasmine, her baby Nina would be taken away by the nurse to be fussed and dressed in lace. In the late afternoons, after an unsleeping siesta, her sparkling company might be sought for tennis and canasta parties. Naty was so lovely, with her emerald eyes and dark blonde hair and tiny dancer’s waist, that men would kneel at her feet. Her natural home appeared to be the Biltmore or the Havana Yacht Club, dining on oysters and sweet omelettes from plates of gold. Yet much of her day was spent watching television in the darkened house until the moment when Orlando would return from work and fall asleep in his chair. It was around then, in the spring of 1

@stowell
stowell / language-runtime.md
Last active August 29, 2015 14:25
Language and runtime (from Ryan Dahl)

Language and Runtime.

The separation of concerns between the programming language and the program itself is being muddled in the systems arising today. Hardly any new language is excluding garbage collection from its list of features—something that I’m beginning to form a negative opinion on. I spend my entire day working on top of the V8 VM. For all the complexity inside my laptop the complexity so close to the surface of what I do, V8, is the most impenetrable. The complexity arises not from the task I am attempting to accomplish: to build a fast hello-world web server. The task is simple: issue accept(2), recv(2), send(2), close(2) system calls in that order - over and over and over - but rather from the JavaScript programming language.

The features hanging off many programming languages are questionable. Does writing an ideal hello-world web server in 5 lines of code require garbage collection, operator overloading, classes, meta-programming, constructors, a user-space scheduler, coroutines? Must t

@stowell
stowell / raw.c
Last active February 20, 2016 02:30
raw.c
#include <sys/mman.h>
typedef unsigned int uintf();
int main(int argc, char* argv[]) {
unsigned char* f = mmap(
0, 4096, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (MAP_FAILED == f) {
@stowell
stowell / mapped.c
Created February 20, 2016 02:34
mapped.c
#include <fcntl.h>
#include <sys/mman.h>
typedef unsigned int uintf();
int main(int argc, char* argv[]) {
int fd = open(argv[1], O_RDONLY);
if (-1 == fd) {
@stowell
stowell / justreturn.c
Created February 20, 2016 02:34
justreturn.c
unsigned int justreturn() {
return 243;
}
@stowell
stowell / compiles.c
Created March 2, 2016 18:50
compiles.c
#include <xmmintrin.h>
int main(int argc, char* argv[]) {
__m128 vector1 = _mm_set1_ps(1); // Little endian, stored in 'reverse'
__m128 vector2 = _mm_set1_ps(2);
// Addition
__m128 result = _mm_add_ps(vector1, vector2);
return 0;
}
@stowell
stowell / sigmoid.py
Last active September 20, 2017 01:14
Rigid parser for sigcode
import fileinput
import pprint
import re
blockstartre = re.compile('^(?P<blockname>\S+)\s+is$')
defre = re.compile('^(?P<varname>\S+)\s+is\s+(?P<expr>.+)$')
funcallre = re.compile('(?P<funname>\S+)\s+(?P<funvalue>\S+)')
opcallre = re.compile('(?P<left>\S+)\s+(?P<opname>\S+)\s+(?P<right>\S+)')
@stowell
stowell / word.py
Created September 20, 2017 01:21
Slightly less rigid parser for sigcode
import fileinput
import re
blockdefre = re.compile("^\s*(?P<blockname>\S+)\s+is\s*$")
vardefre = re.compile("^\s*(?P<varname>\S+)\s+is\s+(?P<expr>.+)$")
whitespacere = re.compile("\s+")
def isnumber(word):
@stowell
stowell / phrase.py
Created December 7, 2017 02:28
generate multiple parsings for each line
import fileinput
import re
class Expression(object):
def addexpression(self, expression):
return expression
class Empty(Expression):
set nocompatible
syntax off
" do not put a cr at the end of the file
set binary noeol
" highlighting search results is annoying
set nohlsearch
" show matching brackets