The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

    • RT @samgerrits: Caroline en asielzoekers, een tweeluik. Links: dwepen met een speldje gekregen van een Iraanse asielzoeker, rechts: nou ja… 4 hours ago
    • RT @delphijunkie: Yeah, nah. I'm good thanks Twitter. https://t.co/eTMPUoeSEa 4 hours ago
    • RT @d_feldman: Microsoft: We have world class AI research Google: We have world class AI research Meta: We’re one or two steps behind in AI… 4 hours ago
    • RT @SchipholWatch: Op dit moment is kerosine zo’n tien keer goedkoper dan alternatieve synthetische brandstof. De overheid moet dit prijsve… 4 hours ago
    • RT @jasongorman: One aspect of LLMs many folks overlook is the energy cost of training one. GPT-3 used an ~936 MWh and training it took 102… 4 hours ago
  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,178 other subscribers

Archive for July 15th, 2021

c# – Algorithm to check whether a certain hour falls into a given time period – Stack Overflow

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:

This is brilliant! Thanks a lot. – Martin Dimitrov [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 »

How do I get the application exit code from a Windows command line? – Stack Overflow

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.

  • You can quickly see what app returns: app.exe & echo %errorlevel% – [WayBack] marbel82
  • 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. – [WayBackRockDoctor

–jeroen

Posted in Batch-Files, Development, Scripting, Software Development | Leave a Comment »

Een moment van herdenking: 25 jaar na de Herculesramp.

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 »

inheritance – Delphi: How to call inherited inherited ancestor? – Stack Overflow

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 understaning what what the [WayBack] System.TMethod Record essentially is:

TMethod = record
  Code: Pointer;
  Data: Pointer;
end;

The TMethod stores the Code and Data pointers for a method. This type can be used in a type cast of a method pointer to access the code and data parts of the method pointer.

You can also furnish a TMethod variable by assigning Data a pointer to an object, and assigning Code using MethodAddress, specifying the method name as a string parameter to that method.

So if you have a Method variable of the procedure of object type, then you can set the Code part to reference the ancestor method, and the Data part to Self and call the correct method.

It is important to resalise that this still is a hack, which hides the “design smell” you are trying to solve.

W warming is in place:

Even after applying the hack, your design still smells, and will likely continue to rotten further until a moment some essential flesh in your design and the bones of your design start to collapse.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

 
%d bloggers like this: