Stumbled across something that goes well with jq (the sed for JSON of which I wrote about before), [Wayback/Archive] Jan-Piet Mens :: A shell command to create JSON: jo:
Archive for the ‘Scripting’ Category
Jan-Piet Mens :: A shell command to create JSON: jo
Posted by jpluimers on 2023/08/30
Posted in Development, JavaScript/ECMAScript, jo, jq, JSON, Scripting, Software Development | Leave a Comment »
.NET/C#: Small command-line tool to query REST JSON results from a batch file.
Posted by jpluimers on 2023/08/29
Often the power is in the combinations of tools.
Read until the epilogue…
Prologue
In this case, I needed to be able to query the JSON results of calls to REST services from the command-line so I could process them in Batch files.
Since I could not find anything readily available, I originally Originally I opted for theΒ PowerShell command-line scripting tool, as that ships with recent Windows versions and can re-use anything that .NET brings. But though [Wayback/Archive] .NET has built in JSON serialization support, there is [Wayback/Archive] no querying support in it.
Then I thought about Delphi, as it [Wayback/Archive] too has a built-in JSON parser, but even the well known [Wayback/Archive] JSON SuperObject library has no query support.
Back to .NET, which – like Delphi – has a well known and respected third party JSON library as well: [Wayback/Archive] NewtonSoft JSON aka JSON.netΒ and that one [Wayback/Archive] does have support for querying JSON with the SelectToken function.
That’s the fundament of the rest of this article, with the potential to be used in a cross-platform as well.
So no need for a plan B.
Posted in *nix, *nix-tools, .NET, Batch-Files, Conference Topics, Conferences, Development, Event, JavaScript/ECMAScript, jq, JSON, Power User, Scripting, Software Development, Windows, Windows Development | Leave a Comment »
Bruce Tate on Twitter: “What’s the most unique feature of your favorite programming language?”
Posted by jpluimers on 2023/08/24
For my link archive: [Wayback/Archive] Bruce Tate on Twitter: “What’s the most unique feature of your favorite programming language?” / Twitter
From the languages that I have been using most:
- [Wayback/Archive] Jeroen Wiert Pluimers on Twitter: “@redrapids Delphi having had virtual constructors since version 1. Wrote a blog post only years after it was introduced as too few developers (still!) realise the power of it: …” / Twitter
- [Wayback/Archive] Marco Wobben on Twitter: “@redrapids @jpluimers Perhaps not terribly unique, but definitely my favorite: Strong typing in Delphi/Pascal.” / Twitter
- [Archive] Jeroen Wiert Pluimers on Twitter: “@redrapids C#: extension methods on interfaces. Without this, things like LINQ would have been impossible. ” / Twitter
- [Wayback/Archive] c# – Can extension methods be applied to interfaces? – Stack Overflow (thanks [Wayback/Archive] Greg and [Wayback/Archive] Aaronaught):
Of course they can; most of Linq is built around interface extension methods.Interfaces were actually one of the driving forces for the development of extension methods; since they can’t implement any of their own functionality, extension methods are the easiest way of associating actual code with interface definitions.See theΒ EnumerableΒ class for a whole collection of extension methods built aroundΒIEnumerable<T>. To implement one, it’s the same as implementing one for a class
- [Wayback/Archive] c# – Can extension methods be applied to interfaces? – Stack Overflow (thanks [Wayback/Archive] Greg and [Wayback/Archive] Aaronaught):
It was a kind of follow-up on his earlier tweet that also sparked nice responses at [Archive] Bruce Tate on Twitter: “What is a #programming technique or construct that other people like but you think is overused?” / Twitter.
In my respons I phrased my decades long pet peeve [Archive] Jeroen Wiert Pluimers on Twitter: “@redrapids OOP: inheritance over composition. This leads to deep hierarchies that eventually nobody understands.” / Twitter.
Whereas with OOP (object-oriented programming) one should use composition over inheritance, often the reverse is true.
Actually my take can be generalised into two directions as these hierarchies:
- often crowd a single namespace, so: crowding namespaces is bad.
One does see this outside the Object Oriented realm a well.
JavaScript for instance takes the crowded global namespace one step further by many libraries taking
$q,$_or$x, which is part of my take[Wayback/Archive] Jeroen Wiert Pluimers on Twitter: “@redrapids Mutation of global state followed by an overly crowded global namespace. Example on the JavaScript side: too many libraries and projects using the global `$` and `_` symbols.”.
- often have many levels of indirection, so: overdoing indirection is bad
One does see this outside the Object Oriented realm a well, just not as pronounced.
[Wayback/Archive] joao on Twitter: “@redrapids But to be more specific, I think sometimes there’s too much indirection with very deep class hierarchies. In the same vein those rules of “functions should have at most 6 arguments and 5/10/20 lines” can lead to a ton of indirection chasing the subfunctions being called”.
–jeroen
Posted in .NET, C#, Conference Topics, Conferences, Delphi, Development, Event, JavaScript/ECMAScript, Pascal, Scripting, Software Development | Leave a Comment »
Bookmarklet to save a page both in the WayBack machine and Archive.is (ending on the latter to solve a reCAPTCHA)
Posted by jpluimers on 2023/08/22
TL;DR:
javascript:{h=location.href;open('https://archive.is/?run=1&url='+encodeURIComponent(h));location.href='https://web.archive.org/save/'+(h)}
Posted in Bookmarklet, Development, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers, Web Development | Leave a Comment »
Figuring out the threads for processes ran by python
Posted by jpluimers on 2023/08/17
A while ago I wrote about Figuring out the open network connections for processes ran by python, which explained the TL;DR:
pidof python | tr " " "\n" | xargs -r -n 1 lsof -i -a -e /run/user/1001/gvfs -p
Now I needed thread information as well, so below two examples using ps and pstree. I won’t explain the pidof and xargs stuff here as that was already covered in the above blog-post and I found out that ps already has a built-in way to filter on process name.
The ps solution uses the H, -L or -T argument to show the threads:
Posted in *nix, *nix-tools, bash, Development, lsof, Power User, ps, Scripting, Software Development | Leave a Comment »
Bookmarklet for Archive.is to navigate to the canonical link
Posted by jpluimers on 2023/08/15
This is a follow-up to Bookmarklets for Archive.is and the WayBack Machine to go to the original page.
Archive.is has two kinds of URLs:
- The encoded version is the short form without any meta-information,
- for example archive.is/jnp53
- The canonical version is a long form and has metadata about Archive date and time, and the Archived URL,
- for example 2022.02.22-215053/https://www.cloudflare.com/ips/
- and archive.today/20220222215053/https://www.cloudflare.com/ips/ (which redirects to the non-functioning https://archive.li/20220222215053/https://www.cloudflare.com/ips/)
- and https://archive.is/20220222215053/https://www.cloudflare.com/ips/
You get the first URL both after archiving and when browsing from an archived page to another archived page (if it is not archived you will go the unarchived full page URL).
Posted in archive.is / archive.today, Development, Internet, InternetArchive, JavaScript/ECMAScript, Power User, Scripting, Software Development, WayBack machine | Leave a Comment »
Gradual Hedy programming language supports many numerals: easier for people not using English or not using Latin based alphabets
Posted by jpluimers on 2023/08/10
Yesterday, I wrote about Learn to program the gradual way: Welcome to Hedy! and today is the next installment: about numerals.
[Archive] /Fay-lee-nuh/ (@Felienne) | TwitterΒ kind of by surprise discovered that the ten numerical digits of the decimal numeral system used in virtually all programming languages are not the original Arabic forms.
Supporting other forms of decimal numerals will help learning to program when your background is non-English or even using ten systems outside the Arabic numeral realm so common in Latin alphabets. And they are a fun learning exercise for every body too!
Some of the related Tweets on this:
- [Archive]Β /Fay-lee-nuh/ on Twitter: “You know those things 0 to 9 that we call Arabic numerals?! The actual Arabic language uses different ones* But of course, we support that now too!!! * Fun fact I did not know until embarrassingly recently…”
- [Archive] Hedy on Twitter: “Turns out different languages not only have different words and letters but also…. numbers!! So to make sure Hedy works really well for all languages we need to do a “bit” of work! …”
- [Archive] Hedy on Twitter: “Can’t believe how little I knew about other languages and cultures before all this!”
- [Archive] Hedy on Twitter: “Tadaaaaaa! …”
- [Archive] Hedy on Twitter: “Turns out different languages not only have different words and letters but also…. numbers!! So to make sure Hedy works really well for all languages we need to do a “bit” of work! …”
- [Archive] Peter Bindels πππβ³ on Twitter: “@Felienne Unicode actually has like 62 different numbering systems that use some form of a 0-9 symbol. And about 5 that use a non-0-9 system of counting.” (spoiler: Felienne knows)
- [Archive] Jeroen Wiert Pluimers on Twitter: “@dascandy42 @Felienne Looking for numer and number in … shows a few categories that I think are now missing from .. (which is already a huge leap forward)” / Twitter (this blog post has some notes so I might be able to create a pull request later)
Some more related Wikipedia links:
- Numeral – Wikipedia
- Numeral system – Wikipedia
- Numeral (linguistics) – Wikipedia
- Numerical digit – Wikipedia
- Decimal – Wikipedia
- Arabic numerals – Wikipedia
- Spread of the Latin script – Wikipedia
- Numerals in Unicode – Wikipedia
- List of Unicode characters – Wikipedia
- Unicode block – Wikipedia
- Number Forms – Wikipedia
- Enclosed Alphanumerics – Wikipedia
- Common Indic Number Forms – Wikipedia
- Aegean Numbers (Unicode block) – Wikipedia
- Ancient Greek Numbers (Unicode block) – Wikipedia
- Coptic Epact Numbers – Wikipedia
- Rumi Numeral Symbols – Wikipedia
- Sinhala Archaic Numbers – Wikipedia
- Cuneiform Numbers and Punctuation – Wikipedia
- Mayan Numerals (Unicode block) – Wikipedia
- Counting Rod Numerals (Unicode block) – Wikipedia
- Mathematical Alphanumeric Symbols – Wikipedia
- Indic Siyaq Numbers (Unicode block) – Wikipedia
- Ottoman Siyaq Numbers (Unicode block) – Wikipedia
- Enclosed Alphanumeric Supplement – Wikipedia
- Number Forms – Wikipedia
- Mathematical Alphanumeric Symbols – Wikipedia
- Unicode – Wikipedia
In the Unicode pages, look for “numeral”, “number”, and “numeric” (or just for “num”).
–jeroen
Posted in Development, Hedy, Learning/Teaching, LifeHacker, Power User, Scripting, Software Development | Leave a Comment »







