Skip to content

Instantly share code, notes, and snippets.

View jorendorff's full-sized avatar

Jason Orendorff jorendorff

View GitHub Profile
~/play/sine/timings$ make
c++ -O2 -std=c++11 -c -o clock_gettime.o clock_gettime.cc
c++ -O2 -std=c++11 -c -o lib.o lib.cc
c++ -O2 -std=c++11 clock_gettime.o lib.o -o clock_gettime
c++ -O2 -std=c++11 -c -o fwrite.o fwrite.cc
c++ -O2 -std=c++11 fwrite.o lib.o -o fwrite
c++ -O2 -std=c++11 -c -o mutex.o mutex.cc
c++ -O2 -std=c++11 mutex.o lib.o -o mutex
c++ -O2 -std=c++11 -c -o time-delta.o time-delta.cc
c++ -O2 -std=c++11 time-delta.o lib.o -o time-delta
diff --git a/js/public/StructuredClone.h b/js/public/StructuredClone.h
--- a/js/public/StructuredClone.h
+++ b/js/public/StructuredClone.h
@@ -15,26 +15,126 @@
#include "jstypes.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "js/Value.h"
@jorendorff
jorendorff / ptr.md
Last active January 30, 2018 16:00

Axes of pointer type:

  • Validity - Information about whether the pointer is safe to dereference to begin with. Options:

    • Static guarantee that the pointer is valid and non-null
    • Static guarantee that it is either valid or null, and you can dynamically check is_null()
    • No guarantees—the pointer may be any usize.
#[macro_use] extern crate nsswitch_service;
use nsswitch_service::*;
use std::ffi::CStr;
use std::net::IpAddr;
fn my_gethostbyname(name: &CStr) -> Result<Option<HostEntry>> {
...
}

Meltdown and Spectre

(This is a transcript of a lightning talk I gave at NashJS on 10 January 2018.)

Intro (15s)

(slide: Meltdown and Spectre logos)

Meltdown and Spectre are two new security vulnerabilities revealed January 4th. Yes, security holes have logos now...

@jorendorff
jorendorff / playground.rs
Created October 11, 2017 19:19 — forked from anonymous/playground.rs
Rust code shared from the playground
use std::fmt::Debug;
struct Reader<'a> {
buf: &'a [u8],
}
impl<'a> Reader<'a> {
fn read<'b>(&'b mut self, len: usize) -> Result<&'a [u8], ()> {
if len <= self.buf.len() {
let (read, remains) = self.buf.split_at(len);
;; amb.scm - Nondeterminism using call/cc <3
(define (fail)
(error 'require "no solutions"))
(define backtrack fail)
(define (require ok)
(if (not ok)
(backtrack)))
@jorendorff
jorendorff / heads.py
Created August 4, 2017 04:21 — forked from jimblandy/heads.py
There must be a better way to compute this...
import random
random.seed()
def flip():
return random.choice([True, False])
def run():
b = flip()
n = 1
@jorendorff
jorendorff / eq.hs
Last active July 30, 2017 01:17
The equality of computable functions of a certain type is decidable.
class Finite t where
allValues :: [t]
eq :: (Eq a, Finite b, Eq c) => ((a -> b) -> c) -> ((a -> b) -> c) -> Bool
eq f g =
let -- spy :: (Eq a, Finite b) => [(a, b)] -> a -> b
spy codebook k =
case lookup k codebook of
Just v -> v
Nothing -> head (filter (\v -> not (test ((k, v) : codebook)))
@jorendorff
jorendorff / editor.rs
Last active July 20, 2017 17:59 — forked from levicole/editor.rs
extern crate termion;
use std::io::{Write, Stdout, stdout, stdin};
use termion::event::{Key, Event};
use termion::input::TermRead;
use termion::raw::{IntoRawMode, RawTerminal};
use termion::screen::AlternateScreen;
pub struct Editor {
screen: AlternateScreen<Stdout>,