The Wiert Corner – irregular stream of stuff

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

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

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

    Join 2,119 other followers

Current state: still fighting the metastases of the rectum cancer; chemos are done, major liver surgery in about 3 weeks

Posted by jpluimers on 2020/08/23

A long follow-up of Current state: still fighting with rectum cancer, but chances for better quality of life which does not even include everything, because so much happened.

So this is the current state; browse back via Twitter for more of the history which you can find at [Archive.is] Jeroen Pluimers on Twitter: “Too much to let sink in …” and [Archive.is] Jeroen Pluimers (@jpluimers) | Twitter.

Too much to let sink in, not just about the hospital results and upcoming surgery, but also about Cindy and Danny Thorpe who just lost their house in the California forest fires, despite it being on the humid side of the Santa Cruz mountains.
If you can help anybody affected by the #CZULightningComplex, please do. Many families there are going through a rough time for the foreseeable future especially because of the combination of fires and COVID.
If you are in that area: be careful, be safe.
For me it is mixed emotions time.
The chemo did make the cancer operable. Some tumors have shrunken, a few small ones are invisible, probably because of the chemo-induced hepatic steatosis, and no new tumor were found.
The prolapse has grown big: extended it is at least 10cm of bowel pushing itself outside of the abdomen causing many stoma leaks (5 full ones in 2 weeks time and 2 almost ones yesterday).
The good news is that it means there is hardly any intestinal adhesion.
The bad news: it takes 4-8 hours a day (of which 1-2 hours during the night) pushing the bowel back into the stoma so the output opening becomes unblocked and the poo can get out.
Though a temporary situation, this eats a lot of energy.
It means I need to find a way to keep my body in shape to prepare for surgery which is in 3-4 weeks (likely mid September).
The surgery will be tough as it will focus on 2 things:
  1. Removing areas of of the liver where the tumors are and were (which is about 30-50% of the liver).
  2. Likely remove the gallbladder, to minimise the chance of bile leakage (which is devastating when it gets into the abdomen)

    (Good news: no chance to get gallstones)

  3. repair the small intestine and remove the stoma.
It is going to be bloody surgery (because of the liver part) taking some 4 hours or more, likely ending up in the IC because the post-surgery risks.
This scares the hell out of me.
In addition recovery will take a long time, and even longer for liver tissue growing back (it will never reach 100%, but should be much more than 50% in a few years time).
I also need to re-learn how to poop, which likely means back to diaper age for quite a while.
So all of this means I feel very confused. Glad on the one side because I will loose the cancer and the stoma, but mixed about the risks and recovery.
More later.

–jeroen

Via [Wayback] Thread by @jpluimers on Thread Reader App: Too much to let sink in, not just about the hospital results and upcoming surgery, but also about Cindy and @danny_thorpe who just lost their house in the California forest fires…

Posted in About, Personal | 1 Comment »

The biggest lie I tell myself is not about new years resolutions.

Posted by jpluimers on 2019/01/01

The biggest lie I tell myself is “I don’t need to write that down, I’ll remember it”

It’s likely older, but the oldest reference I could find was 2012 [WayBack].

So before I forget:

Happy New Year everyone!

With the above quote, it is no coincidence I started my blog even earlier (in 2009): it’s my off-line memory, way better readable than my hand-writing and indexed by various search engines.

Read the rest of this entry »

Posted in About, LifeHacker, Personal, Power User | Leave a Comment »

Installing Windows software with Chocolatey: a few notes

Posted by jpluimers on 2020/10/28

I will limit myself to software that needs Administrative elevation in order to be installed. This is the default use-case for Chocolatey. It is way way easier than installing software all by hand, but there are a few things you need to know, hence these notes.

Administrative elevation

Since the default use case is installing software that requires Administrative elevation during install, Chocolatey needs to run with Administrative privileges in order to perform these installs.

If you were hoping for a way around this (for instance by having a client/service architecture), then just stop here.

Even though such a structure could technically be created, getting it stable and working it correctly with a truckload of software to be installed (much of which not available as packages during Chocolatey development in the first place) is a task too big.

Think of the size of the Windows Installer team at Microsoft to get installers working in the first place, the extra effort needed by Chocolatey volunteers to get the installers working from the console, then another much more complex layer of getting them running from inside a service and communicating everything back and forth to a non-elevated command prompt would be a nightmare.

I won’t even mention the security steps involved to ensure the non-elevated command prompt has enough rights to send installation instructions to the elevated service.

So the first step is to have an elevated command prompt for Chocolatey.

Being elevated, and Chocolatey needing to download installers requires a local temporary place for them.

By default, that place is %Temp%\chocolatey of the administrative user that elevated the Chocolatey command prompt.

This directory can grow quite big, so dir, so – since there is no choco cleanup yet [WayBack] you need to either:

Install Chocolatey itself

Either the direct one below, or the more secure one (so you can inspect the intermediate [WayBackinstall.ps1) at [WayBack] Installation using PowerShell from cmd.exe:

@echo off
SET DIR=%~dp0%
::download install.ps1
%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "((new-object net.webclient).DownloadFile('https://chocolatey.org/install.ps1','%DIR%install.ps1'))"
::run installer
%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%DIR%install.ps1' %*"

If you want to get rid of it, use [WayBack] Uninstallation.

Besides the one above and below, there are many more [WayBack] Installation: more install options

Output of direct install as Administrator (disclaimers apply):

C:\WINDOWS\system32>powershell -NoProfile -ExecutionPolicy Bypass -Command "[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH="%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.11.
Downloading 7-Zip commandline tool prior to extraction.
Extracting C:\Users\JEROEN~1\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\JEROEN~1\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
  Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
  before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
  (i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
  and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.

Creating Chocolatey folders if they do not already exist.

WARNING: You can safely ignore errors related to missing log files when
  upgrading from a version of Chocolatey less than 0.9.9.
  'Batch file could not be found' is also safe to ignore.
  'The system cannot find the file specified' - also safe.
chocolatey.nupkg file not installed in lib.
 Attempting to locate it from bootstrapper.
PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...
WARNING: Not setting tab completion: Profile file does not exist at 'C:\Users\jeroenAdministrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
 first prior to using choco.
Ensuring chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder

Installing packages

Compressing

If you run out of SSD or VM disk space, you can try compress using compact /c /s *.* in these directories:

  • C:\ProgramData\Package Cache
  • C:\ProgramData\Microsoft\VisualStudio\Packages
  • C:\ProgramData\Microsoft\ClickToRun\ProductReleases

Further reading

–jeroen

PS: always watch the output and logs!

Read the rest of this entry »

Posted in Chocolatey, CommandLine, Conference Topics, Conferences, Development, Event, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Leave a Comment »

Spring4D Mock – Delphi Unit Testing : Writing a simple spy for the CUT – Stack Overflow

Posted by jpluimers on 2020/10/28

Reminder to self: write a longer article on Delphi mocking as Spring4D mocking is much better than Delphi Mocks, especially because of code-completion reasons.

Spring4D has a Mock record that can return a Mock<T> on which you can verify using methods like Received.

See:

I got some code that I need to dig up from an old project with many more Spring4D Mock examples.

Note that:

For now, these are a start [WayBack] Delphi Unit Testing : Writing a simple spy for the CUT – Stack Overflow:

Sounds like a use case for a mock (I am using the term mock here because most frameworks refer to their various kinds of test doubles as mock)

In the following example I am using DUnit but it should not make any difference for DUnitX. I am also using the mocking feature from Spring4D 1.2 (I did not check if Delphi Mocks supports this)

unit MyClass;

interface

type
  TMyClass = class
  private
    fCounter: Integer;
  protected
    procedure MyProcedure; virtual;
  public
    property Counter: Integer read fCounter;
  end;

implementation

procedure TMyClass.MyProcedure;
begin
  Inc(fCounter);
end;

end.

program Tests;

uses
  TestFramework,
  TestInsight.DUnit,
  Spring.Mocking,
  MyClass in 'MyClass.pas';

type
  TMyClass = class(MyClass.TMyClass)
  public
    // just to make it accessible for the test
    procedure MyProcedure; override;
  end;

  TMyTest = class(TTestCase)
  published
    procedure Test1;
  end;

procedure TMyClass.MyProcedure;
begin
  inherited;
end;

procedure TMyTest.Test1;
var
  // the mock is getting auto initialized on its first use
  // and defaults to TMockBehavior.Dynamic which means it lets all calls happen
  m: Mock<TMyClass>;
  o: TMyClass;
begin
  // set this to true to actually call the "real" method
  m.CallBase := True;
  // do something with o
  o := m;
  o.MyProcedure;

  // check if the expected call actually did happen
  m.Received(Times.Once).MyProcedure;

  // to prove that it actually did call the "real" method
  CheckEquals(1, o.Counter);
end;

begin
  RegisterTest(TMyTest.Suite);
  RunRegisteredTests();
end.

Keep in mind though that this only works for virtual methods.

  • In case you need to test a method from a base class which cannot be affected by the $RTTI directive, you can use a little trick and redefine it in subclass in public section as override; abstract; this will cause the RTTI to be generated. – Honza RFeb 5 ’16 at 8:02

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Spring4D | Leave a Comment »

performance – How can I produce high CPU load on Windows? – Super User

Posted by jpluimers on 2020/10/28

Reminder to self: [WayBack] performance – How can I produce high CPU load on Windows? – Super User

Poor-mans-solution is a batch file filling one core:

@echo off
:loop
goto loop

To stop, press Ctrl+C in the console.

Far easier is [WayBack] Tools To Simulate CPU / Memory / Disk Load – The Way I See It:

There is an old SysInternals tool from 1996 called “CPU Stress” that still works. (I just tried it on my Windows 10 laptop.)

Custom CPU load

It’s GUI based and allows you to run up to four threads at custom intensities. This allows you to tune the desired CPU load. As a rule of thumb: One thread with Activity set to Maximum will consume about 25% CPU. So as an example: If you run three threads at Maximum, your CPU load goes to about 75%.

Portable

CPUSTRES.EXE is a portable download and does not require installation.

–jeroen

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

Optional sort by name in `LogMemoryManagerStateToFile` · Issue #64 · pleriche/FastMM4 · GitHub

Posted by jpluimers on 2020/10/27

If not done yet, try to improve this: [WayBack] Optional sort by name in LogMemoryManagerStateToFile · Issue #64 · pleriche/FastMM4 · GitHub

–jeroen

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

shell – How do I grep for multiple patterns with pattern having a pipe character? – Unix & Linux Stack Exchange

Posted by jpluimers on 2020/10/27

Since I keep forgetting this – especially because I cannot remember the “why”: [WayBack] shell – How do I grep for multiple patterns with pattern having a pipe character? – Unix & Linux Stack Exchange by “user unknown“.

The -E means using Regular expression: POSIX extended – Wikipedia.

egrep "foo|bar" *.txt

or

grep "foo\|bar" *.txt
grep -E "foo|bar" *.txt

selectively citing the man page of gnu-grep:

   -E, --extended-regexp
          Interpret PATTERN as an extended regular expression (ERE, see below).  (-E is specified by POSIX.)

Matching Control
   -e PATTERN, --regexp=PATTERN
          Use PATTERN as the pattern.  This can be used to specify multiple search patterns, or to protect  a  pattern
          beginning with a hyphen (-).  (-e is specified by POSIX.)

(…)

   grep understands two different versions of regular expression syntax: basic and extended.”  In  GNU grep,  there
   is  no  difference  in  available  functionality  using  either  syntax.   In  other implementations, basic regular
   expressions are less powerful.  The following description applies to extended regular expressions; differences  for
   basic regular expressions are summarized afterwards.

In the beginning I didn’t read further, so I didn’t recognize the subtle differences:

Basic vs Extended Regular Expressions
   In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose their special meaning; instead  use  the
   backslashed versions \?, \+, \{, \|, \(, and \).

I always used egrep and needlessly parens, because I learned from examples. Now I learned something new. :)

–jeroen

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

 
%d bloggers like this: