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 1,861 other subscribers

Archive for November, 2020

How to quickly add hours/minutes/second to date and time in Excel?

Posted by jpluimers on 2020/11/11

Excel date times are almost identical to OLE/COM automation date times (that used in many Windows applications).

Which means that dates are 1 unit apart, and:

  • Weeks = 7
  • Days = 1
  • Hours = 1/24
  • Minutes = 1/(24*60) or 1/1440
  • Seconds = 1/(24*60*60) or 1/86400

That way you can easily add one hour to a date/time value by adding 1/24.

Source: How to quickly add hours/minutes/second to date and time in Excel?

Related:

–jeroen

Posted in Development, Excel, LifeHacker, Office, Power User, Software Development | Leave a Comment »

Editors (including visual studio code – VSCode): insert tab character manually – Stack Overflow

Posted by jpluimers on 2020/11/11

Sometimes you are in search of a real TAB character, as most editors (except a few like the ones for Golang) I bump into are space-based. A great answer at [WayBack] visual studio code – VSCode insert tab character manually – Stack Overflow:

Quick-and-dirty solution: Find a tab somewhere else, then copy-paste.

Chances are that you already have a tab character in the file you are editing, but if not you can generate one in another application or text editor.

You can also generate a tab programmatically in a bash shell with the following command (the brackets are optional):

echo -e [\\t]

For your more immediate needs, I have inserted a tab character below…

    There is a tab character between these brackets: [ ]

–jeroen

Posted in Development, Software Development, Visual Studio and tools, vscode Visual Studio Code | Leave a Comment »

Be careful changing the DataContext of a TRemotable

Posted by jpluimers on 2020/11/11

Still not sure why the RTL code is like this:

procedure TRemotable.SetDataContext(Value: TDataContext);
begin
  if (RemotableDataContext <> nil) and (RemotableDataContext = Self.DataContext) then
  begin
    TDataContext(RemotableDataContext).RemoveObjectToDestroy(Self);
  end;
  FDataContext := Value;
end;

It means that if you ever have to change the DataContext property from the default global RemotableDataContext, it will be removed, but not added to the new DataContext.

When you assign it nil (so you can dump it to JSON, which often is easier to read than XML), and back to the old value, this results in a memory leak:

function TNotificationKeyPortTypeImplementation.prematchChanged(const prematchChangedRequest: prematchChangedRequest): prematchChangedResponse;
var
  DataContext: TDataContext;
begin
  // ...
  DataContext := prematchChangedRequest.DataContext;
  try
    prematchChangedRequest.DataContext := nil; // otherwise the JSON serializer will stackoverflow because DataContext points back to the TRemotable instance.
    Result := Format('prematchChanged: prematchChangedRequest=%s', [TJson.ObjectToJsonString(prematchChangedRequest)]);
  finally
    // `prematchChangedRequest.DataContext := nil` removed `prematchChangedRequest` from `DataContext.FObjsToDestroy`
    DataContext.AddObjectToDestroy(prematchChangedRequest);
    prematchChangedRequest.DataContext := DataContext; // does not add `prematchChangedRequest` to `DataContext.FObjsToDestroy`
  end;
end;

or when you are outside an incoming SOAP call where DataContext might not be assigned at all:

function ToJSON(const Value: TRemotable): string;
var
  DataContext: TDataContext;
  RemotableDataContext: Pointer;
begin
  if Assigned(Value) then
  begin
    DataContext := Value.DataContext;
    try
      Value.DataContext := nil; // otherwise the JSON serializer will stackoverflow because DataContext points back to the TRemotable instance.
      Result := TJson.ObjectToJsonString(Value);
      Result := TRegExSanitiser.ReplaceSecretInText(Result, [rttJSON]);
    finally
      // `Value.DataContext := nil` removed `Value` from `DataContext.FObjsToDestroy`
      if Assigned(DataContext) then
      begin
        RemotableDataContext := GetRemotableDataContext();
        if Assigned(RemotableDataContext) and (RemotableDataContext = DataContext) then
          DataContext.AddObjectToDestroy(Value);
        Value.DataContext := DataContext; // does not add `Value` to `DataContext.FObjsToDestroy`
      end;
    end;
  end
  else
    Result := '';
end;

–jeroen

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

JSON to tabular format via JSONformatter.org and JSON2table.com

Posted by jpluimers on 2020/11/10

Two interesting sites to ease transforming JSON fragments in log-messages to a table system, for instance Excel.

  1. Paste the bits in [WayBack] Best JSON Pretty Print Online then fix any syntax errors.
  2. Copy from there to [WayBack] json2table.com and press the triangle button (run)
  3. Copy either the tabular or tree result to your favourite program.
  4. Format any numbers for readability. I really like the Custom format ##0.00E+00 that just shows the exponents in multiples of 3 (so kilo, mega, giga, etc)[WayBack] formatting – How can I format bytes a cell in Excel as KB, MB, GB etc? – Stack Overflow

This way I copied the example code into adjecent Excel areas, so I could compare the values and calculate memory increase of a Delphi application.

jeroen

Read the rest of this entry »

Posted in Development, JavaScript/ECMAScript, JSON, LifeHacker, Power User, Scripting, Software Development | Leave a Comment »

Radio Garden

Posted by jpluimers on 2020/11/10

Explore live radio by rotating the globe.

[Archive.is] Radio Garden

Via: [WayBack] Radio Garden is just too cool Check out radio across the planet with this interactive station finding globe! – Kevin Powick – Google+

–jeroen

Read the rest of this entry »

Posted in LifeHacker, Power User | Leave a Comment »

Git pushing to multiple remotes

Posted by jpluimers on 2020/11/10

I didn’t know there were multiple ways to push to multiple remotes.

[WayBack] github – Git – Pushing code to two remotes – Stack Overflow is intriguing as the accept answer shows one remote can have more than one URL, and you can push to all of them at the same time.

Most people just have multiple remotes with one URL per remote, and have a branch optionally track one remote brach: [WayBack] How can I tell a local branch to track a remote branch?

The other way around: you can find out which branch track remote branches as well: [WayBack] git – Find out which remote branch a local branch is tracking – Stack Overflow

–jeroen

 

Posted in Development, DVCS - Distributed Version Control, git, Software Development, Source Code Management | Leave a Comment »

Bootable virus scanners supporting ntfs

Posted by jpluimers on 2020/11/09

I was looking for a bootable virus scanner supporting NTFS. Kaspersky was the first one I found, and it worked well.

Back then, these were the output locations:

The HTTP link can be convenient for locations that do not support TLS (cough, VMware ESXi wget, cough), which are OK if you calculate the sha256 hash from the TLS link first.

Likely there is a 2020 version by now.

I got the links via:

I might try BitDefender later.

–jeroen

Posted in LifeHacker, Power User, Security | Leave a Comment »

“net view” “System error 1231 has occurred.” “Windows 10”

Posted by jpluimers on 2020/11/09

On my research list: none of my Windows 10 PC’s in WORKGROUP can see that other machines exist, but they can connect to each other.

C:\>net view
System error 1231 has occurred.c

C:\>net view
System error 6118 has occurred.

On Windows 8.1 and 7 (I know: both beyond end-of-support) can see both Windows 8.1/7 machines and Windows 10 machines:

C:\>net view
Server Name          Remark
-------------------------------------------------------------------------------
\\...
The command completed successfully.

It is unclear on which Windows 10 release this started failing. I think it is around 1803 (April 2018 Update) or 1709 (Fall Creators Update). It fails despite all settings indicating sharing and discovery are enabled:

Things tried that failed:

Start service WebClient

Tried from an administrative command prompt, then waited a minute:

C:\net start WebClient
The WebClient service is starting.
The WebClient service was started successfully.

Failed.

Via: [WayBack] System error 1231 has occurred – Microsoft Community

Ensure system names are uppercase

The system names were already in uppercase.

Via: [WayBack] Win10 10586 – FOUND FIX for system error 1231 bug ( network shares – Microsoft Community

TODO

Note: do not re-enable SMBv1 as it is inherently insecure!

–jeroen

Posted in Power User, Windows, Windows 10 | Leave a Comment »

Poundland lights unexpected feature and USB mod. to operate christmas lights using USB – YouTube

Posted by jpluimers on 2020/11/09

Cool video with nice ideas:

–jeroen

Posted in Development, Hardware Development | Leave a Comment »

PoE to ethernet + micro USB converters

Posted by jpluimers on 2020/11/06

The first is 100mbit, some do not get it to work with Raspberry Pi 3B+, but others do get it to work, even at 1Gbit:

The second is 1Gbit, about 40% more expensive, but just works:

Via: [WayBack] Thread by @Nick_Craver: “Shout out to @mstum for reminding me 1Gb PoE USB splitters are completely viable for Raspberry Pis – now running a fi PoE switches and using just 1 outlet on the UPS: … Less wiring and if the network’s […]”

–jeroen

Posted in Development, Hardware Development, Power User, Raspberry Pi | Leave a Comment »