Skip to content

Instantly share code, notes, and snippets.

@juster
juster / quine.erl
Created October 28, 2020 03:40
Erlang quine
-module(quine).
-export([run/0]).
run() -> io:format(q(), [q()]).
q() -> "-module(quine).
-export([run/0]).
run() -> io:format(q(), [q()]).
q() -> ~p.~n".
@juster
juster / keybase.md
Created December 22, 2019 20:38
My voice is my passport

Keybase proof

I hereby claim:

  • I am juster on github.
  • I am jrcd (https://keybase.io/jrcd) on keybase.
  • I have a public key ASC7vmleUkZWB2AJcuvdARMV7eTFZXnaqq8eMvLc2GMwJAo

To claim this, I am signing this object:

const std = @import("std");
pub fn main() !void {
var buf = try std.heap.c_allocator.alloc(u32, 1);
}
// never compiles, just exits back to cmd prompt
const std = @import("std");
const FileOutStream = std.io.FileOutStream;
const sampleSize = 16;
const heap = std.heap.c_allocator;
const math = std.math;
var stdout : FileOutStream = undefined;
fn randomSample() ![sampleSize]i8 {
var buf: [8]u8 = undefined;
@juster
juster / templ.awk
Created September 2, 2015 22:31
Tiny awk web template
function die (msg)
{
printf "%s:%d %s\n", FILENAME, FNR, msg > "/dev/stderr"
exit 1
}
BEGIN { FS="{!}"; OFS="" }
NF > 0 && NF % 2 == 0 { die("Unbalanced {!} tokens.") }
NF > 2 {
for (i=2; i<=NF; i+=2) {
-- lisp.lua
-- by Justin Davis <jrcd83@gmail.com>
-- Very light data abstraction.
local nullval = {}
local function pair_exp (exp)
return type(exp) == "table" and exp.left ~= nil and exp.right ~= nil
end
digraph "Bash Grammar" {
pipeline_command -> command
command -> simple_command
command -> shell_command
command -> function_def -> function_body
shell_command -> for
shell_command -> case
@juster
juster / sotree
Last active August 29, 2015 14:07
Print min spanning tree of dep graph for dynamic libraries.
#!/usr/bin/awk -f
##
# sotree
# Prints a dynamic library dependency graph as a minimum spanning tree.
# Justin Davis 10/14/14
##
BEGIN {
libdircnt = split("/lib:/usr/lib:" ENVIRON["LD_LIBRARY_PATH"], libdirs, /:/)
if(!libdirs[libdircnt]) --libdircnt
--- perl-5.20.0/vutil.c 2014-05-26 09:34:21.000000000 -0400
+++ perl-5.20.0-patched/vutil.c 2014-06-19 09:25:19.024409700 -0400
@@ -585,11 +585,29 @@
{
STRLEN len;
+#ifdef USE_LOCALE_NUMERIC
+ char *loc = setlocale(LC_NUMERIC, NULL);
+ if (loc) {
+ /* setlocale returns NULL on error */
@juster
juster / patchprov
Last active August 29, 2015 14:02
Script for patching the provides list in the ArchLinux PKGBUILD for the perl package.
#!/usr/bin/perl
##
## Name:
## patchprov
##
## Description:
## Patch the provides list in the perl package PKGBUILD. Scan the appropriate
## directories under the perl source tree for directories containing dists
## similar to CPAN dists. Search the files in the distributions for VERSION
## strings, which are perl expressions. Filters these version strings through