Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Ringo remexre

View GitHub Profile
View gist:eecf0673446db3cafe1dbe2e42a20e09
#
# 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 Jan 21, 2019
SurfingKeys Config
View surfingkeys-config.js
addSearchAliasX("w", "wikipedia", "https://en.wikipedia.org/w/index.php?search=");
iunmap(":");
@remexre
remexre / misc.asm
Created Nov 1, 2018
Miscellaneous assembly snippets
View misc.asm
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
View gist:1181e2784b00ae2e6fe815d488f55bfa
#
# 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
View sst-haswell-pcm.c
/*
* 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 Jun 18, 2018
HOWTO: GNU Parallel
View howto-gnu-parallel.md

HOWTO: GNU Parallel

Installation

It's the parallel package on Ubuntu.

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

Simple Example

View i-like-trains.ts
#!/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 Mar 25, 2018
An "opener" script.
View o.sh
#!/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 Dec 7, 2017
G vs. E laziness
View main.ml
(* 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
View 2041-graph-coloring.md

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