Skip to content

Instantly share code, notes, and snippets.

View nacnudus's full-sized avatar

Duncan Garmonsway nacnudus

View GitHub Profile
@wch
wch / multi_dispatch.R
Last active December 24, 2023 17:20
Multiple dispatch in R without S4
# ---- Multiple dispatch functions -----
multi_dispatch <- function(gen_name) {
calling_env <- parent.frame()
parent_call <- sys.call(sys.parent())
calling_fun <- sys.function(sys.parent())
arg1 <- eval(parent_call[[2]], calling_env)
arg2 <- eval(parent_call[[3]], calling_env)
@cgwxyz
cgwxyz / urldecode_encode.lua
Last active June 23, 2020 14:09
lua urlencode/urldecode
function encodeURI(str)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w ])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
return str
end
@artifactsauce
artifactsauce / conv-pg_dump-tsv.pl
Last active March 13, 2024 13:17
Convert from a pg_dump data file to TSV files for LOAD DATA INFILE.
#!/usr/bin/env perl
use strict;
use warnings;
use Path::Class;
use FindBin;
my $output_dir = dir($FindBin::Bin,"data");
$output_dir->is_dir or die "[ERROR] $output_dir is not a directory.";