Add truecolor awk script.

Add truecolor awk script.

This script is used to test true color support on your terminal emulator
of choice. If a smooth gradient is displayed when it is run, then
everything is configured correctly.

error: pathspec 'scripts/truecolor.awk' did not match any file(s) known to git


I better commit this, while it works.

I better commit this, while it works.

#!/usr/bin/awk

# TODO:
# cat nfa.dot | dot -Tplain > /tmp/a.mp \
# && mpost -s 'outputformat="svg"' -s 'outputtemplate="%j-%c.%o"' /tmp/a.mp

# Only intended to consume Dot generated from libfsm's .dot output,
# and not graphviz diagrams in general.

# graph 1 5.75 0.93056
# node start 0.15278 0.41667 0.30556 0.5 "" solid none black lightgrey
# node S6 0.97222 0.41667 0.30556 0.30556 "" solid circle black lightgrey
# node S1 5.5417 0.20833 0.41667 0.41667 "" solid doublecircle black lightgrey
# edge S3 S6 10 3.5244 0.20119 3.2727 0.19014 2.7322 0.17358 2.2778 0.20833 1.873 0.23929 1.7755 0.28067 1.375 0.34722 1.3389 0.35322 1.3009 0.35974 1.2635 0.3663 <ε> 2.3264 0.3125 solid black
# edge S3 S2 4 3.835 0.20833 3.9555 0.20833 4.1328 0.20833 4.2831 0.20833 <y> 4.1319 0.3125 solid black
# stop

BEGIN {
	# TODO: common stuff for multiple graphs
	print "pair start;"
	print "pair S[];"
	print "pair q[];"
	print "path nS[];"
	print "path nstart;"
	print "path e;"
	print "ahlength := .1in;"
}

/^graph / {
	printf "beginfig(%s)\n", $2
}

/^node / {
	# node S6 0.97222 0.41667 0.30556 0.30556 "" solid circle black lightgrey
	# node name x y width height label style shape color fillcolor

	name = $2;
	x = $3;
	y = $4;
	width = $5;
	height = $6;
	# TODO: label delimited by <>, may contain spaces

	diameter = (height + width) / 2;

#	printf "\t%% %s %s\n", name, $0
#	printf "\t%s := fullcircle scaled %fin shifted (%fin, %fin);\n", name, diameter, x, y
#	printf "\tdraw %s;\n", name
	printf "\t%s := (%fin, %fin);\n", name, x, y

	# TODO: style for doublecircle
	# TODO: style for start state

	printf "\tn%s := fullcircle scaled %fin shifted %s;\n", name, diameter, name

	printf "\tdraw n%s;\n", name
}

#/^edge S1 S5 / {
/^edge / {
	# edge tail head n x1 y1 .. xn yn [label xl yl] style color
	# edge S3 S6 10 3.5244 0.20119 3.2727 0.19014 2.7322 0.17358 2.2778 0.20833 1.873 0.23929 1.7755 0.28067 1.375 0.34722 1.3389 0.35322 1.3009 0.35974 1.2635 0.3663 <ε> 2.3264 0.3125 solid black

	tail = $2;
	head = $3;
	n    = $4;

	v = split($0, a, " ");
# TODO: assert n < v - whatever
# TODO: assert n >= 4 (knot, control, control)

	# TODO: note we assume -Etailclip=false -Eheadclip=false -Edir=none
	# TODO: explain that requirement

	# things i wish the graphviz documentation said about -Tplain:
	# graphviz always outputs cubic b-splines
	# 3i+1 points total. format is { knot, control, control }* knot
	# bezier is ordered tail to head
	# first two points (knot, control) are ontop of each other, in the tail node
	# last two points (control, knot) are ontop of each other, in the head node
	# coordinates are in inches

#	printf "\te := %s .. ", tail;
#	for (i = 1; i <= n; i++) {
#		# control point
#		cx = a[i * 2 + 3];
#		cy = a[i * 2 + 4];
#
#		# knot
##		ox = a[i * 2 + 5];
##		oy = a[i * 2 + 6];
#
#		printf "(%sin, %sin) .. ", cx, cy;
##		printf "(%sin, %sin) .. controls (%sin, %sin) and (%sin, %sin) ..", ox, oy, cx, cy, cx, cy;
#	}
#	printf "%s;\n", head;

	#printf "draw e withcolor green;\n";
	#printf "draw point .5 of e withpen pencircle scaled 3bp withcolor blue;\n";
	#printf "draw e cutafter %s withcolor black;\n", head;

	for (i = 1; i <= n; i++) {
		ox = a[i * 2 + 3];
		oy = a[i * 2 + 4];
		printf "draw (%sin, %sin) withpen pencircle scaled 4bp withcolor black;\n", ox, oy;
#		printf "label.top(\"%d\", (%sin, %sin));\n", i, ox, oy;
	}

	for (i = 1; i <= n - 1; i += 3) {
		# knot
		ox = a[(i + 0) * 2 + 3];
		oy = a[(i + 0) * 2 + 4];

		# control
		c1x = a[(i + 1) * 2 + 3];
		c1y = a[(i + 1) * 2 + 4];

		# control
		c2x = a[(i + 2) * 2 + 3];
		c2y = a[(i + 2) * 2 + 4];

		printf "draw (%fin, %fin) withpen pencircle scaled 3bp withcolor red;\n", ox, oy;
		printf "draw (%fin, %fin) withpen pencircle scaled 2bp withcolor red + green;\n", c1x, c1y;
		printf "draw (%fin, %fin) withpen pencircle scaled 2bp withcolor red + green;\n", c2x, c2y;
	}
	# TODO: knot at end, which i haven't drawn
	# last point:
	{
		# knot
		ox = a[(n + 0) * 2 + 3];
		oy = a[(n + 0) * 2 + 4];
		printf "draw (%fin, %fin) withpen pencircle scaled 1bp withcolor red;\n", ox, oy;
	}

	printf "\te := ";
	for (i = 1; i <= n - 1; i += 3) {
		# knot
		ox = a[(i + 0) * 2 + 3];
		oy = a[(i + 0) * 2 + 4];

		# control
		c1x = a[(i + 1) * 2 + 3];
		c1y = a[(i + 1) * 2 + 4];

		# control
		c2x = a[(i + 2) * 2 + 3];
		c2y = a[(i + 2) * 2 + 4];

		printf "(%fin, %fin) .. controls (%fin, %fin) and (%fin, %fin) .. ", ox, oy, c1x, c1y, c2x, c2y;
	}
	# TODO: knot at end, which i haven't drawn
	# last point:
	{
		# knot
		ox = a[(n + 0) * 2 + 3];
		oy = a[(n + 0) * 2 + 4];
		printf "(%fin, %fin);", ox, oy;
	}

	printf "draw e withpen pencircle scaled 0.25bp withcolor red;\n";

## TODO: better explain this
printf "pair p; p = e intersectionpoint n%s;\n", head;
printf "pair q; q = e intersectionpoint n%s;\n", tail;

##printf "draw p withpen pencircle scaled 3bp withcolor blue;\n";
##printf "draw q withpen pencircle scaled 3bp withcolor blue;\n";

printf "path b; b = %s .. p .. q .. %s;\n", head, tail;

printf "drawarrow b cutbefore p cutafter q withpen pencircle scaled 0.5bp withcolor blue;\n";
##printf "\tdraw fullcircle scaled %fin shifted %s;\n", diameter, name
#print "endfig;end."
}

/^stop$/ {
	print "endfig;"
}

END {
	print "end."
}

error: pathspec 'share/bin/plain2mp.awk' did not match any file(s) known to git


simple phylip to fasta canversion

simple phylip to fasta canversion

error: pathspec 'phy2Fasta.awk' did not match any file(s) known to git


for (y in x) z = z d x[y] (y < m ? d "\\" d : d)

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/svnpenn/sage.git/'


Add source for info pages to CVS

Add source for info pages to CVS

error: pathspec 'doc/infosrc/sz.awk' did not match any file(s) known to git


2008-05-06  Martin Sebor  <sebor@roguewave.com>

	STDCXX-906
	* bin/xcomp.awk (print_section): Corrected the computation
	of date ranges. Added comments. This is already on 4.2.x
	(inadvertently done in rev 653930).

git-svn-id: 8ce9432b95a2a271c6c279131eb1bb968a8ee7fb@653932 13f79535-47bb-0310-9956-ffa450edef68

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/pathscale/stdcxx.git/'


removed beginfile expression, unsupported by mawk

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/orbifx/yamado.git/'


print ab_join(sb, RS)

print ab_join(sb, RS)


awk code

awk code

#! /bin/awk -f

#find mean and variance of a column from a file
BEGIN {
print "Hello awk"
}

#body
{
sum = sum + $4
}
END {
print NR
print sum
mean = sum / NR
print mean
}

error: pathspec 'src/awk/meanvariance.awk' did not match any file(s) known to git


file sep

file sep

#! /bin/awk -f

#find mean and variance of a column from a file
BEGIN {
OFS=","
}
#body
{
$1=$1 #rebuild the record using current OFS
print $0
}
END {
print "Done"
}

error: pathspec 'src/awk/fs.awk' did not match any file(s) known to git


Create main.awk

Create main.awk

error: pathspec 'Challenges/53.-Kamil/main.awk' did not match any file(s) known to git


Added one awk script

Added one awk script

#!/usr/bin/awk -f
BEGIN {
    FS = "[^a-zA-Z]+"
    OFS = "\t"
}

{
    for (i = 1; i < NF; i++)
	words[tolower($i)]++;
}

END {
    delete words[""]
    for (i in words)
	print words[i], i
}

error: pathspec 'awk/word_freq.awk' did not match any file(s) known to git


add Shell (initial)

add Shell (initial)

####################################################################
# Shell.awk                                                        #
####################################################################

# Detect external readline wrapper (rlwrap).
function initRlwrap() {
    Rlwrap = !system("rlwrap --version >/dev/null 2>/dev/null") ? "rlwrap" : ""
}

# Prompt for interactive session.
function prompt(    i, p, temp) {
    p = Option["prompt"]

    # Format specifiers supported by strftime().
    # Roughly following ISO 8601:1988, with the notable exception of "%S", "%t" and "%T".
    # GNU libc extensions like "%l", "%s" and "%_*" are not supported.
    # See: <https://www.gnu.org/software/gawk/manual/html_node/Time-Functions.html>
    #      <http://pubs.opengroup.org/onlinepubs/007908799/xsh/strftime.html>
    if (p ~ /%a/) gsub(/%a/, strftime("%a"), p)
    if (p ~ /%A/) gsub(/%A/, strftime("%A"), p)
    if (p ~ /%b/) gsub(/%b/, strftime("%b"), p)
    if (p ~ /%B/) gsub(/%B/, strftime("%B"), p)
    if (p ~ /%c/) gsub(/%c/, strftime("%c"), p)
    if (p ~ /%C/) gsub(/%C/, strftime("%C"), p)
    if (p ~ /%d/) gsub(/%d/, strftime("%d"), p)
    if (p ~ /%D/) gsub(/%D/, strftime("%D"), p)
    if (p ~ /%e/) gsub(/%e/, strftime("%e"), p)
    if (p ~ /%F/) gsub(/%F/, strftime("%F"), p)
    if (p ~ /%g/) gsub(/%g/, strftime("%g"), p)
    if (p ~ /%G/) gsub(/%G/, strftime("%G"), p)
    if (p ~ /%h/) gsub(/%h/, strftime("%h"), p)
    if (p ~ /%H/) gsub(/%H/, strftime("%H"), p)
    if (p ~ /%I/) gsub(/%I/, strftime("%I"), p)
    if (p ~ /%j/) gsub(/%j/, strftime("%j"), p)
    if (p ~ /%m/) gsub(/%m/, strftime("%m"), p)
    if (p ~ /%M/) gsub(/%M/, strftime("%M"), p)
    if (p ~ /%n/) gsub(/%n/, strftime("%n"), p)
    if (p ~ /%p/) gsub(/%p/, strftime("%p"), p)
    if (p ~ /%r/) gsub(/%r/, strftime("%r"), p)
    if (p ~ /%R/) gsub(/%R/, strftime("%R"), p)
    if (p ~ /%u/) gsub(/%u/, strftime("%u"), p)
    if (p ~ /%U/) gsub(/%U/, strftime("%U"), p)
    if (p ~ /%V/) gsub(/%V/, strftime("%V"), p)
    if (p ~ /%w/) gsub(/%w/, strftime("%w"), p)
    if (p ~ /%W/) gsub(/%W/, strftime("%W"), p)
    if (p ~ /%x/) gsub(/%x/, strftime("%x"), p)
    if (p ~ /%X/) gsub(/%X/, strftime("%X"), p)
    if (p ~ /%y/) gsub(/%y/, strftime("%y"), p)
    if (p ~ /%Y/) gsub(/%Y/, strftime("%Y"), p)
    if (p ~ /%z/) gsub(/%z/, strftime("%z"), p)
    if (p ~ /%Z/) gsub(/%Z/, strftime("%Z"), p)

    # %_ : prompt message
    if (p ~ /%_/)
        gsub(/%_/, sprintf(Locale[getCode(Option["hl"])]["message"], ""), p)

    # %l : home language
    if (p ~ /%l/)
        gsub(/%l/, Locale[getCode(Option["hl"])]["display"], p)

    # %L : home language (English name)
    if (p ~ /%L/)
        gsub(/%L/, Locale[getCode(Option["hl"])]["name"], p)

    # %s : source language
    # 's' is the format-control character for string

    # %S : source language (English name)
    if (p ~ /%S/)
        gsub(/%S/, Locale[getCode(Option["sl"])]["name"], p)

    # %t : target languages, separated by "+"
    if (p ~ /%t/) {
        temp = Locale[getCode(Option["tl"][1])]["display"]
        for (i = 2; i <= length(Option["tl"]); i++)
            temp = temp "+" Locale[getCode(Option["tl"][i])]["display"]
        gsub(/%t/, temp, p)
    }

    # %T : target languages (English names), separated by "+"
    if (p ~ /%T/) {
        temp = Locale[getCode(Option["tl"][1])]["name"]
        for (i = 2; i <= length(Option["tl"]); i++)
            temp = temp "+" Locale[getCode(Option["tl"][i])]["name"]
        gsub(/%T/, temp, p)
    }

    # %, : target languages, separated by ","
    if (p ~ /%,/) {
        temp = Locale[getCode(Option["tl"][1])]["display"]
        for (i = 2; i <= length(Option["tl"]); i++)
            temp = temp "," Locale[getCode(Option["tl"][i])]["display"]
        gsub(/%,/, temp, p)
    }

    # %< : target languages (English names), separated by ","
    if (p ~ /%</) {
        temp = Locale[getCode(Option["tl"][1])]["name"]
        for (i = 2; i <= length(Option["tl"]); i++)
            temp = temp "," Locale[getCode(Option["tl"][i])]["name"]
        gsub(/%</, temp, p)
    }

    # %/ : target languages, separated by "/"
    if (p ~ /%\//) {
        temp = Locale[getCode(Option["tl"][1])]["display"]
        for (i = 2; i <= length(Option["tl"]); i++)
            temp = temp "/" Locale[getCode(Option["tl"][i])]["display"]
        gsub(/%\//, temp, p)
    }

    # %? : target languages (English names), separated by "/"
    if (p ~ /%\?/) {
        temp = Locale[getCode(Option["tl"][1])]["name"]
        for (i = 2; i <= length(Option["tl"]); i++)
            temp = temp "/" Locale[getCode(Option["tl"][i])]["name"]
        gsub(/%\?/, temp, p)
    }

    # %s : source language
    printf(AnsiCode["bold"] AnsiCode[Option["prompt-color"]] p AnsiCode[0] " ", Locale[getCode(Option["sl"])]["display"]) > "/dev/stderr"
}

error: pathspec 'include/Shell.awk' did not match any file(s) known to git


Create lr.awk

Create lr.awk

An Awk script for processing linear regression of input data

#!/bin/awk -f
BEGIN{
    ts = 0;
}
{
	lr = linearRegression( $1, ts, 10, 0 );
	ts += 10;

	printf( "%f\n", lr );

}

function linearRegression( newAngle, looptime, samples, prediction )
{

	lreg[counter%samples] = newAngle;
	tss[counter%samples] = looptime;

	counter++;

	lxy = 0;
	lxx = 0;
	lxs = 0;
	lys = 0;

	len = length(lreg);

	for( i = 0; i < len; i++ )
	{
		lxy += lreg[i]*tss[i];
		lxx += tss[i]*tss[i];
		lxs += tss[i];
		lys += lreg[i];
	}

	if( ((len*lxx)-(lxs*lxs)) == 0 )
		return newAngle;

	m = ((len*lxy)-(lxs*lys))/((len*lxx)-(lxs*lxs));
	b = (lys-(m*lxs))/len;

	return m*(looptime+prediction)+b;
}

error: pathspec 'lr.awk' did not match any file(s) known to git


Add AWK script to add a file type annotation

#!/usr/bin/env awk -f
#
# Annotates a file statistic by prefixing a new column which includes the file type.
#
# Usage: annotate_file_type
#
# Input:
#   - <statistic> <filename>
#
# Output:
#   - <file_type> <statistic> <filename>
#

# When adding file extension patterns, do so in alphabetical order.

# Special cases...
/(LICENSE|NOTICE)$/ {
	print "LICENSE" OFS $1 OFS $2
	next
}
/datapackage\.json$/ {
	print "datapackage.json" OFS $1 OFS $2
	next
}
/package\.json$/ {
	print "package.json" OFS $1 OFS $2
	next
}

# Known file extensions (keep in alphabetical order)...
/\.awk$/ {
	print "AWK" OFS $1 OFS $2
	next
}
/\.bib$/ {
	print "BibTeX" OFS $1 OFS $2
	next
}
/\.c$/ {
	print "C" OFS $1 OFS $2
	next
}
/\.cpp$/ {
	print "C++" OFS $1 OFS $2
	next
}
/\.csl$/ {
	print "CSL" OFS $1 OFS $2
	next
}
/\.css$/ {
	print "CSS" OFS $1 OFS $2
	next
}
/\.csv$/ {
	print "CSV" OFS $1 OFS $2
	next
}
/\.eot$/ {
	print "fonts" OFS $1 OFS $2
	next
}
/\.gif$/ {
	print "gif" OFS $1 OFS $2
	next
}
/\.go$/ {
	print "Go" OFS $1 OFS $2
	next
}
/\.h$/ {
	print "C" OFS $1 OFS $2
	next
}
/\.hpp$/ {
	print "C++" OFS $1 OFS $2
	next
}
/\.html$/ {
	print "HTML" OFS $1 OFS $2
	next
}
/\.jl$/ {
	print "Julia" OFS $1 OFS $2
	next
}
/\.jpg$/ {
	print "JPG" OFS $1 OFS $2
	next
}
/\.js$/ {
	print "JavaScript" OFS $1 OFS $2
	next
}
/\.json$/ {
	print "JSON" OFS $1 OFS $2
	next
}
/Makefile$/ {
	print "make" OFS $1 OFS $2
	next
}
/\.md$/ {
	print "Markdown" OFS $1 OFS $2
	next
}
/\.mk$/ {
	print "make" OFS $1 OFS $2
	next
}
/\.png$/ {
	print "PNG" OFS $1 OFS $2
	next
}
/\.py$/ {
	print "Python" OFS $1 OFS $2
	next
}
/\.R$/ {
	print "R" OFS $1 OFS $2
	next
}
/\.sh$/ {
	print "bash" OFS $1 OFS $2
	next
}
/\.svg$/ {
	print "SVG" OFS $1 OFS $2
	next
}
/\.txt$/ {
	print "plaintext" OFS $1 OFS $2
	next
}
/\.woff$/ {
	print "fonts" OFS $1 OFS $2
	next
}
/\.yml$/ {
	print "YAML" OFS $1 OFS $2
	next
}

# Special cases...
$2 ~ /^\.([A-Za-z])+$|\/\.([A-Za-z])+$/ {
	print "dotfiles" OFS $1 OFS $2
	next
}
$2 ~ /\/([A-Za-z0-9_-])+$/ {
	print "executables" OFS $1 OFS $2
	next
}

# Everything else...
{
	print "OTHER" OFS $1 OFS $2
}

error: pathspec 'tools/git/scripts/annotate_file_type.awk' did not match any file(s) known to git


even cleaner comment

even cleaner comment

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/szilvajuhos/CAW.git/'