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,862 other subscribers

Archive for November, 2017

github – Open Atom editor from command line – Stack Overflow

Posted by jpluimers on 2017/11/17

I have the Atom editor and was wondering how you can open a file or folder from the terminal in Atom. I am using a Mac. I am looking for a way to do this: atom . (opens folder) atom file.js (

The answer to it isn’t any good any more (since then, Atom has evolved), but this comment works splendid:

I solved the issue by choosing “Install Shell Commands” under the “Atom” menu.

It will add a script in /usr/local/bin/atom that starts Atom with the parameters you entered.

Thanks [WayBackrxgx!

[WayBackgithub – Open Atom editor from command line – Stack Overflow

–jeroen

PS: Reminder to self to add a screenshot.

Posted in Apple, atom editor, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, MacMini, macOS 10.12 Sierra, OS X 10.11 El Capitan, Power User, Text Editors | Leave a Comment »

Hi! how to hide a property in object inspector? i have my custom components …

Posted by jpluimers on 2017/11/16

For my link archive:

Some quotes

–jeroen

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

DNS BIND9 acl clause – they *can* be nested

Posted by jpluimers on 2017/11/16

One of the use cases of DNS acl I needed involved having some data to be duplicated across acl.

So I was looking at some way to de-duplicate and found out the term for that is nesting which the bind acl allow.

–jeroen

Posted in DNS, Internet, Power User | Leave a Comment »

Happy 60th birthday, Fortran

Posted by jpluimers on 2017/11/15

I remember a FORTRAN IV (or was it 66?) course during my chemistry studies at the end of the 1980s. Luckily, the VAX/VMS version (not sure which one, it ran on a VAX 11/750) where we had to program on came with an extended FORTRAN 77 compiler even supporting 132 columns and other nice features.

My favourite program was about an algorithm to assemble 3 tables (one relating atom numbers and their valencies, a second with atom-atom distances, a third with 3-D atom positions) into a chemical compound indicating any rings. I implemented my own recursion with stacks citing a Dire Straits song with “and when you finally reappear, at the place where you came in…”.

Later I ported this to a PC reviewing the Microsoft FORTRAN 5.1 compiler for the Dutch PCM (Personal Computer Magazine). Recently I learned Lahey had a big role in the Fortran.NET compiler.

This year FORTRAN turned 60 years old and it is still in used, though not as heavily as a few decades ago.

The Fortran compiler, introduced in April 1957, was the first optimizing compiler, and it paved the way for many technical computing applications over the years. What Cobol did for business computing, Fortran did for scientific computing. Fortran may be approaching retirement age, but that doesn’t mean it’s about to stop working. This year marks the 60th anniversary of the first Fortran (then styled “FORTRAN,” for “FORmula TRANslation”) release.

Source: [WayBack] Happy 60th birthday, Fortran.

Via [Archive.is] Happy 60th birthday, Fortran – ThisIsWhyICode – Google+

Historic references:

–jeroen

Read the rest of this entry »

Posted in Development, Fortran, Software Development | 1 Comment »

FastMM4 + Delphi – Recompiling application with 10.2.1 causes memory leaks?

Posted by jpluimers on 2017/11/15

This is why you should always test your Delphi apps with FastMM4 and FullDebugMode enabled: [WayBack] Delphi – Recompiling application with 10.2.1 causes memory leaks?

A workaround is to add the below code in either of these places:

  • end of your .dpr file right before the end.
  • in the finalization section of a new unit

CheckSynchronize();

It calls the [WayBackSystem.Classes.CheckSynchronize method to ensure the background thread performs the needed cleanup.

Thanks Stefan Glienke for solving this.

–jeroen

Read the rest of this entry »

Posted in Delphi, Delphi 10.2 Tokyo (Godzilla), Development, Software Development | Leave a Comment »

immediate “Too many authentication failures” – check your authentication methods

Posted by jpluimers on 2017/11/15

If you ever ssh into something and immediately get the immediate Too many authentication failures message, then you’ve probably mixed your authentication methods.

Follow the steps in [WayBackssh – Too many authentication failures for username – Super User (thanks [WayBackJohn T and [WayBackBen West).

First check out whats wrong by slowly increasing the number of -v parameters to make output more verbose:

ssh -v
ssh -v -v
ssh -v -v -v

Then try to find out which authentication method fails: usually it’s a private key that’s wrong.

I’ve had success in various cases where I screwed up with these ssh parameters:

-o PubkeyAuthentication=no
-i some_id_rsa -o IdentitiesOnly=yes

–jeroen

 

Posted in *nix, Communications Development, Development, Internet protocol suite, Power User, Software Development, SSH, TCP | Leave a Comment »

Changing a commit message – User Documentation

Posted by jpluimers on 2017/11/15

When you haven’t pushed yet, git rebase --interactive HEAD~# where # is the number of commits to view is your friend: [WayBackChanging a commit message – User Documentation.

At the first screen, replace aa with reword then change the commit message for each commit and copy the message.

Then in each following screen, if you changed the commit message for that commit, change it there as well.

Similar answers are at [WayBackgit – How to modify existing, unpushed commits? – Stack Overflow

–jeroen

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

Delphi: ^TNodeData incompatible with PNodeData – {$T+} versus {$T-}

Posted by jpluimers on 2017/11/14

In my Turbo Pascal days, I was fan of the {$T+} directive (now a.k.a TypedAddress on) as it would make the @ operator return typed pointers and the compiler would be more strict in forcing checks on pointer types to be compatible.

Not so much in Delphi any more, see the below comment on in a G+ thread on Delphi pointer type compatibility [WayBack] by David Millington from Embarcadero.

Basically we’re stuck with {$T-} which is a double edged sword:

  • on the one hand it forces you to ensure your typed pointers are always the same actual type (so you need to define a type like PNodeData once and use it everywhere)
  • on the other hand it still allows the generic Pointer type to be compatible with typed pointers which means people use that and will not have the benefit of typed pointer checking

David Millington:

So the question is why is PNodeData different to ^TNodeData? These two pages have the answer:

  • “Two distinct types are compatible if they satisfy at least one of the following conditions:
    … (snip)
  • One type is Pointer (an untyped pointer) and the other is any pointer type.
  • Both types are (typed) pointers to the same type and the {$T+} compiler directive is in effect.”

[WayBackhttp://docwiki.embarcadero.com/RADStudio/Berlin/en/Type_Compatibility_and_Identity_(Delphi)#Type_Compatibility

That line about $T+ is key; it’s the “Typed @ operator” compiler option which is off by default. “In the {$T-} state, distinct pointer types other than Pointer are incompatible (even if they are pointers to the same type)”. So with that off, PNodeData and ^TNodeData are different.

[WayBackhttp://docwiki.embarcadero.com/RADStudio/en/Type-checked_pointers_(Delphi)

The best solution is to define PNodeData, as you’ve done, and use it everywhere.

What David fails to mention there, and I added as a commen later is this:

The problem $T is that it’s a two-edged sword as it makes code that looks valid fail to compile because the compiler in the $T+ state (a.k.a. $TypedAddress on state) never got updated to:

  • handle @ to an array creates a pointer to the element of that array
  • handle @ to resourcestrings to become PResStringRec (and likely more examples)

Which means the below programs fail to compile.

The alternative (adding way more {$T+} compatible overloads to the RTL/VCL/FMX) was never done either, so now we’re stuck with {$T-}

Array of char example:

program TypedAddressDirectiveWithCharArrays;

{$APPTYPE CONSOLE}

{$TypedAddress on}

uses
  Winapi.Windows;

var
  TimeZone: string;
  TZ: TTimeZoneInformation;

begin
  TimeZone := 'Coordinated Universal Time';
  StringToWideChar(TimeZone, @(TZ.StandardName), SizeOf(TZ.StandardName) div SizeOf(WideChar));
end.

(*

[dcc32 Error] TypedAddressDirectiveWithCharArrays.dpr(16): E2010 Incompatible types: 'PWideChar' and 'Pointer'

In the System unit:

implicit types:

  PWideChar = WideChar;
  PChar = PWideChar

explicit:

function StringToWideChar(const Source: UnicodeString; Dest: PWideChar; DestSize: Integer): PWideChar;



In the Winapi.Windows unit:

type
  WCHAR = WideChar;

  PTimeZoneInformation = ^TTimeZoneInformation;
  _TIME_ZONE_INFORMATION = record
    Bias: Longint;
    StandardName: array[0..31] of WCHAR;
    StandardDate: TSystemTime;
    StandardBias: Longint;
    DaylightName: array[0..31] of WCHAR;
    DaylightDate: TSystemTime;
    DaylightBias: Longint;
  end;
  TTimeZoneInformation = _TIME_ZONE_INFORMATION;
  TIME_ZONE_INFORMATION = _TIME_ZONE_INFORMATION;

*)

ResourceString example:

program TypedAddressDirectiveWithResourceStrings;

{$APPTYPE CONSOLE}

{$TypedAddress on}

uses
  System.SysConst,
  System.SysUtils;

procedure RangeError;
begin
  raise ERangeError.CreateRes(@SRangeError);
end;

begin
end.

(*
[dcc32 Error] TypedAddressDirectiveWithResourceStrings.dpr(13): E2250 There is no overloaded version of 'CreateRes' that can be called with these arguments


System unit:

type
  PResStringRec = ^TResStringRec;
  {$IF defined(EXTERNALLINKER)}
  TResStringRec = record
    Key: MarshaledAString;
  end;
  {$ELSE}
  TResStringRec = packed record
    // 32bit = 8 bytes
    // 64bit = 16 bytes
    Module: ^HMODULE;
    Identifier: NativeUint;
  end;
  {$ENDIF}


System.SysConst unit:

resourcestring
  SRangeError = 'Range check error';


SysUtils unit:

constructor Exception.CreateRes(ResStringRec: PResStringRec);
begin
  FMessage := LoadResString(ResStringRec);
end;


*)

Source: [WayBackOn Friday I had a brain fade moment (which I don’t seems to have recovered…

–jeroen

Posted in Delphi, Development, Software Development | 2 Comments »

A 4-bit Calculator made in cardboard and marble

Posted by jpluimers on 2017/11/14

Cool device: [WayBackA 4-bit Calculator made in cardboard and marble

I really love this. Not just that it exists, but how it was made and how it’s explained.

Definitely worth reading.

via: [WayBack] Funny modern abacus https://lapinozz.github.io/learning/2016/11/19/calculator-with-caordboard-and-marbles.html – David Berneda – Google+

–jeroen

Posted in Algorithms, Development, Hardware Development, Software Development | Leave a Comment »

Did you miss the ‘View Certificate’ button in Chrome? : sysadmin

Posted by jpluimers on 2017/11/13

[WayBack] Did you miss the ‘View Certificate’ button in Chrome?:

Good news, it’s back for those who want it:

  1. chrome://flags/#show-cert-linkEnable
  2. , restart, Bob’s your uncle.

Via: [WayBackKristian Köhntopp – Google+ chrome://flags/#show-cert-link

It seems I need to update from Version 59.0.3071.115 (Official Build) (64-bit).

–jeroen

Posted in Chrome, Google, Power User | Leave a Comment »