Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason Pepas cellularmitosis

View GitHub Profile
View haskell-syntax.md

format: md1

Haskell Syntax

Some flashcards on Haskell syntax (work-in-progress).


How do you load the haskell file foo.hs from ghci?

@cellularmitosis
cellularmitosis / Makefile
Last active Sep 13, 2020
A simple Snake game in C and SDL1.2
View Makefile
SDL=$(shell sdl-config --cflags --libs)
default: snake run
run: snake
./snake
snake: snake.c
gcc -std=c99 -Wall -Werror $(SDL) snake.c -o snake
@cellularmitosis
cellularmitosis / README.md
Last active Sep 13, 2020
Quick-n-dirty QEMU script to spin up Debian on various CPU's
View README.md

Quick-n-dirty QEMU script to spin up Debian on various CPU's

This script downloads one of the QEMU images from https://people.debian.org/~aurel32/qemu/ and boots up a vm.

(unfortunately, these are all wheezy images, which is quite old now, but still useful for e.g. compiling a C file or running a binary)

Usage examples:

@cellularmitosis
cellularmitosis / HashTable.c
Last active Sep 7, 2020
Hash table in C, part 5: better hashing
View HashTable.c
#include "HashTable.h"
#include <stdio.h> // fprintf
#include <stdlib.h> // exit
#include <string.h> // memset
#include <stdint.h> // uint8_t
#include <stdbool.h> // true
#include <assert.h> // assert
void* dmalloc(size_t size) {
@cellularmitosis
cellularmitosis / HashTable.c
Last active Aug 22, 2020
Hash table in C, part 4: automatic resizing
View HashTable.c
#include "HashTable.h"
#include <stdio.h> // fprintf
#include <stdlib.h> // exit
#include <string.h> // memset
#include <stdint.h> // uint8_t
#include <stdbool.h> // true
#include <assert.h> // assert
void* dmalloc(size_t size) {
@cellularmitosis
cellularmitosis / HashTable.c
Last active Aug 20, 2020
Hash table in C, part 3: hash collisions
View HashTable.c
#include "HashTable.h"
#include <stdio.h> // fprintf
#include <stdlib.h> // exit
#include <string.h> // memset
#include <stdint.h> // uint8_t
#include <stdbool.h> // true
#include <assert.h> // assert
void* dmalloc(size_t size) {
@cellularmitosis
cellularmitosis / HashTable.c
Last active Aug 20, 2020
Hash table in C, part 1: a humble beginning
View HashTable.c
#include "HashTable.h"
#include <stdio.h> // fprintf
#include <stdlib.h> // exit
#include <string.h> // memset
#include <stdint.h> // uint8_t
void* dmalloc(size_t size) {
void* p = malloc(size);
if (p == NULL) {
@cellularmitosis
cellularmitosis / README.md
Created Aug 16, 2020
VS Code configuration
View README.md

Tab switching

I like to switch tabs using ctrl+[ and ctrl+]

Linux: ~/.config/Code/User/keybindings.json

[
    {
        "key": "ctrl+]",
@cellularmitosis
cellularmitosis / Makefile
Last active Aug 20, 2020
Janet Exercism: Implement map
View Makefile
test-all: mymap-iter mymap-recur mymap-iter.janet mymap-recur.janet
chmod +x mymap-recur.janet mymap-iter.janet
./mymap-recur.janet
./mymap-recur
./mymap-iter.janet
./mymap-iter
mymap-iter: mymap-iter.janet
jpm quickbin mymap-iter.janet mymap-iter
@cellularmitosis
cellularmitosis / Makefile
Last active Aug 6, 2020
Janet Exercism: Reverse a string
View Makefile
default: test-all bin-all
test-all: test-recur test-iter
test-recur:
./rev-str-recur.janet
test-iter:
./rev-str-iter.janet
You can’t perform that action at this time.