Archive for July, 2021
Posted by jpluimers on 2021/07/19
[WayBack] windows – Is there any sed like utility for cmd.exe? – Stack Overflow
TL;DR: many people suggest to use PowerShell, but there is GNU sed in Chocolatey
The chocolatey part:
The PowerShell part: read the other answers from the above question.
–jeroen
Posted in *nix, *nix-tools, CommandLine, Power User, PowerShell, RegEx, sed, Windows | Leave a Comment »
Posted by jpluimers on 2021/07/16
This tool can help resetting monitor/display configurations for when your machines gets out of suspend/sleep/shutdown mode and resets the displays to wrong defaults (especially wrong scaling).
Documentation and download: [WayBack] Custom Resolution Utility (CRU)
Custom Resolution Utility (CRU) allows custom resolutions to be defined for both AMD/ATI and NVIDIA GPUs by creating EDID overrides directly in the registry without dealing with .inf files. Download:
Note the requirements:
- Windows Vista or later (Windows XP does not support EDID overrides)
- AMD/ATI or NVIDIA GPU with appropriate driver installed (Microsoft Basic Display Adapter driver does not support EDID overrides)
- Some Intel GPUs and laptops with switchable graphics are supported with one of these drivers:
Old version at [WayBack] GitHub – radamar/Custom-Resolution-Utility-ToastyX: Custom Resolution Utility for Windows by ToastyX, duplicated so the source won’t be lost..
Short instructions (but be sure to read the long ones above as well) slightly rephrased for readability:
- For each monitor
- Disable all of the default “Established Resolutions”
- Delete all of the default “Detailed Resolutions”
- Delete all of the default “Standard Resolutions”
- Add a new “Detailed Resolution”
- Under new “Detailed Resolution” I left all of the settings the same except for the active horizontal and vertical pixel dimensions, which is obviously where you set your desired screen resolution.
- Once all monitors are configured properly, close CRU and run the restart.exe or restart64.exe included with CRU and you should be good to go!
Read the rest of this entry »
Posted in Power User, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Vista | Leave a Comment »
Posted by jpluimers on 2021/07/16
Everyone can learn from an outage. CloudFlare shows how to do it right, for instance on the RegEx-going-wild downtime 2 years ago.
So it’s time to link to that one again: [WayBack] Details of the Cloudflare outage on July 2, 2019
More like these at [WayBack] Post Mortem – The Cloudflare Blog.
More on evaluating regular expressions in linear time:
- [WayBack] Regular Expression Search Algorithm KEN THOMPSON Bell Telephone Laboratories, Inc., Murray Hill, New Jersey
- [WayBack] Programming Techniques: Regular expression search algorithm / [WayBack] Programming Techniques: Regular expression search algorithm
A method for locating specific character strings embedded in character text is described and an implementation of this method in the form of a compiler is discussed. The compiler accepts a regular expression as source language and produces an IBM 7094 program as object language. The object program then accepts the text to be searched as input and produces a signal every time an embedded string in the text matches the given regular expression. Examples, problems, and solutions are also presented.
Programming Techniques: Regular expression search algorithm
| Full Text: |
PDF |
| Author: |
Ken Thompson |
Bell Telphone Labs, Inc., Murray Hill |
Published in:
 |
|
| · Magazine |
| Communications of the ACM CACM Homepage archive |
Volume 11 Issue 6, June 1968
Pages 419-422
ACM New York, NY, USA
table of contents doi>10.1145/363347.363387 |
|
|
- Thompson’s construction – Wikipedia
is a method of transforming a regular expression into an equivalent nondeterministic finite automaton (NFA)
The algorithm works recursively by splitting an expression into its constituent subexpressions, from which the NFA will be constructed using a set of rules.[3] More precisely, from a regular expression E, the obtained automaton A with the transition function δ respects the following properties:
- A has exactly one initial state q0, which is not accessible from any other state. That is, for any state q and any letter a, {\displaystyle \delta (q,a)}
does not contain q0.
- A has exactly one final state qf, which is not co-accessible from any other state. That is, for any letter a, {\displaystyle \delta (q_{f},a)=\emptyset }
.
- Let c be the number of concatenation of the regular expression E and let s be the number of symbols apart from parentheses — that is, |, *, a and ε. Then, the number of states of A is 2s − c (linear in the size of E).
- The number of transitions leaving any state is at most two.
- Since an NFA of m states and at most e transitions from each state can match a string of length n in time O(emn), a Thompson NFA can do pattern matching in linear time, assuming a fixed-size alphabet.
- [WayBack] A Regular Expression Matcher Code by Rob Pike Exegesis by Brian Kernighan
Via [WayBack] Details of the Cloudflare outage on July 2, 2019 | Hacker News
–jeroen
Posted in Algorithms, Development, Power User, RegEx, Software Development | Leave a Comment »
Posted by jpluimers on 2021/07/16
At last, somewhere around ESXi 6.7, the built-in BusyBox tool wget started to support the https protocol.
Yay!
Which means that workarounds in these answers are not needed any more:
It was a big BusyBox version bump (from 1.22.x to 1.29.x) between ESXI 6.5 and 6.7, especially since 1.26.x versions (that introduced wget) have been available way before ESXi 6.5 came out: [WayBack] BusyBox.
From an ESXi 6.5U2 host
[root@ESXi-X10SRH-CF:/tmp] wget https://www.example.org
wget: not an http or ftp url: https://www.example.org
[root@ESXi-X10SRH-CF:/tmp] wget --help
BusyBox v1.22.1 (2018-07-23 19:34:04 PDT) multi-call binary.
Usage: wget [-csq] [-O FILE] [-Y on/off] [-P DIR] [-U AGENT] URL...
Retrieve files via HTTP or FTP
-s Spider mode - only check file existence
-c Continue retrieval of aborted transfer
-q Quiet
-P DIR Save to DIR (default .)
-O FILE Save to FILE ('-' for stdout)
-U STR Use STR for User-Agent header
-Y Use proxy ('on' or 'off')
[root@ESXi-X10SRH-CF:/tmp] vmware -l
VMware ESXi 6.5.0 Update 2
From an ESXi 6.7U2 host
[root@ESXi-X9SRI-3F:/tmp] wget https://www.example.org
Connecting to www.example.org (93.184.216.34:443)
index.html 100% |******************************************************************************************| 1270 0:00:00 ETA
[root@ESXi-X9SRI-3F:/tmp] wget --help
BusyBox v1.29.3 (2018-11-02 15:37:50 PDT) multi-call binary.
Usage: wget [-c|--continue] [--spider] [-q|--quiet] [-O|--output-document FILE]
[--header 'header: value'] [-Y|--proxy on/off] [-P DIR]
[-S|--server-response] [-U|--user-agent AGENT] URL...
Retrieve files via HTTP or FTP
--spider Only check URL existence: $? is 0 if exists
-c Continue retrieval of aborted transfer
-q Quiet
-P DIR Save to DIR (default .)
-S Show server response
-O FILE Save to FILE ('-' for stdout)
-U STR Use STR for User-Agent header
-Y on/off Use proxy
[root@ESXi-X9SRI-3F:/tmp] vmware -l
VMware ESXi 6.7.0 Update 2
–jeroen
Posted in ESXi6.5, ESXi6.7, Power User, Virtualization, VMware, VMware ESXi | Leave a Comment »
Posted by jpluimers on 2021/07/15
For my link archive: [WayBack] c# – Algorithm to check whether a certain hour falls into a given time period – Stack Overflow answered by [WayBack] kennytm:
Assume you only have the time and not the date.
if end_time >= start_time:
return start_time <= current_time <= end_time
else:
return start_time <= current_time or current_time <= end_time
I totally agree with this comment:
– [WayBack]
I love it when algorithms are simple and elegant.
It reminded me of another scheduling related algorithm: [WayBack] Activity Selection Problem | Greedy Algo-1 – GeeksforGeeks
–jeroen
Posted in .NET, Algorithms, C#, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/07/15
[WayBack] How do I get the application exit code from a Windows command line? – Stack Overflow solutions below.
Note they ONLY work when nobody sets the ERRORLEVEL environment variable.
- – [WayBack]
-
something.exe
echo Exit Code is %errorlevel%
– [WayBack] Samuel Renkert
-
start /wait something.exe
echo %errorlevel%
– [WayBack] Gary
-
@echo off
my_nify_exe.exe
if %ERRORLEVEL% EQU 0 (
echo Success
) else (
echo Failure Reason Given is %errorlevel%
exit /b %errorlevel%
)
– [WayBack] Curtis Yallop
- It’s worth noting that .BAT and .CMD files operate differently.Reading https://ss64.com/nt/errorlevel.html it notes the following:
There is a key difference between the way .CMD and .BAT batch files set errorlevels:
An old .BAT batch script running the ‘new’ internal commands: APPEND, ASSOC, PATH, PROMPT, FTYPE and SET will only set ERRORLEVEL if an error occurs. So if you have two commands in the batch script and the first fails, the ERRORLEVEL will remain set even after the second command succeeds.
This can make debugging a problem BAT script more difficult, a CMD batch script is more consistent and will set ERRORLEVEL after every command that you run .
This was causing me no end of grief as I was executing successive commands, but the ERRORLEVEL would remain unchanged even in the event of a failure. – [WayBack] RockDoctor
–jeroen
Posted in Batch-Files, Development, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2021/07/15
Vandaag 25 jaar geleden alweer was de Herculesramp.
Elk jaar wat tranen voor René Hendriksen, waar ik samen mee gespeeld heb bij het muziekkorps Adest Musica en die na de ramp ineens weg viel bij evenementenorkest De Straatklinkers.
Er zijn natuurlijk nog veel meer slachtoffers te herdenken (een lijst staat op [Archive.is] Defensie maakt namen bekend van slachtoffers vliegramp | Trouw), en natuurlijk gaan ook gedachten uit naar naasten en degenen die het wel overleefd hebben (zoals [Wayback] Nicole Adams – Studio040 interview): zij ondervinden nog steeds een grote invloed op hun leven.
In 2011 werd de 15 jarige herdenking van de Herculesramp omlijst met het nummer Hymn to the Fallen tijdens de Nationale Taptoe 2011 in Ahoy (citaat van deze YouTube opname staat onderaan).
Het nummer komt uit de film Saving Private Ryan, en is geschreven door John Williams als eerbetoon aan alle gevallen militairen.
Sinds het in 2007 in het repertoire van Adest Musica kwam, hebben we het talloze malen gespeeld, uiteraard op 4 mei tijdens de nationale herdenking in Sassenheim, en ook op diverse uitvaarten van leden van Adest Musica.
Zowel het nummer als René hebben voor altijd een speciaal plaatsje in mijn hart.
Read the rest of this entry »
Posted in About, Adest Musica, FoodForThought, Personal | Leave a Comment »
Posted by jpluimers on 2021/07/15
Officially, the answer to [WayBack] inheritance – Delphi: How to call inherited inherited ancestor? – Stack Overflow is that you can’t on the language level as I explained in my answer
You can’t in a regular language way, as this would break the object oriented aspects of the language.
You can fiddle around with pointers and clever casts to do this, but before even starting to answer that: is this really what you want?
As others mentioned: your need sounds like a serious “design smell” (which is similar to code smell, but more severe.
Edit:
Going down the pointer fiddling road might save you work in the short term, and cost you weeks of work in the long term.
This makes for some good reading on that: Upstream decisions, downstream costs.
If you really want, then there is a clever hack around this by [WayBack] User kludg – Stack Overflow.
His hack is centered around understanding what what the [WayBack] System.TMethod Record essentially is:
Read the rest of this entry »
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »
Posted by jpluimers on 2021/07/14
You can use:
IF "%~1" == "" GOTO MyLabel
to strip the outer set of quotes. In general, this is a more reliable method than using square brackets because it will work even if the variable has spaces in it.
Source: [WayBack] jamesdlin answering on [WayBack] windows – What is the proper way to test if a parameter is empty in a batch file? – Stack Overflow
The tilde (~) strips out double quotes from the command as per
C:\>help for | findstr "~"
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
%~ftzaI - expands %I to a DIR like output line
values. The %~ syntax is terminated by a valid FOR variable name.
–jeroen
Posted in Batch-Files, Development, Power User, Scripting, Software Development, Windows | Leave a Comment »
Posted by jpluimers on 2021/07/14
On my research list: find out what is the cause of the difference below (Windows batch and Linux behave the same; just the quotes around the echo is different):
Windows statements:
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org:8080 | sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^: ]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org:8080| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^: ]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org | sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^: ]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^: ]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo failure with [:\s]*?
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org:8080 | sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^:\s]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org:8080| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^:\s]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org | sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^:\s]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^:\s]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
Linux statements:
echo "cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org:8080 "| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^: ]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo "cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org:8080"| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^: ]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo "cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org "| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^: ]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo "cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org"| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^: ]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo failure with [:\s]*?
echo "cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org:8080 "| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^:\s]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo "cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org:8080"| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^:\s]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo "cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org "| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^:\s]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
echo "cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org"| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^:\s]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
Output:
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org:8080 | sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^: ]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
https://plastic.example.org/webui/repos/MyRepository/diff/changeset/2648
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org:8080| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^: ]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
https://plastic.example.org/webui/repos/MyRepository/diff/changeset/2648
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org | sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^: ]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
https://plastic.example.org/webui/repos/MyRepository/diff/changeset/2648
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^: ]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
https://plastic.example.org/webui/repos/MyRepository/diff/changeset/2648
echo failure with [:\s]*?
failure with [:\s]*?
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org:8080 | sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^:\s]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
https://pla/webui/repos/MyRepository/diff/changeset/2648
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org:8080| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^:\s]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
https://pla/webui/repos/MyRepository/diff/changeset/2648
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org | sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^:\s]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
https://pla/webui/repos/MyRepository/diff/changeset/2648
echo cs:2648@rep:MyRepository@repserver:ssl://plastic.example.org| sed -E -r -n "s/^cs:(.*?)@rep:(.*?)@repserver:([a-zA-Z][a-zA-Z+.-]*?):\/\/(\w[^:\s]*?)(:\d*)?.*$/https:\/\/\4\/webui\/repos\/\2\/diff\/changeset\/\1/p"
https://pla/webui/repos/MyRepository/diff/changeset/2648
Related:
–jeroen
Read the rest of this entry »
Posted in Uncategorized | 1 Comment »