Skip to content

Instantly share code, notes, and snippets.

@skeeto
skeeto / jit.c
Last active August 18, 2024 16:51
Basic JIT
/* http://redd.it/2z68di */
#define _BSD_SOURCE // MAP_ANONYMOUS
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/mman.h>
#define PAGE_SIZE 4096
@skeeto
skeeto / thebutton.el
Last active August 29, 2015 14:18
thebutton-mode
;;; thebutton.el --- display r/thebutton's status on the modeline
;; This is free and unencumbered software released into the public domain.
;;; Commentary:
;; Unfortunately the URL's hash changes regularly, so you may need to
;; update `thebutton-url' to the new when first start the mode.
;; Dependency: https://github.com/ahyatt/emacs-websocket
@skeeto
skeeto / animals.c
Created April 29, 2015 20:52
Challenge #212 [Intermediate] Animal Guess Game
#define _BSD_SOURCE // byteswap
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <endian.h>
#define DB_FILE "animals.db"
@skeeto
skeeto / A072841.c
Created August 14, 2015 16:45
A072841
/* https://oeis.org/A072841
* This is free and unencumbered software released into the public domain.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define MAX(a, b) ((b) > (a) ? (b) : (a))
@skeeto
skeeto / kenken.c
Last active November 8, 2021 16:36
KenKen generator
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <inttypes.h>
#include <time.h>
#include <getopt.h>
static uint64_t
xorshift(uint64_t *state)
{
@skeeto
skeeto / planet-puzzle.svg
Created August 20, 2016 17:34
Planet exploration puzzle
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@skeeto
skeeto / planet-explore.c
Created August 20, 2016 18:11
Planet exploration solver
/* 1) Immediately prints the base puzzle SVG to stdout.
* 2) Creates a path-*.svg each * time it hits a longest path.
* 3) Creates a solution-*.svg for each solution.
*/
#include <stdio.h>
#include <stdint.h>
#define WIDTH 8u
#define HEIGHT 8u
/* $ cc -std=c99 -Ofast -fopenmp -o julia julia.c -lm
* $ ./julia > output.ppm
* $ ppmtoy4m -F 60:1 < output.ppm > output.y4m
* $ x264 --qp 0 -o output.mp4 output.y4m
*
* Due to parallel compute, stdout must be seekable. Therefore it
* cannot be piped directly into ppmtoy4m.
*/
#define IMAGE_SIZE 600
#define IMAX 512
@skeeto
skeeto / Makefile
Last active February 28, 2017 23:47
16x16 "Pseudoku" generator
CC = c99
CFLAGS = -Wall -Wextra -O3 -g3
generate16: generate16.c
clean:
rm -f generate16
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
#define A 10
#define B 30
#define C 5
#define N 1
#define RULE_B