Skip to content

Instantly share code, notes, and snippets.

Stephen Olsen saolsen

Block or report user

Report or block saolsen

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
@saolsen
saolsen / readme.md
Last active Aug 6, 2019
trying out structs in javascript
View readme.md

I've been thinking about trying to build something like terra but with javascript as the host language and wasm as the low level thing you metaprogram for. Could be used to just "jit" expensive functions and call them from javascript or to build a fully wasm program but metaprogram it from javascript or whatever inbetween. One of the things I think I need to get that to be nice is to be able to have a struct implementation that can be easily shared between wasm and js.

@saolsen
saolsen / program.c
Created Jun 6, 2019
grow_memory in wasm from c
View program.c
include <stdlib.h>
#include <stddef.h>
#include <assert.h>
#include <webassembly.h>
typedef uint8_t u8;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t i32;
@saolsen
saolsen / steve_lib.h
Last active Mar 17, 2018
steve_lib.h
View steve_lib.h
// Collections and helpers for c programming.
// Version: 0.1.3
// Shoutouts to @nothings and @pervognsen who I learned / copied most of this from
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
View keybase.md

Keybase proof

I hereby claim:

  • I am saolsen on github.
  • I am saolsen (https://keybase.io/saolsen) on keybase.
  • I have a public key ASD9j8N4AtK0fUZlAh1XujYN4d4bSiK7GJ3_RQuP7_pj5wo

To claim this, I am signing this object:

@saolsen
saolsen / aissac.cpp
Created Aug 3, 2017
python screen capture
View aissac.cpp
#include <windows.h>
#include <d3d11.h>
#include <dxgi1_2.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#define LEN(e) (sizeof(e)/sizeof(e[0]))
@saolsen
saolsen / 2016-04-13.c
Last active Jun 1, 2016
circular chat buffer
View 2016-04-13.c
#if 0
echo Compiling...
cc -Wall -g -std=c99 $0 -o 2016-04-13 && ./2016-04-13
exit
#endif
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
@saolsen
saolsen / workq.c
Created Dec 2, 2015
another lock free work queue
View workq.c
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>
#include <libkern/OSAtomic.h>
#include <unistd.h>
typedef void(*WorkFunction)(void* work_data);
@saolsen
saolsen / multicore.c
Last active Jun 1, 2016
sort and print a giant list
View multicore.c
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <pthread.h>
#define TEST_CASES 1000000
#define TEST_RUNS 30
// Channels for passing data between threads. We pack a whole cache line of ints before
View free_warning.c
#include <stdlib.h>
int main(int nargs, char * args[])
{
void* vp = malloc(sizeof(char) * 5);
const char* ip = (char*)(vp);
free(ip);
}
View number-to-binary.rkt
#lang racket
(define (get-spaces-inner n spaces)
(define current-space (car spaces))
(if (> current-space n)
(cdr spaces)
(get-spaces-inner n (cons (* current-space 2) spaces))))
(define (get-spaces n)
(get-spaces-inner n '(1)))
You can’t perform that action at this time.