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

Archive for 2018

When a Delphi TCP server causes sudden EIdConnClosedGracefully Exceptions on the client

Posted by jpluimers on 2018/09/19

I always forget which sides of the connection throw this error, but the client side does as explained in [WayBackdelphi – Troubleshooting EIdConnClosedGracefully Exceptions? – Stack Overflow by [WayBackRemy Lebeau the main Indy contributor:

EIdConnClosedGracefully means the other party … has disconnected its end of the connection. Once that exception has been raised, you cannot send more data to the other party. You must reconnect first.

Read the rest of this entry »

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

I tend to forget there is a record intialiser TPair.Create(Key, Value) – via: delphi – TDictionary populated during create example code – Stack Overflow

Posted by jpluimers on 2018/09/18

I tend to forget that since TPair – introduced in Delphi 2009 – has had a TPair.Create(Key, Value)record initialiser since Delphi 2010, though only fully documented since Delphi XE4:

With some spart short methods, Cosmin Prund shows a really nice helper at [WayBack] delphi – TDictionary populated during create example code – Stack Overflow allowing a call like this:

  with TDictHelper<Integer, string> do
    Dict := Make([P(1, 'one'), P(2, 'two')]);

His answer has all the details (including describing the pros and conse), so here is only the helper:

uses
  SysUtils, Generics.Collections;

type
  TDictHelper<Key, Value> = class
  public
    class function P(const K:Key; const V:Value): TPair<Key, Value>;
    class function Make(init: array of TPair<Key, Value>): TDictionary<Key, Value>;overload;
    class function Make(KeyArray: array of Key; ValueArray: array of Value): TDictionary<Key, Value>;overload;
  end;

{ TDictHelper<Key, Value> }

class function TDictHelper<Key, Value>.Make(init: array of TPair<Key, Value>): TDictionary<Key, Value>;
var P: TPair<Key, Value>;
begin
  Result := TDictionary<Key, Value>.Create;
  for P in init do
    Result.AddOrSetValue(P.Key, P.Value);
end;

class function TDictHelper<Key, Value>.Make(KeyArray: array of Key;
  ValueArray: array of Value): TDictionary<Key, Value>;
var i:Integer;
begin
  if Length(KeyArray) <> Length(ValueArray) then
    raise Exception.Create('Number of keys does not match number of values.');
  Result := TDictionary<Key, Value>.Create;
  for i:=0 to High(KeyArray) do
    Result.AddOrSetValue(KeyArray[i], ValueArray[i]);
end;

class function TDictHelper<Key, Value>.P(const K: Key;
  const V: Value): TPair<Key, Value>;
begin
  Result := TPair<Key, Value>.Create(K, V);
end;

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 7 Comments »

Locating the 7z.exe command-line tool on Windows

Posted by jpluimers on 2018/09/18

From one of my scripts: it will find a  64-bit 7z.exe if it was installed as part of the 7-zip installer, then run it with the parameters provided to the batch file.

  setlocal
  
:verify7zip
:: registry trick from http://www.robvanderwoude.com/files/sortdate2_nt.txt
:: extra trick: tokens=2* allows to get the  3rd (and beyond: space delimited!) value in one variable %%b
  for /F "tokens=2*" %%a IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v Path64 2^>nul') do set sevenZipDirectoryPath=%%b
  call :checkMissingSetting sevenZipDirectoryPath     || goto :help
  
  set sevenZipExeFilePath=%sevenZipDirectoryPath%7z.exe
  if not exist "%sevenZipExeFilePath%" call :showError "No 7-zip executable at %sevenZipExeFilePath%" || goto :help
  
:run7zip
  "%sevenZipExeFilePath%" %*

  endlocal
  goto :end
  
:checkMissingSetting
  if not defined %1 call :notifyMissingSetting %1 && exit /b 1
  call :showSetting %1
  exit /b 0
  goto :end

:notifyMissingSetting
  echo Registry didn't provide the environment variable "%1"
  goto :end
  
:showError
  :: remove double quotes using tilde trick:
  echo %~1
  
:help
  echo Syntax: %0 7z.exe-commandline-parameters
  goto :end

:end

–jeroen

Posted in 7zip, Batch-Files, Compression, Development, Power User, Scripting, Software Development | Leave a Comment »

YouTube video how to use DDetours library to hook Win32 API in Delphi

Posted by jpluimers on 2018/09/18

via [WayBack] Just was sneaking around YouTube and found this video showing how to use DDetours library to hook Win32 api. – Mahdi Safsafi – Google+

–jeroen

Read the rest of this entry »

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

Do change your underwear often, but not your passwords. Keep both of your desk and do not share them with anyone.

Posted by jpluimers on 2018/09/18

Maastricht University got 2 out of 3: [WayBack] https://twitter.com/ml2mst/status/1030626908629811200 – Jeroen Wiert Pluimers – Google+

–jeroen

via [WayBack] Marti van Lin 🇳🇱 🇮🇱 on Twitter : “Some useful advice from @MaastrichtU #Security #passwords #computerintelligence 😂😂😂 cc: @nixcraft… “

https://twitter.com/ml2mst/status/1030626908629811200

 

Posted in Power User, Security | Leave a Comment »

(88) swopper office chair: how to assemble and adjust – YouTube

Posted by jpluimers on 2018/09/17

Interesting chair. Bit pricy, but I tried it and like it!

–jeroen

Posted in LifeHacker, Power User | Leave a Comment »

Some interesting presentations by Arjen Kamphuis

Posted by jpluimers on 2018/09/17

The missing of [WayBackArjen Kamphuis (@ArjenKamphuis) | Twitter, made me revisit some of his past videos. In addition, I made the list quite a bit longer, as I was not aware he made so many presentations.

Many, but not all, of these videos are listed no YouTube video channel of Arjen Kamphuis.

Be sure to read the book Information Security for Journalists – Gendo he co-authored with Silkie Carlo.

–jeroen

 

Posted in Power User, Security | Leave a Comment »

Satellite internet is awfully slow for interactive use

Posted by jpluimers on 2018/09/17

A while back, Thomas Mueller assumed that Satellite internet could be an alternative for rural areas in Germany: [WayBack> Auch der Internet-Anschluss über Satellit funktioniere allenfalls quälend langsam <Das kommt mir aber ziemlich seltsam vor… – Thomas Mueller (dummzeuch) – Google+ as a response to [Archive.isTelekom-Posse: Wirt soll eine Million Euro für schnelles Internet zahlen – WELT.

So I summed up what throttling to 600 (optimistic) or 1000 millisecond (realistic) latency on a 10 megabit connection means: awfully slow for interactive use.

The problem with satellite based internet is latency times: 500 milliseconds is the physical minimum for a geostationary connection. It can easily double with overbooked connections (default with consumer DSL/Cable/Fiber).

The latency combined with the very chatty nature of most applications, is the real killer for your experience.

Compare that to my speeds 2 years ago: https://wiert.me/2015/10/05/fiber-to-fiber-speed-beats-cable-to-fiber-speed-by-a-factor-2-all-three-internet-connections-are-in-the-same-house/

I just did a comparison with the fiber connection at my brother (who lives some 20 miles away) and work too and re-checked the fiber connections in the article (they stayed the same).

  • fiber 1 = home
  • fiber 2 = home
  • fiber 3 = brother
  • fiber 4 = work

Traceroute results:

  • fiber 1 to fiber 2: 5 milliseconds
  • fiber 3 to fiber 2: 8 milliseconds
  • fiber 4 to fiber 2: 4 milliseconds
  • cable to fiber 2: 10 millseconds
  • ADSL to fiber 2: 15 millseconds

With these, you can have > 50 connections per second.

Satellite gives you 2 connections per second if you are lucky.

The blog page takes ~160 web requests.

  • DOM content load ~ 1.0 seconds
  • Full load finished ~2.2 seconds
  • Render finished ~5.0 seconds

I throttled it down to Satellite speed:

  • 10 megabit downstream
  • 2 megabit upstream
  • 600 millisecond latency

Now this is the load:

  • DOM content load ~ 2.9 seconds
  • Full load finished ~9.9 seconds
  • Render finished ~10.0 seconds

Increasing the latency to 1000 milliseconds brings this:

  • DOM content load ~ 4.2 seconds
  • Full load finished ~11.8 seconds
  • Render finished ~14.9 seconds

Fully loading gmail.com or booking .com with 1000 millisecond latency takes over 30 seconds.
References:

Read the rest of this entry »

Posted in Internet, Power User | 2 Comments »

When Windows 8.1 gives 80070643 on applying Office 2013 SP1

Posted by jpluimers on 2018/09/17

Steps to try first:

  1. Check %windir%\Windowsupdate.log (on my system, it did not reveal anything special)
  2. In an administrator command prompt, run sfc /scannow (which takes a few minutes to run)
  3. Reboot
  4. Run Clean Manager %windir%\System32\cleanmgr.exe (ensure to clean up update files: it can take tens of minutes to run)
  5. Reboot
  6. Download the SP1 files (I needed 32-bit x86)
  7. Install SP1 manually
  8. If it still hangs:
    1. In Appwiz.cpl try a “Repair” of the Office 2013 installation
    2. If it works: Reboot, otherwise:
      1. Uninstall Office 2013
      2. Disable the network adapter
      3. Reboot
      4. Check if KB3173424 is installed (check it with Appwiz.cpl)
        1. if not: download on a different machine, transfer over USB, install, then reboot
      5. Check ifKB3172614 is installed (which has a younger Windows Update Client)
        1. if not: downloadon a different machine, transfer over USB, install, then reboot
      6. Enable the network adapter
      7. Let Windows scan for updates and install them
        1. If you get an error 80070463 or 80070663: just reboot and retry the updates.
      8. Reboot
      9. Run Clean Manager
      10. Install Office 2013
      11. Reboot
  9. Let Windows scan for updates and install them
  10. Reboot
  11. Run Clean Manager
  12. Reboot

The KB3172614 should also alleviate long during (dozens of minutes) high CPU usage of svchost.exe and TiWorker.exe when searching for Windows updates.

Read the rest of this entry »

Posted in Office, Office 2013, Power User, Windows, Windows 8.1 | Leave a Comment »

Not cool: openSuse Tumbleweed switched DHCP clientID algorithm on Raspberry Pi 3, so now all devices get a non-static DHCP address

Posted by jpluimers on 2018/09/15

Not sure in which changeset this happened, but here is one example:

  1. old DHCP client ID 1:b8:27:eb:1a:b1:ec
  2. new DHCP client ID ff:eb:78:a9:4:0:1:0:1:22:6:67:49:b8:27:eb:78:a9:4

The first one was marked static in the DHCP server, which means the Raspberry Pi now did get a different IP address.

This messes up a few places that cannot do proper address resolution.

Anyone who knows where this has changed / is configured?

These did not help finding the cause:

Edit

As commented by Leen below, this is about

Wicked changed its defaults to use this DHCPv6 compatible RFC4361 client-id in favour of the older RFC2132 client-id. However, this has caused some issues with older DHCPv4 servers and existing setups where the client-id stored by the server is used to assign a (static) address. It is recommended to fix this server-side, but still, wicked provides several ways of addressing this issue

So here are some links:

–jeroen

Posted in *nix, Hardware Development, Linux, openSuSE, Power User, Raspberry Pi, SuSE Linux, Tumbleweed | 6 Comments »