1
#ascii
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 \a \b \t \n \v \f \r
1
2 ! " # $ % & ' ( ) * + , - . /
3 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
4 @ A B C D E F G H I J K L M N O
5 P Q R S T U V W X Y Z [ \ ] ^ _
6 ` a b c d e f g h i j k l m n o
7 p q r s t u v w x y z { | } ~
2
#avidemux
for avi to mp4 use video MPEG-4 AVC
audio copy
format MP4
3
#awk
#regex
gensub(r, s, h [, t])
gensub(regExp, replacementText, replacementSpec [, targetString default $0])
BEGIN {
a = "abc def"
b = gensub(/(.+) (.+)/, "\\2 \\1", "g", a)
print b
c = gensub(/(.+) (.+)/, "\\2 \\1", "", a)
print c
d = "a b c a b c"
print gensub(/a/, "AA", "\\2", d)
d = "a b c a b c"
print gensub(/a/, "AA", 2, d)
}
def abc
def abc
AA b c a b c
a b c AA b c
4
#awk
print "blah">file.name
5
#awk
// concatenate text
substr($1, 4) "Align.txt"
6
#bash
first line #!/bin/bash
7
#bash
for compilation quote incs, defs + src
don't quote references
CR_SRCS="blah"
CR_INCLUDES="-Iblah"
g++ -o alphaIncr $CR_INCLUDES $CR_SRCS
8
#bash
#if
if goes
if ! [ $? -eq 0 ]
then
echo aborting
exit
fi
or
if [ -f userEg ]; then rm userEg; fi
if test -e $CREATESTUB_NAME ;
then
{
echo $CREATESTUB_NAME "exists";
}
else
{
echo $CREATESTUB_NAME "doesn't exist";
}
fi
9
#bash
see /home/user/index.txt for win/lx path substitutions
VAR1="Hello, "
VAR2="${VAR1}World"
echo "$VAR2"
10
#bash
#loop
# for goes:
for var in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14
do
dollar var is ${var}
done
11
#bash
check existence of prog
if ! hash python3 2>/dev/null; then
echo need python3 to proceed
exit
fi
12
#bash
#loop
loop through lines of file
while read csvFileName; do
echo "$csvFileName"
done <sheetList.txt
13
#bash
# derefd last param
${!#}
14
#bash
# %~1n
STEM=$(basename path/to/thing.svg .svg) # thing
15
#bash
#pause
read -N 1 -p "press any key"
16
#bash
find [path...] [expression] is hopeless
use
find dirname | grep "thing you want"
# or
# get list of files goes:
ls -d /media/user/photoDrive/D5000/104D5000/* | egrep -i "\.jpe?g"
see /media/user/LaCie/usr/NIK/DOM/hobbies/milestone/msDb/bin/csvizeSS.sh
17
#bash
#sqlite
compile sqlite
-DSQLITE_OMIT_LOAD_EXTENSION
18
#bash
cmd line substr "string" 1 based start length
expr substr "123456" 2 4
19
#make
rule is
target : dependency
TAB action
TAB action
20
#palemoon
palemoon clear cache: ctrl-shift-del
21
#bash
bash shell : tab-insert (C-v TAB)
Insert a tab character.
22
#xml
xml comment: <!-- ***** -->
23
#firefox
firefox default css locn %APPDATA%\Mozilla\Firefox\Profiles\
24
#gdImage
gdImage library fucks up ans = Code Generation - [Debug] MultiThreaded DLL
gdImageCreateFrom... fucks up ans = Code Generation - MultiThreaded DLL works for debug build
25
#firefox
firefox not loading on wifi change
about:config -> new preference -> boolean -> network.dns.disablePrefetch;true
26
#chm
decompile chm file
hh -decompile decomp ActiveTclHelp8.5.chm
27
#csv
convert csv to libre spreadsheet
c:\bin\csvToOds.bat
set LOFF_PATH=C:\Program Files\LibreOffice 5\program\soffice.exe or something
"%LOFF_PATH%" --convert-to ods %1
and vice versa
"%LOFF_PATH%" --convert-to csv %1
28
#cmd
$ headtxt 36 "string" "*"
************** STRING **************
29
#cmd
$ figlet -f banner string
#### ##### ##### # # # ####
# # # # # ## # # #
#### # # # # # # # #
# # ##### # # # # # ###
# # # # # # # ## # #
#### # # # # # # ####
30
#ocr
for %t in (*.jpg) do "C:\Program Files\Tesseract-OCR\tesseract.exe" %t %~nt
31
#dot
everything enclosed by:
digraph G {
}
33
#dot
name_of_node [shape = record label="{<def>name|{<a>A|<b>B|<c>C}}"];
is a box with A B C below name
34
#dot
record label semantics example:
1 2 34 5 67
V V VV V VV
label="{<def>pageLink|<id>idididid|{<p>page.html|<f>fjsfls}}"
1 - set layout vertical
box content
2 - divider, so new box below
box content
3 - divider, new box below
4 - set layout horizontal
box content
5 - divider, new box at side
box content
6 - eob
7 - eob
<fieldName> names the label and can be used
to address arc beginnings and ends
gives:
----------------------
pageLink
----------------------
<id>idididid
----------------------
<p>page.html|<f>fjsfls
----------------------
35
#dot
name:a:s->another_name[color="green"]
joins bottom of name's A box to another_name with a green line
36
#dot
subgraph cluster_some_other_name
{
}
creates a graph in a box
37
#dot
rankdir, default TB, LR (left to right) or TB (top to bottom)
ranksep, default .75, separation between ranks, in inches.
38
#dot
label arc:
Idle -> WriteWait [fontcolor=black label="arc label goes here" color=black style = solid];
39
#dot
dot User's Manual, January 26, 2006 10
Name Default Values
color black node shape color
comment any string (format?dependent)
distortion 0.0 node distortion for shape=polygon
fillcolor lightgrey/black node fill color
fixedsize false label text has no affect on node size
fontcolor black type face color
fontname Times?Roman font family
fontsize 14 point size of label
group name of node's group
height .5 height in inches
label node name any string
layer overlay range all, id or id:id
orientation 0.0 node rotation angle
peripheries shape?dependent number of node boundaries
regular false force polygon to be regular
shape ellipse node shape; see Section 2.1 and Appendix E
shapefile external EPSF or SVG custom shape file
sides 4 number of sides for shape=polygon
skew 0.0 skewing of node for shape=polygon
style graphics options, e.g. bold, dotted,
filled; cf. Section 2.3
URL URL associated with node (format?dependent)
width .75 width in inches
z 0.0 z coordinate for VRML output
Table 1: Node attributes
40
#ebnf
ebnf
definition =
concatenation ,
termination ;
alternation |
option [...]
repetition {...}
grouping (...)
terminal "..." or '...'
eg preamble = version name [codeblock] ;
- option "[" "]"
The sequence of symbols within these brackets are optional.
(e.g. Rule1 = "begin [optional things] end.")
-iteration "{" "}"
The sequence of symbols within these brackets can occur from zero to infinite times.
(e.g. Rule2 = "begin {and again} end.")
-alternative "|"
It allows to choose a sequence of symbols.
(e.g. Rule3 = "I am a (good | bad) programmer.")
-grouping "(" ")"
These brackets are used to group sequences of symbols in a mathematical way.
41
#git
xfer repo:
on local
git --bare update-server-info
mv hooks/post-update.sample hooks/post-update
goto .git dir
start server
on remote
git clone http://localhost
gets remote in dir localhost
on remote remote do
git clone http://192.168.1.3
and waaaaait
42
#git
zip of repo:
gitarch zipname
43
#git
archive proj by committing, delete everything except .git
reconstitute by resetting to commit with mode hard
44
#git
get local copy of repo with:
git clone https://github.com/your_username/YYYY-MM-DD-site
45
#git
timestamp of last commit
git log -n 1 --pretty=format:%ci
47
#git
delete branch
git branch -d ver_3
48
#git
change branch - get list of branches, then checkout
git branch
git checkout master
49
#git
gitignore all sub dirs:
*/*
50
#git
all file there have ever been:
git log --pretty=format: --name-only --diff-filter=A | sort -u> allGits1.txt
git log --all --pretty=format: --name-only --diff-filter=A | sort - > allGits2.txt
51
#git
all deleted files
git log --diff-filter=D --summary
all deleted files | less
git log --diff-filter=D --summary
52
#git
rename branch
git branch -m main deadEnd
53
#git
diff two branches
git difftool master final_cgigen_v2
54
#html
description list
4.5.8 The dl element
Categories
Flow content.
Contexts in which this element can be used:
Where flow content is expected.
Content model:
Zero or more groups each consisting of one or more
dt elements followed by one or more dd elements.
ie dl { [ dt {dd[{dd}]}{} ] }
dlEl: "<dl>" dlContent "</dl>" ;
dlContent:
| dlContentGroup
| dlContentGroup dlContent
;
dlContentGroup : dtList ddList ;
dtList: dtEl
| dtList dtEl
;
dtEl: "<dt>...</dt>"
ddList: ddEl
| ddList ddEl
;
ddEl: "<dd>...</dd>" ;
55
#html
tabindex attribute
+ If the value is a zero
The user agent must allow the element to be focused,
should allow the element to be reached using sequential
focus navigation, and should follow platform conventions
to determine the element's relative order.
56
#html
inputmode
use correct input type. can set on contenteditable types. possible values
none
text
tel
url
email
numeric
decimal
search
57
#html
autotofocus
boolean
Automatically focus the element when the page is loaded
58
#html
datalist element
+ represents a set of option elements that represent
predefined options for other controls.
example
<label>Homepage: <input name=hp type=url list=hpurls></label>
<datalist id=hpurls>
<option value="http://www.google.com/" label="Google">
<option value="http://www.reddit.com/" label="Reddit">
</datalist>
59
#iterator
#erase
#std-string
erase invalidates its iterator argument so do this:
std::set<std::string>::iterator it;
for (it = vsWords.begin(); res && it != vsWords.end(); /* NB */)
{
if (*it=="erase me")
it = vsWords.erase(it);
else
it++;
}
60
#html
accesskey attribute
+ value is used by the user agent as a guide for creating
a keyboard shortcut that activates or focuses the element.
example
accesskey="B"
61
#gprof
#profiling
g++ -pg incs defs srcs -o prog.exe
prog.exe
gprof [-b] prog.exe > prof.txt
62
#inkscape
#cmd
use -y for background opacity:
"C:\Program Files\Inkscape\inkscape.exe" -y 255 --export-png=filename.png -d 300 -h 1776 -w 1260 filename.svg
63
#javascript
#string
#replace
"string".replace("st","w");
"wibble".replace(/^w.b*/,"wrigg");
"wibble".replace(/b/g,"g");
64
#javascript
"wibble".lastindexOf("b");
65
#javascript
// size and posn of elements
var bodyRect = document.body.getBoundingClientRect(),
elemRect = element.getBoundingClientRect(),
offset = elemRect.top - bodyRect.top;
alert('Element is ' + offset + ' vertical pixels from <body>');
66
#javascript
REGEXP
res = [];
re = new RegExp ('^' + s);
for (i = 0; i < vaxLoc.length; i++)
{
if (re.test(vaxLoc[i].outcode))
{
res.push(vaxLoc[i]);
}
}
if (sArr.length > 0)
firstLetter = /[A-Z]/.test(sArr[0]);
67
#javascript
// psuedo download
// somewhere in js:
var link = document.getElementById('downloadlink');
link.href = makeTextFile(makeNewPage(g_curTags));
link.style.display = 'block';
function makeNewPage(tags)
{
res = "<!DOCTYPE html>\n"
+ "<html>\n"
+ "<head>\n"
+ "<meta name=\"viewport\" content=\"width=device-width,user-scalable=yes\">\n"
+ "<style type=\"text/css\">\n"
+ "body\n"
+ "{\n"
+ " background-color: black;\n"
+ " color:white;\n"
+ "}\n"
+ "section\n"
+ "{\n"
+ " color:white;\n"
+ " text-align: center;\n"
+ "}\n"
+ "div.chk label\n"
+ "{\n"
+ " display: inline-block;\n"
+ "}\n"
+ "img.tn\n"
+ "{\n"
+ " max-width:200px;\n"
+ " max-height:200px;\n"
+ "}\n"
+ "</style>\n"
+ "</head>\n"
+ "<body>\n<section>\n";
// some tag type blah in here
res = res
+ "</section>\n</body>\n"
+ "</html>\n"
return res;
}
function makeTextFile(text)
{
var textFile = null;
var data = new Blob([text], {type: 'text/html'});
// If we are replacing a previously generated file we need to
// manually revoke the object URL to avoid memory leaks.
if (textFile !== null)
{
window.URL.revokeObjectURL(textFile);
}
textFile = window.URL.createObjectURL(data);
return textFile;
}
// html
<a download="mtc.html" id="downloadlink" style="display: none">Download</a>
//fake following a link / load new page
function gotoNewPage(tags)
{
var newloc = window.location.protocol + "//" + window.location.pathname;
var q = makeQuery(tags);
if (q.length > 0)
{
window.location.href = newloc+"?"+q;
}
else
{
window.location.href = newloc;
}
}
68
#javascript
#sort
// sorting
xSections = [
{"id":"75mm L","width":85.0,"height":32.0}
,{"id":"75mm R","width":85.0,"height":32.0}
,{"id":"57mm L","width":66.0,"height":32.0}
,{"id":"57mm R","width":66.0,"height":32.0}
,{"id":"50mm L","width":60.0,"height":32.0}
,{"id":"50mm R","width":60.0,"height":32.0}
,{"id":"small stop","width":25.0,"height":14.0}
];
sortXSections =
function (a,b)
{
if (a===b)
{
return 0;
}
// a and b are different
if (a.id > b.id)
{
return 1;
}
if (a.id < b.id)
{
return -1;
}
// a and b have same id
if (a.width > b.width)
{
return 1;
}
if (a.width < b.width)
{
return -1;
}
// a and b have same width
if (a.height > b.height)
{
return 1;
}
if (a.height < b.height)
{
return -1;
}
return 0; // == shouldn't get here'
};
xSections.sort(sortXSections);
69
#javascript
function clearDropdown(selectElement)
{
const optsToRemove = selectElement.options.length;
for (var i = 0; i < optsToRemove; i++)
{
selectElement.remove(0);
}
}
function addDropdownOptions(selectElement, arrayOfStr)
{
if (!Array.isArray(arrayOfStr))
{
return;
}
clearDropdown(selectElement);
for (var i = 0; i < arrayOfStr.length; i++)
{
var opt = document.createElement("option");
if (typeof (arrayOfStr[i]) == 'string')
{
opt.text = arrayOfStr[i];
selectElement.add(opt);
}
}
}
70
#javascript
function clearTBody(tb)
{
var tableRows = tb.rows;
const rowsToDelete = tableRows.length;
for (var i = 0; i < rowsToDelete; i++)
{
tb.deleteRow(0);
}
}
71
#javascript
get user input
var jobNo = prompt("job number");
fJobNumber.value = jobNo;
72
#javascript
// insert element into array
var thing[];
thing.push("thing");
73
#javascript
// is it defined?
if (jobFile !== undefined)
74
#javascript
// javascript "class"
function Archi(material, section, jambLength, headLength)
{
this.material = material;
this.section = section;
this.jambLength = jambLength;
this.headLength = headLength;
this.toDb = toDb;
function toDb(jobRef, lineRef, side, sqljs)
{
var q = "INSERT INTO "
+ side
+ "(jobRef, lineRef, material, section, jambLength, headLength) "
+ "VALUES ("
+ jobRef
+ ", "
+ lineRef
+ ", '"
+ this.material
+ "', '"
+ this.section
+ "', "
+ this.jambLength
+ ", "
+ this.headLength
+ ");"
sqljs.run(q);
}
}
var timerFunction = setInterval(animate, timerMsecs);
function animate()
{
tickCount = tickCount + 1;
topIm.style.opacity=opacForTick();
window.status=opacForTick();
}
<script
type="text/javascript"
id="script40"><![CDATA[
var tickCount = 0;
var topIm;
var transCount = 100;
var stableCount = 500;
var cycleLen = 2*(transCount + stableCount);
var timerMsecs = 10;
onload = setUp;
function setUp()
{
topIm = document.getElementById("image20")
}
var timerFunction = setInterval(animate, timerMsecs);
function animate()
{
tickCount = tickCount + 1;
topIm.style.opacity=opacForTick();
window.status=opacForTick();
}
function opacForTick()
{
cycleNum = tickCount%cycleLen;
if (cycleNum > 2 * transCount + stableCount)
return 0.0;
if (cycleNum > transCount + stableCount)
return 1.0 - (cycleNum - (transCount + stableCount)) / transCount;
if (cycleNum > transCount)
return 1.0;
return 1.0 * cycleNum / transCount;
}
]]></script>
75
#javascript
// literal text
var helpText = `<h2>Raising App</h2>
<p><a href="mailto:nick [at] njames co uk">Nick James</a> Aug 2019</p>
<p style="font-style:italic; max-width:90%">
An app to visualise the predicted thick wall thickness
of the raising with the chosen profile.</p>
<h3>What to do</h3>
<p>Use the browse button to load a profile, which must
be a two colour .png. This image should appear
in the profile box which will expand to the size of the image.
Select a circle thickness in scale with your profile and then
choose whether to just raise (ie let the thickness increase)
or to raise and keep a constant wall thickness. Press go, and
with luck an information box and an image of the predicted
raising should appear. You may get a pop up saying try again.
Trying again seems to work reliably...</p>
<h3>Info Box</h3>
<p>The info box has different details for different raising methods:</p>
<button id="closeHelp" onclick="undoOverlay();">close</button>
`;
76
#javascript
/blah/ is a regex
/blah/.test('string containing blah') = true;
77
#javascript
// open link in new tab/window
window.open(link, '_blank');
// open
window.location.assign(link);
78
#lex
not working? patterns are matched from top of the list
least inclusive rules should come first.
not working? . doesn't match newline, use .|\n
not working? try %option noyywrap
79
#lex
start condition:
say %x CONDITION after first %}
%x is exclusive
apply to patterns like so - <CONDITION>pattern {...}
access the current start condition using the integer-valued YY_START macro
80
#lex
#literals
\x22 = "
\x2e = .
\x2f = /
\x5c = \
\x3c = <
\x3e = >
\x7b = {
\x7d = }
\x20 is space
\x7c = |
81
#lex
defining a rule with space in it doesn't always work (unrecognized rule)
use \x20 instead.
82
#lex
<<EOF>> {
/* we fake this to get round the no newline
at end of file problem */
if (seenEOF == 0)
{
seenEOF = 1;
return END_OF_FILE;
}
else
{
yyterminate();
}
}
83
#lex
#dodge
compile with -DYY_NEVER_INTERACTIVE=1 when using g++ -std=c++11 to get
round fileno problem
84
#lex
#options
lex options:
-d
makes the generated scanner run in debug mode.
-i
instructs flex to generate a case-insensitive scanner.
-s
causes the default rule (that unmatched scanner input is
echoed to stdout) to be suppressed.
-L
instructs flex not to generate #line directives.
-ooutput
directs flex to write the scanner to the file out- put instead of lex.yy.c.
-Pprefix
changes the default yy prefix used by flex for all globally-visible
variable and function names to instead be prefix.
85
#lex
#options
%options in source file:
caseful or
case-sensitive opposite of -i (default)
case-insensitive or
caseless -i option
debug -d option
default opposite of -s option
array equivalent to "%array"
pointer equivalent to "%pointer" (default)
86
#lex
#options
%options unavailable from command line
main
directs flex to provide a default main() program for the scanner, which
simply calls yylex().
yylineno
directs flex to generate a scanner that maintains the number of the
current line read from its input in the global variable yylineno.
yywrap
if unset (i.e., %option noyywrap), makes the scanner not call
yywrap() upon an end-of-file, but simply assume that there are no
more files to scan (until the user points yyin at a new file and
calls yylex() again).
%option outfile="ABC"
is equivalent to -oABC
%option prefix="XYZ"
is equivalent to -PXYZ.
87
#lex
#define YY_USER_ACTION gSchedule.setLastToken(yytext);
88
#lua
io.stderr:write("yuyruyruyr\n")
89
#lua
#read-file
require() not working? use dofile(filename)
local ins = dofile("i:\\lib\\lua\\inspect.lua")
str = ins(var)
90
#xxd
#dodge
#cpp
-i output in C include file style.
xxd -i %CO_DB% > I:\lib\osgb\convertOsgb\source\osgb.db.h
gets you unsigned char osgb_db[]
write file on dbFp like so
for (i = 0; i < osgb_db_len; i++)
fputc((int)osgb_db[i], dbFp);
91
#mysql
"C:\Program Files (x86)\MySQL\MySQL Server 4.1\bin\mysql.exe" -uroot -ppassword
92
#mysql
show databases;
use <dbName>;
show tables;
show columns from <tableName>;
93
#cmd
#dodge
mangle a string and use it in a command, eg:
sed -n "/%PLACE_NUMBER% /p" places.txt | sed "s/^[0-9]* *//" > curName.txt
set /p PLACE_NAME= < curName.txt
94
#pandoc
#options
-f markdown
-t html
-H %FILEBASE%.style - include in head
-s standalone
--self-contained - no dependencies
--toc - table of contents
--toc-depth=NUMBER depth of toc default 3
-N - number sections
-c file.css - css reference to file.css
--latex-engine path\to\pdflatex.exe
--shift-heading-level-by=1
--metadata author="N James"
--metadata title="Extending GB1900: reloaded"
--metadata date=%MIDN%
--metadata pagetitle="family tree reasoning"
pandoc --list-output-formats
pandoc --list-input-formats
95
#pandoc
do dates like
sqlite3 :memory: "select date('now');" > junk
or
echo %DATE% | sed "s#/#-#g" > junk
then
set /p MIDN=<junk
del junk
or
--metadata date="$(date --rfc-3339=date)"
96
#sql
#dodge
you have
oldTab(id, common, fields) in old db
newTab(id, common, fields) in new db
with same common fields but different ids
you also have
srcTab(foreignId refs oldTab.id, ...)
destTab(foreignId ref newTab.id, ...)
you need to insert/update destTab with ids
such that destTab.id refers to same data
as srcTab.id
with transTab as (
select newTab.id as newId
, oldTab.id as oldId
--, newTab.common
--, newTab.field
from newTab
join oldTab using (common, fields)
)
insert into newTab (id, field1, field2...)
select
(select newId from transTab where oldId=srcTab.foreignId) AS newId
, field1
, field2
..
from srcTab
97
#pandoc
#lua
#bbcode
pandoc -t C:\Users\user\AppData\Roaming\pandoc\filters\bbcode.lua -f html -o index.bbcode index.html
pandoc -t %appdata%\pandoc\filters\bbcode.lua -f html -o index.bbcode index.html
also gmi.lua for gemini
98
#pandoc-lua
pandoc uses lua 5.3
99
#pandoc-lua
remote debugging
- welcome to dll hell
set ZBS=F:\PortableApps\zeroBrane
set LUA_PATH=.\?.lua;%ZBS%\lualibs\?\?.lua;%ZBS%\lualibs\?.lua
set LUA_CPATH=%ZBS%\bin\?.dll;%ZBS%\bin\clibs53\?.dll
100
#pandoc-lua
file:///C:/Program%20Files/Pandoc/Pandoc%20User%27s%20Guide.html#custom-writers
do pandoc --print-default-data-file sample.lua
101
#pandoc-lua
You can find the default user data directory on your system by looking at
the output of pandoc --version.
102
#paradox
~id in qbe file is a parameter (called id) to the query
103
#image
see c:\bin\picsorter for list to ordered page, slidy page
and showOnw page
see I:\usr\nik\dev\tag* for image tagging
image tagging works by creating a db, populating
it with images and tags, giving a javascript to
display the images and page styling.
also, see I:\usr\NIK\dev\tagImage\workflow.txt
104
#printf
#options
printf
%[ flags] [ width] [ .precision] [{ h | l | ll | I | I32 | I64}] type
Flag Meaning Default
- Left align the result within the given field width. Right align.
+ Prefix the output value with a sign (+ or -) if
output value is of a signed type.
the Sign appears only for negative signed values (-).
0 If width is prefixed with 0 , zeros are added until No padding.
the minimum width is reached. If 0 and - appear,
the 0 is ignored. If 0 is specified with an integer
format ( i , u , x , X , o , d ) and a precision
specification is also present (for example, %04.d ),
the 0 is ignored.",
blank (' ') Prefix the output value with a blank if the output No blank appears.
value is signed and positive; the blank is ignored
if both the blank and + flags appear.",
# When used with the o , x , or X format, the # flag No blank appears.
prefixes any nonzero output value with 0, 0x, or 0X,
respectively.",
When used with the e , E , f , a or A format, the # Decimal point appears only
flag forces the output value to contain a decimal if digits follow it.
point in all cases.",
When used with the g or G format, the # flag forces Decimal point appears only
the output value to contain a decimal point in all if digits follow it.
cases and prevents the truncation of trailing zeros. Trailing zeros are truncated.
Ignored when used with c , d , i , u , or s .",
If the width specification is an asterisk (*), an
int argument from the argument list supplies the value.
The width argument must precede the value being formatted in the argument list.
105
#qsv
#options
qsv goes `qsv command options`
qsv excel -s (name|number0) | --metadata c
qsv headers [-j] -j = no index
qsv safenames - db friendly header
106
#sql
#dodge
CAST ( expr AS type-name )
107
#sqlite
#dodge
.parameter
.parameter init command creates the temp.sqlite_parameters
table if it does not already exist.
.param list command shows all entries in the temp.sqlite_parameters table.
.param clear command drops the temp.sqlite_parameters table.
.param set KEY VALUE
.param unset KEY commands create or delete entries
from the temp.sqlite_parameters table.
108
#qsv
qsv select 1,4
qsv select "/^.*\d.*$/"
qsv select 3-1
109
#rebol
#red
A field in face object is called a facet.
110
#rebol
#red
declare funcs after REBOL [] stmt
111
#rebol
#red
#"A" is a char!
a: "a is a string"
b: {b is a string}
112
#rebol
#red
"blah has no value" - probably need to assign to blah like so blah:
113
#rebol
#red
types: inferred from literal form
- see file:///C:/ProgramData/Red/repo/docs-master/en/datatypes.html
114
#git
#dodge
search everything past and present
git log -Gsought -p
then /sought
115
#red
declare funcs after Red [] stmt
116
#grammar
#cgigen
I:\usr\NIK\dev\cgiGen\doc\cgigen.y.dot.png
117
#css
#font
font-family :
'serif' (e.g., Times)
'sans-serif' (e.g., Helvetica)
'cursive' (e.g., Zapf-Chancery)
'fantasy' (e.g., Western)
'monospace' (e.g., Courier)
118
#css
#font
font-size: 16px;
12pt;
119
#red
RED []
- *** Error: not a Red program!
120
#rg
#options
ripgrep 13.0.0
Andrew Gallant <jamslam@gmail.com>
ripgrep (rg) recursively searches the current directory for a regex pattern.
By default, ripgrep will respect gitignore rules and automatically skip hidden
files/directories and binary files.
Use -h for short descriptions and --help for more details.
Project home page: https://github.com/BurntSushi/ripgrep
USAGE:
rg [OPTIONS] PATTERN [PATH ...]
rg [OPTIONS] -e PATTERN ... [PATH ...]
rg [OPTIONS] -f PATTERNFILE ... [PATH ...]
rg [OPTIONS] --files [PATH ...]
rg [OPTIONS] --type-list
command | rg [OPTIONS] PATTERN
rg [OPTIONS] --help
rg [OPTIONS] --version
ARGS:
<PATTERN> A regular expression used for searching.
<PATH>... A file or directory to search.
OPTIONS:
INPUT
-s, --case-sensitive Search case sensitively (default).
-i, --ignore-case Case insensitive search.
-f, --file <PATTERNFILE>... Search for patterns from the given file.
-F, --fixed-strings Treat the pattern as a literal string.
-g, --glob <GLOB>... Include or exclude files.
--glob-case-insensitive Process all glob patterns case insensitively.
-e, --regexp <PATTERN>... A pattern to search for.
-v, --invert-match Invert matching.
OUTPUT
-c, --count
Only show the count of matching lines for each file.
--count-matches
Only show the count of individual matches for each file.
-m, --max-count <NUM> Limit the number of matches.
-x, --line-regexp Only show matches surrounded by line boundaries.
-w, --word-regexp Only show matches surrounded by word boundaries.
-l, --files-with-matches Print the paths with at least one match.
--files-without-match Print the paths that contain zero matches.
-o, --only-matching Print only matched parts of a line.
-r, --replace <REPLACEMENT_TEXT> Replace matches with the given text.
-h, --help
Prints help information. Use --help for more details.
FORMATING
-A, --after-context <NUM> Show NUM lines after each match.
-B, --before-context <NUM> Show NUM lines before each match.
-C, --context <NUM> Show NUM lines before and after each match.
--context-separator <SEPARATOR> Set the context separator string.
-H, --with-filename Print the file path with the matched lines.
-I, --no-filename Never print the file path with the matched lines.
--heading Print matches grouped by each file.
--no-heading Don't group matches by each file.
-n, --line-number Show line numbers.
-N, --no-line-number Suppress line numbers.
-q, --quiet Do not print anything to stdout.
121
#sed
#dodge
pick out table names from sqlite schema
sqlite3 elshDB.sqlite ".schema" | sed -r -n "s/^CREATE TABLE ([a-zA-Z]+).*$/\1/p"
122
#sed
#dodge
# address last line ($) and remove last char (.$)
$ s/.$//
123
#sed
#dodge
# address not (!) last line ($)
# and substitute comma for eol
$! s/$/,/
124
#sed
#options
sed -n suppress automatic printing of pattern space
sed -r gets extended re's
125
#css
#font
font-style:
normal
italic
oblique
126
#sed
#dodge
# print line number 52
sed -n '52p' # method 1
sed '52!d' # method 2
sed '52q;d' # method 3, efficient on large files
127
#sed
#dodge
# print first 10 lines of file (emulates behavior of "head")
sed 10q
128
#sed
#dodge
# print section of file from regular expression to end of file
sed -n '/regexp/,$p'
129
#sed
# append and insert go like:
sed "/regexp/i your text here" file
sed "/regexp/a your text here" file
130
#sed
#literals
# awkward chars
\x0d = CR
\x0a = LF
\x20 = space
\x22 = "
\x25 = %
\x27 = '
\x2a = *
\x2f = /
\x3c = <
\x3e = >
\x5e = ^
\x7b = {
\x7c = |
\x7d = }
\xA3 = £
131
#sed
number each line of a csv file
sed = filename | sed 'N;s/\n/,/'
132
#state-machine
while(!done)
read next input
do action
look up transition from cur state on input
move to next state
ie next state = transition(cur state, input)
133
#sublime
#dodge
in python console (View -> show/hide console)
view.settings().set("rulers", [40,60,80])
view.settings().set("rulers", [])
134
#css
#font
font-variant:
normal
small-caps
135
#bash
3 sorts of substitution : filename, parameter and command
" " - turn off filename subst only
' ' - turn off everything
` ` - command substitution only
\ - protects next char
136
#viewport
#html
<meta name="viewport" content="width=device-width,user-scalable=yes">
137
#vscode
explorer.sortOrder in features explorer
"explorer.sortOrder": "filesFirst"
"editor.findMatchBackground": "#d1dfde",
"editor.findMatchHighlightBackground": "#8dcec0"
138
#vscode
settings suggestions for autocomplete commit
139
#vscode
user settings
C:\Users\user\AppData\Roaming\Code\User\settings.json
140
#vscode
set rulers
"editor.rulers": [28,111,124,131,186],
141
#xhtml
B. Element Prohibitions
This appendix is normative.
The following elements have prohibitions on which elements they can contain
(see SGML Exclusions). This prohibition applies to all depths of nesting, i.e.
it contains all the descendant elements.
a
must not contain other a elements.
pre
must not contain the img, object, big, small, sub, or sup elements.
button
must not contain the input, select, textarea, label, button, form,
fieldset, iframe or isindex elements.
label
must not contain other label elements.
form
must not contain other form elements.
4.12. Entity references as hex values
SGML and XML both permit references to characters by using hexadecimal values.
In SGML these references could be made using either &#Xnn; or &#xnn;. In XML
documents, you must use the lower-case version (i.e. &#xnn;)
142
#xmake
"c:\Program Files\xmake\xmake.exe" f -p windows -a x86
143
#yacc
#options
-b file_prefix
uses file_prefix instead of y as the prefix for the output file names.
-d
generates the file y.tab.h with the #define statements that associate
the yacc-assigned "token codes" with the user-declared "token names".
This association allows source files other than y.tab.c to access the token codes.
-l
specifies that the code produced in y.tab.c will not contain any #line constructs.
This option should only be used after the grammar and the associated actions are
fully debugged.
-p sym_prefix
uses sym_prefix instead of yy as the prefix for the external linkage names.
-t
compiles runtime debugging code by default. Runtime debugging code is
always generated in y.tab.c under conditional compilation control. By
default, this code is not included when y.tab.c is compiled. Whether
or not the -t option is used, the runtime debugging code is under
the control of YYDEBUG, a preprocessor symbol. If YYDEBUG has a non-zero
value, then the debugging code is included. If its value is zero, then
the code is not included. The size and execution time of a program
produced without the runtime debugging code is smaller and slightly faster.
-v
prepares the file y.output, which contains a description of the parsing
tables and a report on conflicts generated by ambiguities in the grammar.
144
#lex
catch line ends
(\r\n)|\n
145
#lex
mode of operation:
the earliest rule matching the longest possible string
high rule with short match is trumped by lower rule with longer match
146
#javascript
var numList = geoNumList.value;
var numArray = numList.split("\n");
for (var i = 0; i < numArray.length; i++)
{
/^[0-9]+$/.test(numArray[i]);
}
147
#dodge
#cpp
for timestamp use
std::string sTimeNow = stringtime::write(time(NULL));
or
time_t t = time(NULL);
char buf[BUFSIZ];
buf[0] = 0;
strftime(buf, BUFSIZ-1, "%Y-%m-%d %H:%M:%S", gmtime(&t));
148
#cpp
#std-set
SET ELEMENTS ARE IMMUTABLE - only operations are insert and delete
std::set
A standard container made up of unique keys
std::set<std::string>::iterator it = m_setOfIDs.find(s);
if (it != m_setOfIDs.end())
Can define key::operator<(..) to deal with comparison function
bool operator<(const Component c) const
{
return m_part < c.m_part;
}
149
#cpp
fgets(char *str,
int n,
FILE *stream)
returns NULL on failure
feof or ferror may be true
gets (at most) n chars inc terminating null
stops on new line and returns it
see I:\usr\NIK\dev\UTIL\CUTILS\linkify.cpp
and i:\lib\fileread.h
150
#std-string
#cpp
#dodge
pos = std::string.find(sought, startIndex);
std::string t = s.substr(startpos, howManyChars);
goto 152
// lower case a string
std::string s;
std::ctype<char> ct;
ct.tolower(&s[0], &s[s.length()]);
OR
std::transform(s.begin(), s.end(), s.begin(), tolower);
std::string::npos
replace : try nj::subst
std::string prevLabel ("cn:0009");
prevLabel.erase(prevLabel.find(":"), 1); // "cn0009"
151
#cpp
#dodge
#operator
bool foo::operator== (const foo &rhs) const
{
return m_ember == h.m_ember; // or some such
}
Pixel & operator+=(const Pixel &rhs)
{
m_value += rhs.m_value;
return *this;
}
const Pixel operator+(const Pixel &other) const
{
Pixel res = *this;
res += other;
return res;
}
152
#cpp
#dodge
#std-map
std::map<key, value> mapThing;
key keyThing;
value valueThing;
mapThing.clear();
mapThing.insert(std::make_pair(keyThing, valueThing));
// or
mapThing[keyThing] = valueThing;
valueThing = mapThing[keyThing];
key someRandomKey; // not in mapThing
value aValueThing = mapThing[someRandomKey];
// NB inserts (someRandomKey, default value) into mapThing and sets aValueThing
// to the newly created default value.
key notThere;
if(mapThing.find(notThere) == mapThing.end())
{
// => notThere not in mapThing
}
// also
assert (mapThing.count(notThere) == 0);
assert (mapThing.count(valueThing) == 1);
static initialization sub std 11 - not pretty
otherwise plain old initializer
std::pair<std::string, TEXT_ANCHOR> strAnchors[]=
{
std::pair<std::string, TEXT_ANCHOR>("start", TEXT_ANCHOR_START),
std::pair<std::string, TEXT_ANCHOR>("middle", TEXT_ANCHOR_MIDDLE),
std::pair<std::string, TEXT_ANCHOR>("end", TEXT_ANCHOR_END),
};
size_t numSAnchors = sizeof(strAnchors)/sizeof(std::pair<std::string, TEXT_ANCHOR>);
std::map<std::string, TEXT_ANCHOR> g_strAnchors(strAnchors, strAnchors + numSAnchors);
c++11 goes
std::map <KML_CANONICAL, std::string> g_canonicals = // m_canonical[KML_CANONICAL] is sql clause
{
{KMLCAN_NATIONALID, ""},
{KMLCAN_OLDCOUNTY, ""},
{KMLCAN_GEOGRAPHIMAGELINK, ""},
{KMLCAN_DISTRICT, ""},
{KMLCAN_RECORDORIGIN, ""},
{KMLCAN_STATUS, ""},
{KMLCAN_GRIDREF, ""},
{KMLCAN_ROADNUMBER, ""},
{KMLCAN_TURNPIKE, ""},
{KMLCAN_COMMUNITY, ""},
{KMLCAN_GENERALLOCATION, ""},
{KMLCAN_POSITION, ""},
{KMLCAN_CATEGORY, ""},
{KMLCAN_DESIGN, ""},
{KMLCAN_ACTIVE, ""},
{KMLCAN_LATITUDE, ""},
{KMLCAN_LONGITUDE, ""}
};
153
#cpp
#dodge
#function
void* (*pvFunctprs)();
pvFunctprs: pointer to function returning pointer to void
typedef bool (HtmlgenSpec::*chkFnPtr)(std::string &);
std::vector<chkFnPtr> chkFns;
chkFns.push_back(&HtmlgenSpec::getSymbols);
res = res && (this->*chkFns[i])(err);
struct StateFunc
{
char *m_state;
int (Meterbase::*m_func)(FILE *);
};
StateFunc funcTable[] =
{
{"show->billstats", &Meterbase::showBillStats},
{"show->projected", &Meterbase::showProjected},
{"show->bill->elec", &Meterbase::showBillElec},
{"show->bill->gas", &Meterbase::showBillGas},
{"new->bill->elec", &Meterbase::newBillElec},
{"new->bill->gas", &Meterbase::newBillGas},
{"show->reading->gas", &Meterbase::showReadingGas},
{"show->reading->elec", &Meterbase::showReadingElec},
{"new->reading->gas", &Meterbase::newReadingGas},
{"new->reading->elec", &Meterbase::newReadingElec},
};
154
#cpp
#dodge
#operator
explicit conversions from a given class type to another type.
Conversion from a class type using conversion functions.
syntax:
conversion-function-name :
operator conversion-type-name ()
conversion-type-name :
type-specifier-list ptr-operator[opt]
eg
class Money
{
double _amount;
public:
operator double()
{
return _amount;
}
};
int main()
{
Money Account;
double CashOnHand = Account;
}
155
#cpp
#dodge
#cpp-ctor
class foo
{
bar *m_pBar;
foo(const foo &f); // copy ctor
foo &operator= (const foo &f); // assignment operator
}
foo::foo(const foo &f)
{
// member = f.member _but_
m_pBar = new bar;
*m_pBar = *f.m_pBar; // and m_pBar must be deleted in dtor
}
foo & foo::operator= (const foo &f)
{
if (this != &f)
{
// member = f.member _but_
delete m_pBar;
m_pBar = new bar;
*m_pBar = *f.m_pBar; // and m_pBar must be deleted in dtor
}
return *this;
}
156
#dodge
#cpp
#argc
argc is >= 1
argc == n => n-1 args in argv[1] ... argv[n-1]
hence argc == 1 => no args
n args => argc == n + 1
157
#cpp
#dodge
#find
#include <algorithm>
std::vector<std::string>::iterator it;
it = find(m_tokens.begin(), m_tokens.end(), s);
if (it == m_tokens.end())
{
return false;
}
return true;
158
#adr
architecture decision records
use gitbash
usage: adr help COMMAND [ARG] ...
COMMAND is one of:
config
generate
help
init
link
list
new
upgrade-repository
Run 'adr help COMMAND' for help on a specific command.
160
#loop
#cmd
loop over lines of a file
for /f "tokens=*" %%t in (file.ext) do echo %%t
more looping
FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k
FOR /L %variable IN (start,step,end) DO command [command-parameters]
161
#dodge
#cmd
2>&1 redirects stderr to stdout
162
#dodge
#cmd
lower case a file: tr [:upper:] [:lower:]
163
#dodge
#cmd
lose newlines: tr -d \r\n
164
#dodge
#cmd
convert \ to /: tr "\\" "/"
165
#dodge
#cmd
redirect stderr to pipe:
prismwriter shed.prismWriter 2>&1 | sed !/^^.*PW.*/d
166
#dodge
#cmd
get user input:
SET /P envVarToSet=[promptString]
167
#dodge
#cmd
%~1 - expands %1 removing any surrounding quotes (")
%~f1 - expands %1 to a fully qualified path name
%~d1 - expands %1 to a drive letter only
%~p1 - expands %1 to a path only
%~n1 - expands %1 to a file name only
%~x1 - expands %1 to a file extension only
%~s1 - expanded path contains short names only
%~a1 - expands %1 to file attributes
%~t1 - expands %1 to date/time of file
%~z1 - expands %1 to size of file
168
#dodge
#cmd
#if
IF EXIST filename. (
del filename.
) ELSE (
echo filename. missing.
)
169
#dodge
#cmd
add cmd to send to context menu:
goto C:\Users\user\AppData\Roaming\Microsoft\Windows\SendTo
add shortcut to desired file
170
#cut
#cmd
-f field -d delim file
cut -f 1 -d " " %1\md5DirList.txt
171
#image
#dodge
@C:\bin\ImageMagick-6.7.9-4\convert page1.jpg -resize x3900 -density 118x118 resized\seq1.png
172
#image
#dodge
rem remove pixels from sides and top / bottom
C:\bin\ImageMagick-6.7.9-4\convert *.jpg -shave 756x720!+380+0
173
#cmd
#dodge
#string
substr of env var s %s:~0,5%
174
#latex
#dodge
comment symbol is %
175
#latex
#literals
for % use \%
for £ use \pounds or £
for ÷ use $\div$ (invokes math mode)
for ± use $\pm$
for ~ use \textasciitilde
for degree symbol use $^\circ$
for " " use `` ''
for ` use `
for x hat use \hat{x}
176
#latex
matrix:
\left(
\begin{matrix}
cos \phi & -sin \phi \\
sin \phi & cos \phi
\end{matrix}
\right)
177
#paradox
from Kevin Mitchell
DB - Contains the data records for a table. The header contains
the field names and types and other useful information.
PX - Contains the primary index for a table. If the table is
unkeyed, there is no PX file for the table.
MB - Contains BLOB (Binary Large Object) data. For example, type
M and B fields are blobs and the MB file contains the data for M
and B fields.
X** - Contains a secondary index and has the same basic format as
a DB file.
Y** - Contains the index for a secondary index (X**) And has the
same basic format as a PX file.
178
#sql
#sqlite
#dodge
For JOINs generally no difference between a
constraint expression in the WHERE clause
and one in the ON clause.
However, for a LEFT JOIN or LEFT OUTER JOIN,
the difference is very important.
In a LEFT JOIN, the extra NULL row for the right-hand
table is added after ON clause processing but before
WHERE clause processing.
A constraint of the form "left.x=right.y" in an ON
clause will therefore allow through the added
all-NULL rows of the right table.
But if that same constraint is in the WHERE clause
a NULL in "right.y" will prevent the expression
"left.x=right.y" from being true, and thus exclude
that row from the output.
179
#css
#font
font-weight:
normal
bold
bolder
lighter
100
200
300
400
500
600
700
800
900
180
#sql
SELECT
CASE length('INTEGER')
WHEN 1 THEN 'One'
ELSE 'Longer than 1'
END; -- = 'Longer than 1'
-- or
SELECT
CASE
WHEN length('INTEGER')=1 THEN 'One'
ELSE 'Longer than 1'
END; -- = 'Longer than 1'
181
#sql
get rid of duplicate records
select * from BmdRecords where rowid in (
-- delete from BmdRecords where rowid in (
select max(rowid)
from BmdRecords
group by fileId, event, year, quarter, lower(surname || givenName), districtId, volume, page
having count(*) > 1)
182
#sql
#sqlite
PRAGMA schema.foreign_key_check;
PRAGMA schema.foreign_key_check(table-name);
check the database, or the table called "table-name", for foreign key
constraints that are violated.
PRAGMA foreign_key_list(table-name);
This pragma returns one row for each foreign key constraint created by a
REFERENCES clause in the CREATE TABLE statement of table "table-name".
PRAGMA foreign_keys;
PRAGMA foreign_keys = boolean;
Query, set, or clear the enforcement of foreign key constraints.
183
#sqlite
synthesise date modifiers like so
julianday(censusDate, '-' || ageYears || ' years') AS estYoB,
184
#formgen
#javascript
to use js do
form: "compute" js [compTimes()]
to use remote cgi do
form: "compute" [doForm] get
185
#formgen
#javascript
supported events
onclick
oninput
onchange
186
#formgen
#grammar
<a href="file:///I:/usr/NIK/dev/formgen/doc/formgen.y.dot.png">formgen.y.dot.png</a>
187
#sqlite
#dodge
sensible / rational date format
strftime('%Y-%m-%d %H:%M:%S', DateTimeField)
for timestamp use datetime('now')
188
#css
#html
#dodge
contrast
sasha truebetsky contrasting colours
"#e6194b"
"#3cb44b"
"#ffe119"
"#4363d8"
"#f58231"
"#911eb4"
"#46f0f0"
"#f032e6"
"#bcf60c"
"#fabebe"
"#008080"
"#e6beff"
"#9a6324"
"#fffac8"
"#800000"
"#aaffc3"
"#808000"
"#ffd8b1"
"#000075"
"#808080"
"#000000"
189
#colour
#svg
aliceblue aliceblue rgb(240, 248, 255)
antiquewhite antiquewhite rgb(250, 235, 215)
aqua aqua rgb( 0, 255, 255)
aquamarine aquamarine rgb(127, 255, 212)
azure azure rgb(240, 255, 255)
beige beige rgb(245, 245, 220)
bisque bisque rgb(255, 228, 196)
black black rgb( 0, 0, 0)
blanchedalmond blanchedalmond rgb(255, 235, 205)
blue blue rgb( 0, 0, 255)
blueviolet blueviolet rgb(138, 43, 226)
brown brown rgb(165, 42, 42)
burlywood burlywood rgb(222, 184, 135)
cadetblue cadetblue rgb( 95, 158, 160)
chartreuse chartreuse rgb(127, 255, 0)
chocolate chocolate rgb(210, 105, 30)
coral coral rgb(255, 127, 80)
cornflowerblue cornflowerblue rgb(100, 149, 237)
cornsilk cornsilk rgb(255, 248, 220)
crimson crimson rgb(220, 20, 60)
cyan cyan rgb( 0, 255, 255)
darkblue darkblue rgb( 0, 0, 139)
darkcyan darkcyan rgb( 0, 139, 139)
darkgoldenrod darkgoldenrod rgb(184, 134, 11)
darkgray darkgray rgb(169, 169, 169)
darkgreen darkgreen rgb( 0, 100, 0)
darkgrey darkgrey rgb(169, 169, 169)
darkkhaki darkkhaki rgb(189, 183, 107)
darkmagenta darkmagenta rgb(139, 0, 139)
darkolivegreen darkolivegreen rgb( 85, 107, 47)
darkorange darkorange rgb(255, 140, 0)
darkorchid darkorchid rgb(153, 50, 204)
darkred darkred rgb(139, 0, 0)
darksalmon darksalmon rgb(233, 150, 122)
darkseagreen darkseagreen rgb(143, 188, 143)
darkslateblue darkslateblue rgb( 72, 61, 139)
darkslategray darkslategray rgb( 47, 79, 79)
darkslategrey darkslategrey rgb( 47, 79, 79)
darkturquoise darkturquoise rgb( 0, 206, 209)
darkviolet darkviolet rgb(148, 0, 211)
deeppink deeppink rgb(255, 20, 147)
deepskyblue deepskyblue rgb( 0, 191, 255)
dimgray dimgray rgb(105, 105, 105)
dimgrey dimgrey rgb(105, 105, 105)
dodgerblue dodgerblue rgb( 30, 144, 255)
firebrick firebrick rgb(178, 34, 34)
floralwhite floralwhite rgb(255, 250, 240)
forestgreen forestgreen rgb( 34, 139, 34)
fuchsia fuchsia rgb(255, 0, 255)
gainsboro gainsboro rgb(220, 220, 220)
ghostwhite ghostwhite rgb(248, 248, 255)
gold gold rgb(255, 215, 0)
goldenrod goldenrod rgb(218, 165, 32)
gray gray rgb(128, 128, 128)
grey grey rgb(128, 128, 128)
green green rgb( 0, 128, 0)
greenyellow greenyellow rgb(173, 255, 47)
honeydew honeydew rgb(240, 255, 240)
hotpink hotpink rgb(255, 105, 180)
indianred indianred rgb(205, 92, 92)
indigo indigo rgb( 75, 0, 130)
ivory ivory rgb(255, 255, 240)
khaki khaki rgb(240, 230, 140)
lavender lavender rgb(230, 230, 250)
lavenderblush lavenderblush rgb(255, 240, 245)
lawngreen lawngreen rgb(124, 252, 0)
lemonchiffon lemonchiffon rgb(255, 250, 205)
lightblue lightblue rgb(173, 216, 230)
lightcoral lightcoral rgb(240, 128, 128)
lightcyan lightcyan rgb(224, 255, 255)
lightgoldenrodyellow lightgoldenrodyellow rgb(250, 250, 210)
lightgray lightgray rgb(211, 211, 211)
lightgreen lightgreen rgb(144, 238, 144)
lightgrey lightgrey rgb(211, 211, 211)
lightpink lightpink rgb(255, 182, 193)
lightsalmon lightsalmon rgb(255, 160, 122)
lightseagreen lightseagreen rgb( 32, 178, 170)
lightskyblue lightskyblue rgb(135, 206, 250)
lightslategray lightslategray rgb(119, 136, 153)
lightslategrey lightslategrey rgb(119, 136, 153)
lightsteelblue lightsteelblue rgb(176, 196, 222)
lightyellow lightyellow rgb(255, 255, 224)
lime lime rgb( 0, 255, 0)
limegreen limegreen rgb( 50, 205, 50)
linen linen rgb(250, 240, 230)
magenta magenta rgb(255, 0, 255)
maroon maroon rgb(128, 0, 0)
mediumaquamarine mediumaquamarine rgb(102, 205, 170)
mediumblue mediumblue rgb( 0, 0, 205)
mediumorchid mediumorchid rgb(186, 85, 211)
mediumpurple mediumpurple rgb(147, 112, 219)
mediumseagreen mediumseagreen rgb( 60, 179, 113)
mediumslateblue mediumslateblue rgb(123, 104, 238)
mediumspringgreen mediumspringgreen rgb( 0, 250, 154)
mediumturquoise mediumturquoise rgb( 72, 209, 204)
mediumvioletred mediumvioletred rgb(199, 21, 133)
midnightblue midnightblue rgb( 25, 25, 112)
mintcream mintcream rgb(245, 255, 250)
mistyrose mistyrose rgb(255, 228, 225)
moccasin moccasin rgb(255, 228, 181)
navajowhite navajowhite rgb(255, 222, 173)
navy navy rgb( 0, 0, 128)
oldlace oldlace rgb(253, 245, 230)
olive olive rgb(128, 128, 0)
olivedrab olivedrab rgb(107, 142, 35)
orange orange rgb(255, 165, 0)
orangered orangered rgb(255, 69, 0)
orchid orchid rgb(218, 112, 214)
palegoldenrod palegoldenrod rgb(238, 232, 170)
palegreen palegreen rgb(152, 251, 152)
paleturquoise paleturquoise rgb(175, 238, 238)
palevioletred palevioletred rgb(219, 112, 147)
papayawhip papayawhip rgb(255, 239, 213)
peachpuff peachpuff rgb(255, 218, 185)
peru peru rgb(205, 133, 63)
pink pink rgb(255, 192, 203)
plum plum rgb(221, 160, 221)
powderblue powderblue rgb(176, 224, 230)
purple purple rgb(128, 0, 128)
red red rgb(255, 0, 0)
rosybrown rosybrown rgb(188, 143, 143)
royalblue royalblue rgb( 65, 105, 225)
saddlebrown saddlebrown rgb(139, 69, 19)
salmon salmon rgb(250, 128, 114)
sandybrown sandybrown rgb(244, 164, 96)
seagreen seagreen rgb( 46, 139, 87)
seashell seashell rgb(255, 245, 238)
sienna sienna rgb(160, 82, 45)
silver silver rgb(192, 192, 192)
skyblue skyblue rgb(135, 206, 235)
slateblue slateblue rgb(106, 90, 205)
slategray slategray rgb(112, 128, 144)
slategrey slategrey rgb(112, 128, 144)
snow snow rgb(255, 250, 250)
springgreen springgreen rgb( 0, 255, 127)
steelblue steelblue rgb( 70, 130, 180)
tan tan rgb(210, 180, 140)
teal teal rgb( 0, 128, 128)
thistle thistle rgb(216, 191, 216)
tomato tomato rgb(255, 99, 71)
turquoise turquoise rgb( 64, 224, 208)
violet violet rgb(238, 130, 238)
wheat wheat rgb(245, 222, 179)
white white rgb(255, 255, 255)
whitesmoke whitesmoke rgb(245, 245, 245)
yellow yellow rgb(255, 255, 0)
yellowgreen yellowgreen rgb(154, 205, 50)
190
#grep
#options
-B, --before-context=NUM print NUM lines of leading context
-A, --after-context=NUM print NUM lines of trailing context
-C, --context=NUM print NUM lines of output context
-n, --line-number print line number with output lines
-H, --with-filename print the filename for each match
-h, --no-filename suppress the prefixing filename on output
-c, --count print only a count of matching lines per FILE
191
#sqlite
#sql
update from
-- get fields from subQ into where clause for q update
UPDATE ColumnInfo set cName = subQ.cName
FROM (SELECT manager, shortName, cName FROM ManagerShortName) AS subQ
WHERE subQ.Manager=ColumnInfo.manager
AND subQ.shortName=ColumnInfo.shortName;
-- or sthing like
-- 25JY1894 to rfc
WITH properDates AS(
SELECT rowid,
substr(detail, -4) AS year,
CASE lower(substr(detail, -6, 2))
WHEN 'ja' THEN '01'
WHEN 'fe' THEN '02'
WHEN 'mr' THEN '03'
WHEN 'ap' THEN '04'
WHEN 'my' THEN '05'
WHEN 'je' THEN '06'
WHEN 'jy' THEN '07'
WHEN 'au' THEN '08'
WHEN 'se' THEN '09'
WHEN 'oc' THEN '10'
WHEN 'no' THEN '11'
WHEN 'de' THEN '12'
END AS month,
substr(detail, -8, 2) AS day
FROM BmdRecords
WHERE regexp('[0-9][0-9]*[a-zA-Z]{2}[0-9][0-9][0-9][0-9]', detail)
)
UPDATE BmdRecords SET detail=printf('%d-%s-%02d', properDates.year, properDates.month, properDates.day)
FROM properDates
WHERE BmdRecords.rowid=properDates.rowid;
192
#sqlite
#options
disable -no-utf8 option
-DSHELL_OMIT_WIN_UTF8=1
193
#pandoc
#options
lose smart quotes
-f markdown-smart
194
#dodge
#cmd
#sqlite
smuggle sql from batch file into db
goto main
/* begin */
sql goes here
/* end */
:main
snipfile -once -b "/* begin */" -e "/* end */" %0 > skel.sql
sqlite db skel.sql
del skel.sql
195
#dodge
#sqlite
pragmas can used as follows:
sqlite> pragma foreign_key_list('Unions');
id seq table from to on_update on_delete match
-- --- ------ ---- -- --------- --------- -----
0 0 Person m id NO ACTION NO ACTION NONE
1 0 Person f id NO ACTION NO ACTION NONE
sqlite> select * from pragma_foreign_key_list('Unions');
id seq table from to on_update on_delete match
-- --- ------ ---- -- --------- --------- -----
0 0 Person m id NO ACTION NO ACTION NONE
1 0 Person f id NO ACTION NO ACTION NONE
196
#sqlite
-- sqlite system table is
sqlite_schema;
type|name|tbl_name|rootpage|sql
197
#dodge
#markdown
#pandoc
set a target [here]{#l15}. note ids start with a letter & pandoc enforces this
198
#git
git bundle create sqUtil.bundle --all
then
git clone sqUtil.bundle
199
#image
canvas resize to make square image in dir imgsq:
md imgsq
imgBoxMax.bat file.jpg imgsq
imgsq\file.jpg
shrink image for square thumbnail in dir imgshrink:
md imgshrink
imgFitBox.bat imgsq\file.jpg imgshrink 100 100
imgshrink\file.jpg
200
#grep
-m NUM - at most NUM matches
201
#internet
mimetype
I:\info\mime.types.txt
202
#logic
#set
define set using predicate
p(x) says element x satisfies predicate p
and the set is written {x : p(x)} which says
the set of x such that p(x) is true.
eg even numbers = {x : x mod 2 = 0}
203
#gcc
find dependencies of file
gcc -MM file
204
#sed
#include for sed
address with line no, re or why
r filename
Append text read from filename.
205
#internet
https://search.findmypast.co.uk/record/browse?id=gbc%2f1891%2f0487%2f0289
gets gbc_1891_0487_0289.jpg
206
#sql
create table tbl as select '12/03/1924' AS dt;
select printf('%d-%02d-%02d',
substr(dt, 7, 4),
substr(dt, 4, 2),
substr(dt, 1, 2))
FROM tbl;
207
#knot
alpine knot
1 bight hanging down
2 finger in, 2 turns clockwise
3 fold up so bight above all twists
4 turn 180 deg
5 separate twist away from bight
6 loop downward end of bight through
gap immediately above
7 pull tight
208
#sqlite
mode should be one of:
ascii
box
column
csv
html
insert
json
line
list
markdown
qbox
quote
table
tabs
tcl
209
#cpp
gcc -MM gets non-system dependencies
210
#pandoc
#lua
convert links to footnotes using pandoc plus lua filter
pandoc text.md
-o book.epub \
--lua-filter=filters/linkToFootnote.lua \ # <-- This one
...
212
#pandoc
Extension: inline_notes
Inline footnotes are also allowed (though, unlike regular notes,
they cannot contain multiple paragraphs). The syntax is as follows:
Here is an inline note.^[Inlines notes are easier to write, since
you don't have to pick an identifier and move down to type the
note.]
213
#sqlite
#sql
substr(X,Y,Z)
substr(X,Y)
The substr(X,Y,Z) function returns a substring of input string X
that begins with the Y-th character and which is Z characters long.
If Z is omitted then substr(X,Y) returns all characters through the end
of the string X beginning with the Y-th. The left-most character of X
is number 1.
If Y is negative then the first character of the
substring is found by counting from the right rather than the left.
If Z is negative then the abs(Z) characters preceding the Y-th character
are returned.
If X is a string then characters indices refer to actual
UTF-8 characters. If X is a BLOB then the indices refer to bytes.
SELECT '/*
results
initial string "abcdefghijklmnopqrst" of length ' || length('abcdefghijklmnopqrst'); -- 20
SELECT '3 letters starting with 6th =' || substr('abcdefghijklmnopqrst', 6, 3); -- fgh
SELECT '
2 ways of selecting 3 letters starting 6th from the end';
SELECT substr('abcdefghijklmnopqrst', -6, 3); -- opq
SELECT substr('abcdefghijklmnopqrst', (SELECT length('abcdefghijklmnopqrst')+1-6), 3); -- opq
SELECT '
2 ways of selecting 3 letters preceding 6th';
SELECT substr('abcdefghijklmnopqrst', 6, -3); -- cde
SELECT substr('abcdefghijklmnopqrst', 6-3, 3); -- cde
SELECT '
2 ways of selecting 3 letters preceding 6th from end';
SELECT substr('abcdefghijklmnopqrst', -6, -3); -- lmn
SELECT substr('abcdefghijklmnopqrst', (SELECT length('abcdefghijklmnopqrst')+1-6)-3, 3); -- lmn
SELECT '
created with sqlite3 < substr.sql >> substr.sql
*/';
214
#prolog
?- sub_string("123456789",5,3,A,B).
A = 1,
B = "678"
215
#prolog
leave swipl
halt.
216
#prolog
#grammar
Prolog BNF Grammar
This is a Prolog logic programming language grammar in BNF (Backus-Naur Form).
<program> ::= <clause list> <query> | <query>
<clause list> ::= <clause> | <clause list> <clause>
<clause> ::= <predicate> . | <predicate> :- <predicate list>.
<predicate list> ::= <predicate> | <predicate list> , <predicate>
<predicate> ::= <atom> | <atom> ( <term list> )
<term list> ::= <term> | <term list> , <term>
<term> ::= <numeral> | <atom> | <variable> | <structure>
<structure> ::= <atom> ( <term list> )
<query> ::= ?- <predicate list>.
<atom> ::= <small atom> | ' <string> '
<small atom> ::= <lowercase letter> | <small atom> <character>
<variable> ::= <uppercase letter> | <variable> <character>
<lowercase letter> ::= a | b | c | ... | x | y | z
<uppercase letter> ::= A | B | C | ... | X | Y | Z | _
<numeral> ::= <digit> | <numeral> <digit>
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<character> ::= <lowercase letter> | <uppercase letter> | <digit> | <special>
<special> ::= + | - | * | / | \ | ^ | ~ | : | . | ? | | # | $ | &
<string> ::= <character> | <string> <character>
Source:
By Ivan Sukin on June 9, 2012
http://cdn.bitbucket.org/muspellsson/rosetta/downloads/prolog-bnf.html
217
#sql
#sqlite
select * from sqlite_master;
select * from pragma_foreign_key_list('ElectorPerson');
with recursive cte as (
select
"table",
'ElectorPerson' as path
from pragma_foreign_key_list('ElectorPerson')
union all
select
fk."table",
path || '->' || fk."table" as path
from cte
join pragma_foreign_key_list(cte."table") as fk
where fk."table" <> cte."table"
)
select *
from cte;
with recursive cte as (
select --"table"
'ElectorPerson'
--''
as below,
id,
"from",
"table",
"to"
from pragma_foreign_key_list('ElectorPerson')
--,'electorPerson' as path
union all
select
--cte.below,
fk."table",
fk.id,
fk."from",
fk."table",
fk."to"
from cte,
pragma_foreign_key_list(cte."table") as fk
--where fk."table" <> cte."table"
)
select printf('%s(%s)', below, "from") as child, printf('%s(%s)', "table", "to") as parent
from cte;
218
#sublime
use
sublime.log_commands(True)
in the console to get command names
219
#sublime
context menu defined in
%APPDATA%\Sublime Text 2\Packages\Default\Context.sublime-menu
220
#dodge
#javascript
get coordinates on image
see file:///I:/usr/NIK/dev/UTIL/converge/converge.html
221
#dodge
#sql
title case a string - in this case, in MyTable.Name
id goes along for the ride
WITH RECURSIVE pcase(id, rest, result) AS (
SELECT ID,
Name,
''
FROM MyTable
UNION ALL
SELECT id,
substr(rest, 2),
result || CASE WHEN substr(result, -1) GLOB '[A-Za-z]'
THEN lower(substr(rest, 1, 1))
ELSE upper(substr(rest, 1, 1))
END
FROM pcase
WHERE rest <> ''
)
SELECT id,
result
FROM pcase
WHERE rest = '';
222
#gotcha
#sql
select a from b
except
select c from d
will fail if, for eg, a is TEXT and c is INTEGER
even if contents of all a are digits.
select cast(a as INTEGER) from b
except
select c from d
will work as expected
The Docs: "No affinity transformations are applied to any values when comparing rows as part of a compound SELECT."
sqlite.org/.../lang_select.html
223
#cpp
#dodge
#regex
if (regex_match(path, std::regex ("/thing-[0-9][0-9]*")))
{
return true;
}
224
#cpp
#dodge
#gotcha
_sys_errlist dodgy use strerror
225
#sql
relations between 2 tables
1-1 relation table1.field1 -> table2.*
table1(field1 primary key, ...);
table2(..., fieldN primary key references table1(field1), ...);
select table1.field1, table2.*
from table1
join table2 on table2.fieldN=table1.field1;
is a function, as is its inverse table2.fieldN -> table1.*
select table2.fieldN, table1.*
from table2
join table1 on table1.field1=table2.fieldN;
----------------------------------------------------
1-many relation table1.field1 -> {table2.*}
table1(field1 primary key, ...);
table2(..., fieldN references table1(field1), ... );
select table1.field1, table2.*
from table1
join table2 on table2.fieldN=table1.field1;
is not a function, its inverse table2.fieldN -> table1.* is
select table2.fieldN, table1.*
from table2
join table1 on table1.field1=table2.fieldN;
----------------------------------------------------
many-1 relation {table1.field1} -> table2.fieldN
table1(field1 references table2(fieldN), ...);
table2(..., fieldN primary key, ...);
select table1.field1, table2.*
from table1
join table2 on table2.fieldN=table1.field1;
is a function, its inverse table2.fieldN -> table1.* isn't
select table2.fieldN, table1.*
from table2
join table1 on table1.field1=table2.fieldN;
----------------------------------------------------
many-many relation table1 {table1.*} -> {table2.*}
table1(field1 primary key, ...);
table2(field1 primary key, ...);
t1Xt2(t1id references table1(field1),
t2id references table2(field1)
primary key (t1id, t2id));
select table1.field1, table2.*
from table1
join t1Xt2 on t1Xt2.t1Id=table1.field1
join table2 on t1Xt2.t2id=table2.field1;
isn't a function, nor is
select table2.field1, table1.*
from table2
join t1Xt2 on t1Xt2.t2Id=table2.field1
join table1 on t1Xt2.t1id=table1.field1;
226
#grep
-d, --directories=ACTION how to handle directories;
ACTION is `read', `recurse', or `skip'
doesn't work
227
#dodge
grab screen
ffmpeg -f x11grab -video_size cif -framerate 25 -i :1.0+10,20 ~/out.mpg
228
#vscode
#raspi
settings files at /home/user/.config/Code/User/
229
#linux
#raspi
shred -zu <file>
230
#linux
#raspi
sudo cryptsetup luksOpen file volumeName
sudo mount /dev/mapper/volumeName /mnt/volName
sudo umount /mnt/volName
sudo cryptsetup luksClose volumeName
232
#cpp
#dodge
#std-set
pos = std::string.find(sought, startIndex);
std::string t = s.substr(startpos, howManyChars);
// lower case a string
std::string s;
std::ctype<char> ct;
ct.tolower(&s[0], &s[s.length()]);
OR
std::transform(s.begin(), s.end(), s.begin(), tolower);
std::string::npos
std::string prevLabel ("cn:0009");
prevLabel.erase(prevLabel.find(":"), 1); // "cn0009"
233
#std-string
#cpp
#dodge
pos = std::string.find(sought, startIndex);
std::string t = s.substr(startpos, howManyChars);
// lower case a string
std::string s;
std::ctype<char> ct;
ct.tolower(&s[0], &s[s.length()]);
OR
std::transform(s.begin(), s.end(), s.begin(), tolower);
std::string::npos
replace : try splitstring::subst
std::string prevLabel ("cn:0009");
prevLabel.erase(prevLabel.find(":"), 1); // "cn0009"
234
#argc
#cmd
#dodge
%* in a batch script refers to all the arguments
235
#dodge
#cmd
#argc
%~1 - expands %1 removing any surrounding quotes (")
%~f1 - expands %1 to a fully qualified path name
%~d1 - expands %1 to a drive letter only
%~p1 - expands %1 to a path only
%~n1 - expands %1 to a file name only
%~x1 - expands %1 to a file extension only
%~s1 - expanded path contains short names only
%~a1 - expands %1 to file attributes
%~t1 - expands %1 to date/time of file
%~z1 - expands %1 to size of file
236
#linux
#bash
define function as follows
fname () compound-command [redirection]
function fname [()] compound-command [redirection]
This defines a function named fname. The reserved word function
is optional. If the function reserved word is supplied, the
parentheses are optional. The body of the function is the com‐
pound command compound-command (see Compound Commands above).
That command is usually a list of commands between { and }, but
may be any command listed under Compound Commands above. If the
function reserved word is used, but the parentheses are not sup‐
plied, the braces are recommended. compound-command is executed
whenever fname is specified as the name of a simple command.