Skip to content

Instantly share code, notes, and snippets.

View remexre's full-sized avatar

Nathan Ringo remexre

View GitHub Profile
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 4.14.83-gentoo Kernel Configuration
#
#
# Gentoo Linux
#
CONFIG_GENTOO_LINUX=y
CONFIG_GENTOO_LINUX_UDEV=y
@remexre
remexre / surfingkeys-config.js
Last active January 21, 2019 19:00
SurfingKeys Config
addSearchAliasX("w", "wikipedia", "https://en.wikipedia.org/w/index.php?search=");
iunmap(":");
@remexre
remexre / misc.asm
Created November 1, 2018 05:20
Miscellaneous assembly snippets
bits 64
global dehex
[section .text]
; unsigned char dehex(const char hex[2]);
dehex:
mov ax, [rdi]
sub ax, 12336
cmp ax, 2559
jl .L1
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 4.14.65-gentoo Kernel Configuration
#
#
# Gentoo Linux
#
CONFIG_GENTOO_LINUX=y
CONFIG_GENTOO_LINUX_UDEV=y
/*
* Intel SST Haswell/Broadwell PCM Support
*
* Copyright (C) 2013, Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
@remexre
remexre / howto-gnu-parallel.md
Last active June 18, 2018 21:38
HOWTO: GNU Parallel

HOWTO: GNU Parallel

Installation

It's the parallel package on Ubuntu.

Before running parallel, you must run parallel --citation. Yeah...

Simple Example

#!/usr/bin/env -S deno run --allow-net
const api = async (path: string) => {
const url = `https://svc.metrotransit.org/NexTrip/${path}?format=json`;
const resp = await fetch(url);
if (!resp.ok) {
console.error(`Got back status ${resp.status} ${resp.statusText}`);
Deno.exit(1);
}
return await resp.json();
@remexre
remexre / o.sh
Last active March 25, 2018 03:21
An "opener" script.
#!/bin/bash
audio_viewer="nvlc"
image_viewer="eog"
pdf_viewer="zathura"
video_viewer="nvlc"
set -eu
if [[ $# -ne 1 ]]; then
@remexre
remexre / main.ml
Created December 7, 2017 00:14
G vs. E laziness
(* The G method supports thunks well. *)
type 'a g_thunk_inner
= GUnevaled of (unit -> 'a)
| GEvaled of 'a
type 'a g_thunk
= GThunk of ('a g_thunk_inner) ref
let g_force (th: 'a g_thunk): 'a =
let GThunk th = th in

So, essentially, for a NP-complete program, you want to iterate over the entire solution space. To do this, you want to define a bijection between a range of the natural numbers and the solution space. The most elegant way to do this is to define functions on the solutions that mirror the natural numbers (i.e., a homomorphism). The natural numbers can be defined as type nat = Z | S of nat, which gives you an initial (zero) element and a successor function. To define these for the solutions, I would have functions zero_soln and succ_soln which mirror Z and S:

Z : nat
S : nat -> nat
zero_soln : soln