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

Delphi: a pattern for a generic factory, this one for components, but can be uses for anything having a base class like a TThread descendant.

Posted by jpluimers on 2018/05/16

Generics and constraints in Delphi is still a bit of pain.

A while ago, I needed a factory for threads. It was more convoluted than I meant it to be, so I had a short chat with Stefan Glienke.

He came up with an example similar to the one below. I tore it apart so you can on each line see what the compiler dislikes.

This fails, but was kind of how I wanted it to be:

type
   TFactory = record
     class function Manufacture<T: TBaseClass, constructor>(parameter definitions): T;
   end;

class function Manufacture<T: TBaseClass, constructor>(parameter definitions): T;
begin
  Result := T.Create(parameter values);
end;

Which means I need to update Delphi Constraints in Generics – RAD Studio XE documentation wiki

The factory:

type
  TComponentFactory = class
    class function CreateComponent<T: TComponent>(AOwner: TComponent): T; static;
  end;

class function TComponentFactory.CreateComponent<T>(AOwner: TComponent): T;
var
  ComponentClass: TComponentClass;
  Component: TComponent;
begin
  ComponentClass := T;
  Component := ComponentClass.Create(AOwner); // you can't do `T.Create(AOwner)`
  Result := T(Component); // you can't do `Result := ComponentClass.Create(AOwner);`
end;

The usage:

var
  Component: TButton;
  Owner: TComponent;
begin
  Owner := Application.MainForm;
  Component := TComponentFactory<TButton>.CreateComponent(Owner);
  Component.Parent := Owner;
end;

Full source example is at: After a discussion with Stefan Glienke: a pattern for a factory, this one for components, but can be uses for anything having a base class like a TThread descendant.

In the mean time, Spring4D has added the [Archive.is] Spring4D: TActivator record with many CreateInstance methods that allow you to create instances of classes for which you just have type information.

–jeroen

This fails:

type
   TFactory = record
     class function Manufacture<T: TBaseClass, constructor>(parameter definitions): T;
   end;

class function Manufacture<T: TBaseClass, constructor>(parameter definitions): T;
begin
  Result := T.Create(parameter values);
end;

view raw

readme.md

hosted with ❤ by GitHub


type
TComponentFactory = class
class function CreateComponent<T: TComponent>(AOwner: TComponent): T; static;
end;
class function TComponentFactory.CreateComponent<T>(AOwner: TComponent): T;
var
ComponentClass: TComponentClass;
Component: TComponent;
begin
ComponentClass := T;
Component := ComponentClass.Create(AOwner); // you can't do `T.Create(AOwner)`
Result := T(Component); // you can't do `Result := ComponentClass.Create(AOwner);`
end;


var
Component: TButton;
Owner: TComponent;
begin
Owner := Application.MainForm;
Component := TComponentFactory<TButton>.CreateComponent(Owner);
Component.Parent := Owner;
end;

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

Delphi WSDL default importer settings

Posted by jpluimers on 2018/05/15

Note to self (as the WSDL importer has trouble with WSDL files that include XSD files having xsd:group definitions), the default settings of the importer in the UI:

-Oa -Od -Oe -Of -Oh -Oi -Oj -Oo -Op -Ot -Ou -Ov -Ox

This matches the output from the WSDLImp.exe default settings as well (larger screenshots below):

I suspect the reason is that the command-line importer does, but the wizard does not, show an exception during processing:

*Error*: D:\Playground\iECK DT2.0 services v2.1.1\xsd\ECK-DT2-CatalogServiceSchema-v2.1.1.xsd
> Access violation at address 0059DBA4 in module 'WSDLImp.exe'. Read of address 00000000
Done : D:\Playground\iECK DT2.0 services v2.1.1\wsdl\ECK-DT2-CatalogService-v2.1.1.wsdl>0
Writing: D:\Playground\iECK_ImportWSDL\ECK_DT2_CatalogService_v2.pas

Hopefully more on that later.

Both the IDE expert and console based WSDLimp will write the output .pas file and the output file of both tools has the same content.

–jeroen

Read the rest of this entry »

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

Delphi – finding published event handlers that have lost their binding from the DFM

Posted by jpluimers on 2018/05/15

The scripts in these links didn’t work well enough for me:

So I’ve been working on a GExperts based solution (because that gave me a nice starting point). It’s not fully done yet, so here are a few things I’ve used:

(Reminder to self: contact David Hoyle who knows a lot about the OTA).

–jeroen

Read the rest of this entry »

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

State.of.dev

Posted by jpluimers on 2018/05/15

Reminder to self: more than a year later, see the progression of [Archive.isState.of.dev, a project that visualizes the current state of development split by key topics.

Or basically a split graph of the one on the side into various graphs by topic.

Current state: Home – State.of.dev

Past state: WayBack (hopefully it got the graphs archived by now).

The author is Yvo Schaap – Medium who also wrote the very interesting post [WayBackWhy your business needs a good downturn – CTO Insights – Medium.

–jeroen

Read the rest of this entry »

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

“A Journey to OCP”, Open Compute Meetup in Amsterdam – YouTube

Posted by jpluimers on 2018/05/14

Well worth watching: “A Journey to OCP”, Open Compute Meetup in Amsterdam – YouTube

Keywords: Open Compute Platform, Booking, Kohntopp

Related: [WayBack] To France… – The Isoblog.

 

–jeroen

Posted in Cloud, Infrastructure | Leave a Comment »

Ubuntu: Fixing the myserious “Failed to stop apt-daily.timer: Connection timed out”

Posted by jpluimers on 2018/05/14

Ubuntu is the only Linux system I had that – after installing a text-mode console setup – gets itself in the below state with only running apt update and apt-get upgrade.

Preparing to unpack .../archives/apt_1.2.19_armhf.deb ...
Failed to stop apt-daily.timer: Connection timed out
See system logs and 'systemctl status apt-daily.timer' for details.
Failed to get load state of apt-daily.timer: Connection timed out
dpkg: warning: subprocess old pre-removal script returned error exit status 1

I could not find meaningful search results for the above thing, nor did systemctl status apt-daily.timer return anything better than

Failed to get properties: Failed to activate service 'org.freedesktop.systemd1': timed out

Heck, it doesn’t even reboot any more (no helpful search results either):

# reboot
Failed to start reboot.target: Failed to activate service 'org.freedesktop.systemd1': timed out
See system logs and 'systemctl status reboot.target' for details.
Failed to open /dev/initctl: No such device or address
Failed to talk to init daemon.

Nor did systemctl status reboot.target return anything better than

Failed to get properties: Failed to activate service 'org.freedesktop.systemd1': timed out

From the ubuntu-16.04-minimal-odroid-c1-20160817.img.xz base system, it only had these extra packages installed:

  • etckeeper
  • tmux
  • speedtest-cli
  • sendemail

Workaround found, but still unsure why this happened in the first place

Despite the workaround below, I still don’t know why I got into this situation and this leaves me with a very uncomfortable feeling.

Too bad some systems (like ODroid) only have Ubuntu based distributions as sorting out stuff like above took me way too much effort.

Read the rest of this entry »

Posted in *nix, Development, etckeeper, Hardware Development, Internet, Linux, Odroid, Power User, SpeedTest, Ubuntu | 2 Comments »

When Windows suddenly starts mixing up keys for various applications.

Posted by jpluimers on 2018/05/14

Since:

  • many people use the left-alt key as it as it is more accessible
  • development tools uses a lot of Alt-Shift based keyboard shortcuts
  • Windows by default has the Left Alt+Shift shortcut enabled to switch language+keyboard layout combinations
  • In most countries, Windows by default has more than one language+keyboard combination installed
  • Windows remembers per application instance which language+keyboard combination is used

every now and then you will get strange characters in only your development tools.

You can change this Windows setting, but be aware that every now and then, various Windows versions will re-enable the Left Alt+Shift even if you have previously disabled it. As of Windows 7 this occurs far less often, but still seems to occur.

Source: Question: Does anyone else have instances in the IDE (Berlin but has happened…

Comments at https://plus.google.com/+JeroenPluimers/posts/ektRa2qW92L

 

Posted in internatiolanization (i18n) and localization (l10), Keyboards and Keyboard Shortcuts, Power User, Windows | Leave a Comment »

When you loose your Google Guides level, still can post reviews, but do not have access to the forums any more…

Posted by jpluimers on 2018/05/11

Via a private share: If you ever loose your Google Guides level for no apparent reason, still can post reviews, but cannot post to the Google Guides forums, then just mail Google. They can usually fix the situation.

–jeroen

Posted in Google, GoogleMaps, Local Guides, Power User | Leave a Comment »

How to Add Your Gmail Account to Outlook 2013 and 2016 Using IMAP

Posted by jpluimers on 2018/05/11

If you use Outlook to check and manage your email, you can easily use it to check your Gmail account as well. You can set up your Gmail account to allow you to synchronize email across multiple machines using email clients instead of a browser.

Oh: you need to lower your Gmail security for Outlook 2013 as the latter isn’t up to par on security. For that, follow similar steps like in “the user name or password for imap.gmail is incorrect” – iPad, iPod or iPhone with iOS < 7.

–jeroen

Posted in GMail, Google, Office, Office 2013, Office 2016, Outlook, Power User | Leave a Comment »

Some Raspberry Ideas via Tweakers.net

Posted by jpluimers on 2018/05/11

via: [WayBackRaspberry Pi Zero W met wifi en bluetooth kost 10 dollar – Computer – Nieuws – Tweakers

  • LibreELEC (media player OS for Kodi); if your PC is recent enough and supports CEC, you can even use the remote control of your TV to controle the KODI user interface
  • EmulationStation; play old NES/SNES/PS1/etc games on your TV
  • Pi Hole, alternative DNS server that blocks ads even on devices that do not support an ad blocker
  • Domoticz to support device and protocols like Klik-aan-klik-uit, Z-Wave, HVAC, thermostats, smart electricity meters, and make your home “smart”
  • Build Robotjes and control with your smartphone
  • Install Rasbian and replace simple desktop machine usage
  • Sick Beard
  • Sonarr
  • SABnzbd+
  • Couch Potato
  • Retropie
  • http://makezine.com/proje…ode-raspberry-pi-cluster/

–jeroen

Posted in *nix, Debian, Development, Hardware Development, Linux, Power User, Raspberry Pi, Raspbian | Leave a Comment »