Archive for the ‘Scripting’ Category
Posted by jpluimers on 2025/09/10
[Wayback/Archive] What Every Programmer Should Know about How CPUs Work • Matt Godbolt • GOTO 2024 – YouTube
Main takeaways for me:
- CPU pipelines have grown a lot longer than I was aware off
- there are many more internal registers than I was anticipating
- clever ways to convert if statements to non-jumps
--jeroen
Posted in .NET, Assembly Language, C, C#, C++, Delphi, Development, Python, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2025/09/03
I needed the portable version of [Wayback/Archive] CrystalDiskMark on Chocolatey (unlike the [Wayback/Archive] Chocolatey Software | CrystalDiskMark (Install) package). Luckily I found the auto-update package [Wayback/Archive] Chocolatey Software | CrystalDiskInfo (Portable) and knew both that CrystalDiskMark is from the same author as CrystalDiskInfo, and that their code is on GitHub like the Chocolatey package.
Given I had a the below chocolatey-packages/automatic/crystaldiskinfo.portable as a template, I asked the CrystalDiskInfo (Portable) package maintainer if they were willing to maintain CrystalDiskMark (portable) as well and was glad the response was “yes”: [Wayback/Archive] Portabe CrystalDiskMark similar to the current CrystalDiskInfo? · Issue #159 · mkevenaar/chocolatey-packages
So for my link-archive:
Read the rest of this entry »
Posted in .NET, Chocolatey, CommandLine, Development, Lightweight markup language, MarkDown, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Tagged: 159, 16 | Leave a Comment »
Posted by jpluimers on 2025/09/02
For a long time, I have ran with the runelevated.bat in [Wayback/Archive] Run an Elevated command using that: “net file” returns errorlevel 1 when not UAC, and “PowerShell Start-Process” has a “-Verb RunAs“; see the answers at http://stackoverflow.com/questions/7044985/how-can-i-auto-elevate-my-batch-file-so-that-it-requests-from-uac-admin-rights for more information
By now, I would just prepend this oneliner into each batch-file needing elevation:
@pushd "%~dp0" & fltmc | find "." && (powershell start '"%~f0"' ' %*' -verb runas 2>nul && popd && exit /b)
Both the initial batch file and one-liner are from [Wayback/Archive] windows – How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required? – Stack Overflow (thanks [Wayback/Archive] Ir Relevant, [Wayback/Archive] ceztko, [Wayback/Archive] Jamesfo, and [Wayback/Archive] PDixon724)
Note that the net file trick below should actually be repeated twice. This is explained in [Wayback/Archive] windows – Batch script: how to check for admin rights – Stack Overflow (thanks [Wayback/Archive] zumalifeguard), but wait: there is even a better solution!
The fltmc trick above works much better than the net file trick and is available from Windows XP and up, see [Wayback/Archive] windows – Batch script: how to check for admin rights – Stack Overflow (thanks [Wayback/Archive] npocmaka).
Oh: on systems where I have full installation control, I always install gsudo, see gsudo (sudo for windows).
–jeroen
Read the rest of this entry »
Posted in .NET, Batch-Files, CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2025/08/20
With the constant influx of JavaScript programmers, it keeps worth repeating that you should always run JavaScript in strict mode via "use strict"; (like in the past Visual Basic 6 developers should use option strict and option explicit) to forget risky JavaScript syntax like implicit ocal constants (which were removed from the documentation in the 2009 ECMAScript 5 specification for JavaScript), and every codeline should have a test code covering it, especially for comparisons involving non-strict behaviour like the use of leading zeros.
As of the succeeding 2015 standard (ECMAScript 6), octal numbers in JavaScript start with 0o or 0O followed by a series of octal digits.
Oh, and the history of octal in computing of course has to do with 6-bit systems and also lead to 6-six bit character codes including BCD character encoding..
My tweet back earlier this year: [WaybackSave/Archive] Jeroen Wiert Pluimers @wiert@mastodon.social on X: “@_ObomheseR Since JavaScript is in the group of curly based programming languages influenced by the B programming language, integer constants starting with zero are tried first in octal base. 017 octal is 15 decimal 018 octal is not possible, so becomes 18.”
Inhteritence:
Read the rest of this entry »
Posted in B, BASIC, C, Development, JavaScript/ECMAScript, MarkDown, Retrocomputing, Scripting, Software Development, VB6, Visual BASIC | Leave a Comment »
Posted by jpluimers on 2025/08/12
Posted in .NET, Batch-Files, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows, Windows 10, Windows 11, Windows 8.1 | Leave a Comment »
Posted by jpluimers on 2025/08/06
Sometimes I need [Wayback/Archive] Redirect Checker | Check your Statuscode 301 vs 302 on the command-line, so cURL to the rescue: [Wayback/Archive] linux – Get final URL after curl is redirected – Stack Overflow. The relevant portions of answers and comments further below.
TL;DR:
Since I prefer verbose command-line arguments (you can find them at the [Wayback/Archive] curl – How To Use on-line man page) especially in scripts this HTTP GET request is what works with Twitter:
% curl --location --silent --output /dev/null --write-out "%{url_effective}\n" https://twitter.com/anyuser/status/20
https://x.com/anyuser/status/20
This failed (twitter dislikes HTTP HEAD requests):
% curl --head --location --silent --output /dev/null --write-out "%{url_effective}\n" https://twitter.com/anyuser/status/20
https://twitter.com/anyuser/status/20
Notes
Given so many of my scripts now run on zsh, I added the new-line because of command line – Why does a cURL request return a percent sign (%) with every request in ZSH? – Stack Overflow. You can strip that bit.
Note that these do not perform client side redirects, so they do not return the ultimate originating URL https://x.com/jack/status/20 (which was the first ever Tweet on what was back then called twttr) as Twitter on the client-side overwrites window.location.href with the final URL. Similar behaviour for getting the Twitter user handle of a Twitter user ID, more on Twitter tricks below.
Tweet by TweetID trick via [Wayback/Archive] Accessing a tweet using only its ID (and without the Twitter API) – Bram.us.
Further reading (thanks [Wayback/Archive] vise, [Wayback/Archive] Daniel Stenberg, [Wayback/Archive] Ivan, [Wayback/Archive] AndrewF, [Wayback/Archive] Roger Campanera, and [Wayback/Archive] Dave Baird):
Read the rest of this entry »
Posted in *nix, *nix-tools, bash, Batch-Files, Bookmarklet, Communications Development, Conference Topics, Conferences, CSS, cURL, Development, Event, HTTP, Internet protocol suite, JavaScript/ECMAScript, Power User, Scripting, SocialMedia, Software Development, TCP, Twitter, Web Browsers, Web Development | Tagged: 76 | Leave a Comment »
Posted by jpluimers on 2025/08/01
A few notes after I helped updating [Wayback/Archive] Chocolatey Software | SetACL (Portable) 3.0.6.0 to version 3.1.2.0 and [Wayback/Archive] Updates glab from 1.22.0 to 1.24.1; fixes #2 by jpluimers · Pull Request #3 · corbob/ChocoPackages.
As the burden on maintainers (not just Chocolatey ones) is high, not all packages get updated soon after new underlying software versions arrive.
Which means the maintainers are often very happy when an occasional user helps and preferably sends in a pull request.
That brings me to the an important point IN DOCUMENTATION DO NOT LIMIT EXAMPELS TO ONLY ABBREVIATED PARAMETERS OR VERBS as that scares away occasional and novice users of your software.
Chocolatey documentation is no exception on this, hence this blog post meant for people other than maintaining chocolatey packages on a day to day base.
Read the rest of this entry »
Posted in CertUtil, Chocolatey, CommandLine, Conference Topics, Conferences, Development, Event, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Tagged: 2, 2850, 3, 309, 561 | Leave a Comment »
Posted by jpluimers on 2025/07/31
I try to stay on the default shells of environments as much as possible, especially as that makes life easier when needing to work on an non-customised system.
Apple switched back from an ancient latest GPLv2 version 3.2 of bash (they regard newer GPLv3 as toxic to their revenue stream¹), introduced MIT-license based zsh and introduced a bash nag screen a few years ago forcing users to switch. Suppressing that message reliably is trickier than you might think².
After so many years of bash, I still stumble over things that zsh does differently: [Wayback/Archive] command line – Why does a cURL request return a percent sign (%) with every request in ZSH? – Stack Overflow (thanks [Wayback/Archive] Travis and [Wayback/Archive] zaTricky) is a “feature” with a simple workaround for cURL:
This is a zsh feature that prints a percent-and-newline after a command completes if that command does not already include a newline at the end of its output. If zsh did not do this, you would either not ever notice the fact that the command didn’t print a newline – or you’d see zsh’s command prompt not start on the margin and think it was a bug in zsh.
…
$ curl http://api.macvendors.com/0015c7
Cisco Systems, Inc%
$ curl -w '\n' http://api.macvendors.com/0015c7
Cisco Systems, Inc
…
Since the above example now writes a redirect messages (good bye HTTP, welcome HTTPS), and I very much dislike short command-line parameters, here is version with the long form of the [Wayback/Archive] curl -w or --write-out parameter :
Read the rest of this entry »
Posted in *nix, *nix-tools, Apple, bash, bash, Development, Mac OS X / OS X / MacOS, macOS 14 Sonoma, macOS 15 Sequoia, Power User, Scripting, Software Development, zsh | Leave a Comment »
Posted by jpluimers on 2025/07/31
For my link archive [Wayback/Archive] Out of Control. An essay on paradigms, refactoring… | by Kevlin Henney | Dec, 2020 | Medium.
Neither because Kevlin describes how to refactor a basic algorithm to convert Roman numerals into Hindu-Arabic numerals (in part by using the fact that an if statement can be considered a bounded case of a while loop), nor because he splits the resulting algorithm in coded data and coded statements, or because he mentions the [Wayback/Archive] Gilded Rose Kata but because well, you should just read it in full.
Remember though: Read the rest of this entry »
Posted in Configuration Management, Development, DevOps, Power User, Python, Scripting, Software Development | Leave a Comment »