Skip to content

Instantly share code, notes, and snippets.

View eschen42's full-sized avatar

Arthur Eschenlauer eschen42

View GitHub Profile
@eschen42
eschen42 / ulogd2sql.icn
Created October 22, 2024 15:04
Parse ulogd syslog lines to SQLite insertion statements
#!/usr/local/bin/icon
############################################################################
#
# File: ulogd2sql.icn
#
# Subject: Parse ulogd syslog lines to SQLite insertion statements
#
# Author: Art Eschenlauer, adapted from rough-in by Microsoft Copilot
#
# LCTboot_inspect - TestCor::LCTboot modified:
# - to return a "reportables" data.frame as an attribute of the result
# - (for estimating the adjusted and unadjusted p-values)
# - to return the function environment as an attribute of the result
# - (for debugging reportables)
# - to use the normal approximation when Nboot == 0
# - (so that the same code base may be used for LCT-N and LCT-B)
# ref: https://github.com/cran/TestCor/blob/9d5d2a9a1ac284e3346bd144776559cbd82a8b52/R/FdrMethods.R
#' Bootstrap procedure LCT-B proposed by Cai & Liu (2016) for correlation testing.
#'
@eschen42
eschen42 / wsl2-reset.md
Created October 21, 2022 07:58 — forked from kiransubash/wsl2-reset.md
Reset WSL2 networking on windows 10

Open Powershell or Cmd as Administrator and run the following commands

wsl --shutdown
netsh winsock reset
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns
@eschen42
eschen42 / co_ject.icn
Created October 7, 2022 20:30
simple "co-expressions as objects" prototype
procedure co_foo(state, args[])
return .(state[args[1]] +:= args[2])
end
procedure co_new()
local state, foo, msg
state := table()
state["something"] := 1
@(
foo := create (
@eschen42
eschen42 / pingstat.icn
Last active August 21, 2022 20:37
pingstat.icn - compute statistics for unix ping output
#!/bin/env icon
############################################################################
#
# File: pingstat.icn
#
# Subject: pingstat.icn - compute statistics for unix ping output
#
# Author: Arthur Eschenlauer (https://orcid.org/0000-0002-2882-0508)
#
# Date: 21 August, 2022
@eschen42
eschen42 / header.icn
Last active August 21, 2022 20:26
Icon standard header
############################################################################
#
# File: [progname].icn
#
# Subject: [progname].icn - [subtitle succinctly describing what progname.icn is or does]
#
# Author: Arthur Eschenlauer (https://orcid.org/0000-0002-2882-0508)
#
# Date: [e.g. 26 March, 2020]
#
@eschen42
eschen42 / fgrep.R
Created August 8, 2022 21:40
Emulate fgrep in R, i.e., is any of needles found in any of haystacks
#' Emulate fgrep, i.e., is any of needles found in any of haystacks
#'
#' This should perform adequately for a few needles.
#'
#' If performance for many needles is inadequate, use
#' `0 < length(AhoCorasickTrie::AhoCorasickSearch(needles, haystacks)[[1]])`
#' as the implementation for a more realistic emulation of fgrep.
#'
#' @param needles A character vector of length 1 or more
#' @param search_strings A character of length 1 or more
@eschen42
eschen42 / staque.R
Last active September 29, 2022 18:22
staque.R - Icon-oriented stack and queue operations
# staque.R - Icon-oriented stack and queue operations
# - queue:
# - sq_push/sq_pull to pass values thru vector left-to-right;
# - sq_put/sq_pop to pass values thru vector right-to-left.
# - stack:
# - sq_push/sq_get to left end of vector;
# - this is an "upward-growing stack";
# - in Icon, get is a synonym for pop; however base::get exists in R.
# - sq_put/sq_pull to right end of vector;
# - this is a "downward-growing stack".
@eschen42
eschen42 / tabCount.icn
Last active December 29, 2021 16:57
Count tabs per line; flag when number differs from number in first line
# Count tabs per line; flag when number differs from number in first line
#
# Execute with `icon tabCount.icn tsv_file -1`
# See [the Icon website](https://cs.arizona.edu/icon) for further info about the Icon programming language.
#
procedure main(args)
# args[1] = input file
# args[2] = number of lines (optional, default = 3)
local expected
local input_file
@eschen42
eschen42 / LcomboP.icn
Last active September 24, 2021 13:50
Produce lists combining memoized infinte sequences
############################################################################
#
# File: LcomboP.icn
#
# Subject: Produce lists combining memoized infinte sequences
#
# Author: Art Eschenlauer (@eschen42 on GitHub,
# - https://orcid.org/0000-0002-2882-0508
# - https://github.com/eschen42
#