Skip to content

Instantly share code, notes, and snippets.

View eschen42's full-sized avatar

Arthur Eschenlauer eschen42

View GitHub Profile
# 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
#
@eschen42
eschen42 / coexpr.h
Last active August 5, 2021 17:04
Macros to declare C coroutines with syntax similar to Icon co-expressions
#ifndef _COEXPR_H
// Here are C macros to approximate Icon co-expressions, see e.g.,
// https://web.archive.org/web/20160407082917im_/http://www.cs.arizona.edu/icon/ftp/doc/tr87_6.pdf
// https://web.archive.org/web/20160407001546im_/http://www.cs.arizona.edu/icon/analyst/backiss/IA21.pdf
// These macros were (loosely) adapted from:
// https://web.archive.org/web/20210611030357im_/https://www.chiark.greenend.org.uk/~sgtatham/coroutine.h
// see e.g.,
// https://web.archive.org/web/20210611030357im_/https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html