Skip to content

Instantly share code, notes, and snippets.

View justinmeiners's full-sized avatar

Justin Meiners justinmeiners

View GitHub Profile
@justinmeiners
justinmeiners / curl.md
Created June 3, 2019 19:41 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@justinmeiners
justinmeiners / btree.inl
Created June 15, 2019 17:23 — forked from pervognsen/btree.inl
Experiments in lightweight C templates
// Here is btree.inl, which is the thing you would write yourself.
// Unlike C++ templates, the granularity of these lightweight templates is at the
// module level rather than the function or class level. You can think of it like
// ML functors (parameterized modules) except that there isn't any static checking
// of signatures (in that respect, it's like C++ templates). In my view, this style
// of parameterized generative modules is generally the better conceptual framework.
// This is a completely valid C file even prior to preprocessing, so during library
// development you can just include this file directly. That is a big win for testing

The axiom of choice says that for an infinite set of disjoint nonempty sets, we can find a set with one element from each. In others we can choose an element.

The axiom of choice is needed only when there is no clear way to choose. For example if the disjoint sets were integers, we could always explicitly pick the smallest, but for sets of sets, there isn't a clear way to pick.

Finite Set proof

Axiom of Choice = Cartesian Product

It postulates the existence of a set which is not uniquely determined, of which we know only some properties.

// https://gist.github.com/pervognsen/c56d4ddce94fbef3c80e228b39efc028
// https://gist.github.com/pervognsen/fb31981701b534e495a8baa2a6c3ae86
// https://gist.github.com/pervognsen/d4dc1dc159f93a0ad5b6
// https://gist.github.com/vurtun/2e32089f0f012aab2b4c6385f145b5bd
// http://blog.pkh.me/p/20-templating-in-c.html
#ifndef LISTPOOL_VAL
#error "LISTPOOL_VAL must be #defined to a type."
#endif
/* Created By: Justin Meiners (2012)
This is the only worthwhile piece a project I wrote in 2012. I got interested in emulation after watching
[Bisqwit's video](https://www.youtube.com/watch?v=y71lli8MS8s)
It was interesting to learn about how the cartridge data is organized
and how the graphics are stored.
I didn't get very far into the actual emulation, as the CPU has tons of instructions
with slightly different variations and I didn't understand computer architecture at the time.
/*
After making my ASM rogue, I thought it might be fun to make a C one.
Termbox looks awesome.
gcc rogue.c -I /usr/local/include -L /usr/local/lib -l termbox -o rogue
*/
#include <stdio.h>
#include <stdlib.h>

The Problem

Let's suppose you are writing an autocomplete/search feature in which an input field sends requests to the server to get suggestions. The tricky part here is accounting for latency, so I'm going to model this as a timeline of events. This a choice of mathematical structure that I will use to represent the problem. You can visualize it by thinking of points on a number line.

Components

Peter Thiel on Markets, Technology, and Education

YouTube

Uncommon Knowledge. The Hoover Institution

Published: October 23, 2014

Participants

@justinmeiners
justinmeiners / python3_caching_proxy.py
Last active February 9, 2023 17:17
A simple caching HTTP proxy in Python 3.
# A simple HTTP proxy which does caching of requests.
# Inspired by: https://gist.github.com/bxt/5195500
# but updated for Python 3 and some additional sanity improvements:
# - shutil is used to serve files in a streaming manner, so the entire data is not loaded into memory.
# - the http request is written to a temp file and renamed on success
# - forward headers
import http.server
import socketserver
import urllib.request