Skip to content

Instantly share code, notes, and snippets.

View causal-agent's full-sized avatar

june causal-agent

View GitHub Profile
@causal-agent
causal-agent / babyjit.c
Created October 13, 2016 03:09
Baby's First JIT
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/mman.h>
#include <unistd.h>
#include <err.h>
#include <sysexits.h>
typedef int32_t (*fptr)(int32_t);
use std::ops::{Range, RangeFrom, RangeTo};
pub trait RangeExt<T> {
fn before(&self) -> RangeTo<T>;
fn after(&self) -> RangeFrom<T>;
}
impl<T: Copy> RangeExt<T> for Range<T> {
fn before(&self) -> RangeTo<T> {
..self.start
@causal-agent
causal-agent / repro.sh
Created February 20, 2015 04:03
Postgres dump view defined with VALUES drops column names (PostgreSQL 9.4.1 on Mac OS X 10.10.1 installed via Homebrew)
set -v
dropdb --if-exists repro
dropdb --if-exists repro-restore
createdb repro
createdb repro-restore
# Create a view with named columns defined with VALUES
psql repro -c "CREATE VIEW repro_view (my_column) AS VALUES (1);"

So, there's a man crawling through the desert.

He'd decided to try his SUV in a little bit of cross-country travel, had great fun zooming over the badlands and through the sand, got lost, hit a big rock, and then he couldn't get it started again. There were no cell phone towers anywhere near, so his cell phone was useless. He had no family, his parents had died a few years before in an auto accident, and his few friends had no idea he was out here.

He stayed with the car for a day or so, but his one bottle of water ran out and he was getting thirsty. He thought maybe he knew the direction back, now that he'd paid attention to the sun and thought he'd figured out which way was north, so he decided to start walking. He figured he only had to go about 30 miles or so and he'd be back to the small town he'd gotten gas in last.

He thinks about walking at night to avoid the heat and sun, but based upon how dark it actually was the night before, and given that he has no flashlight, he's afraid that he'll break a l