Skip to content

Instantly share code, notes, and snippets.

View seven1m's full-sized avatar

Tim Morgan seven1m

View GitHub Profile
<script>
var module = WebAssembly.instantiateStreaming(fetch("linked_list.wasm"), {});
</script>
@kddnewton
kddnewton / json.rb
Last active October 6, 2023 09:25
JSON parser with pattern matching
require "json"
struct = { "a" => 1, "b" => 2, "c" => [1, 2, 3], "d" => [{ "e" => 3 }, nil, false, true, [], {}] }
source = JSON.dump(struct)
tokens = []
index = 0
until source.empty?
tokens <<
@danott
danott / main.rb
Created January 28, 2022 21:32
A WIP of codifying the Planning Center company calendar
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'repeatable', "= 1.0.0"
end
weekdays = Repeatable::Expression::Union.new(
Repeatable::Expression::Weekday.new(weekday: 1),
Repeatable::Expression::Weekday.new(weekday: 2),
@onigetoc
onigetoc / oembed_list.json
Created January 22, 2020 18:28
oembed list json
// https://oembed.com/providers.json
[{
"provider_name": "23HQ",
"provider_url": "http:\/\/www.23hq.com",
"endpoints": [{
"schemes": [
"http:\/\/www.23hq.com\/*\/photo\/*"
],
"url": "http:\/\/www.23hq.com\/23\/oembed"
}]
@munificent
munificent / generate.c
Last active May 7, 2024 06:19
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@38
38 / Makefile
Last active February 19, 2024 02:12
A Minimal LLVM JIT example for LLVM-5
jit-toy: jit-toy.cpp
clang++ -g -o $@ $^ $(shell /usr/lib/llvm-5.0/bin/llvm-config --cxxflags --ldflags --system-libs --libs core)
@andyrbell
andyrbell / scanner.sh
Last active April 5, 2024 09:01
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@MightyPork
MightyPork / utf8_encode.c
Last active February 28, 2024 08:07
C function to encode a Unicode code point as UTF-8 byte array
#include <stdint.h>
/**
* Encode a code point using UTF-8
*
* @author Ondřej Hruška <ondra@ondrovo.com>
* @license MIT
*
* @param out - output buffer (min 5 characters), will be 0-terminated
* @param utf - code point 0-0x10FFFF
@ryanmaclean
ryanmaclean / salt_on_mac.md
Last active March 10, 2024 10:38
Install and Run Salt Stack on macOS Servers and Desktops

Install Salt on macOS

Install Homebrew

Install Dependencies

brew install python swig zmq
enum FacResult {
Become(i32,i32),
Return(i32),
}
fn fac_tail(n: i32, accu: i32) -> FacResult {
if n < 2 {
// result known
FacResult::Return(accu)
} else {