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

linux – dmesg time vs system time time isnt correct – Server Fault

Posted by jpluimers on 2018/10/10

[WayBacklinux – dmesg time vs system time time isnt correct – Server Fault helped me solve this problem with an Odroid C1+ running busybox:

[root@meye-062016b9 ~]# hwclock --show
Wed Apr  3 20:25:47 2013  0.000000 seconds
[root@meye-062016b9 ~]# date
Wed May 31 09:48:18 UTC 2018
[root@meye-062016b9 ~]# hwclock --systohc --utc
[root@meye-062016b9 ~]# hwclock --show
Wed May 31 09:48:29 2018  0.000000 seconds
[root@meye-062016b9 ~]# date
Wed May 31 09:48:35 UTC 2018
[root@meye-062016b9 ~]#

Note: If your logging clock in /var/log/dmesg.log is wrong by an exact couple of hours, then try [WayBacksyslog time wrong – but date returns the correct time? and edit [WayBack] /etc/sysconfig/clock.

The above involves looking if I can get MotionEyeOS working Giving up on the official Ubuntu for Odroid C1 image.

So far not much luck: the Ubuntu got hosed, but before it was stable as in that didn’t reboot suddenly.

Now the MotionEyeOS (which is busybox based) reboots itself without notice about every 3 minutes, despite no other hardware connected and trying 3 different power supplies.

The Odroid C1+ only draws 0.34 Ampère at 5.13 Volt which is well within specs.

I’m puzzled:

[Wed May 31 09:49:51 2018] Booting Linux on physical CPU 0x200
[Wed May 31 09:52:20 2018] Booting Linux on physical CPU 0x200
[Wed May 31 09:54:50 2018] Booting Linux on physical CPU 0x200
[Wed May 31 09:57:19 2018] Booting Linux on physical CPU 0x200
[Wed May 31 09:59:49 2018] Booting Linux on physical CPU 0x200
[Wed May 31 10:02:22 2018] Booting Linux on physical CPU 0x200
[Wed May 31 10:04:56 2018] Booting Linux on physical CPU 0x200
[Wed May 31 10:07:26 2018] Booting Linux on physical CPU 0x200
[Wed May 31 10:09:59 2018] Booting Linux on physical CPU 0x200
[Wed May 31 10:12:29 2018] Booting Linux on physical CPU 0x200
[Wed May 31 10:14:58 2018] Booting Linux on physical CPU 0x200

jeroen

Posted in *nix, *nix-tools, Power User | Leave a Comment »

TObjectHelper for easier debugging a cast mismatch and a typed FreeAndNil

Posted by jpluimers on 2018/10/10

The below came in really useful in an old project I took over that was full of bugs having to do with improper casts and FreeAndNil usage.

EDIT 20181010: WordPress.com keeps mangling angle-brackets in pre and code sections, so I added the code to a gist; see link below.

First the examples.

procedure TMyServer.UnbindFromIdTcpServerStatusContext(const aContext: TIdContext);
var
  lClientSession: TClientSession;
begin
  lClientSession := TObjectHelper.Cast<TClientSession>(aContext.Data);
...
end;

type
  TBaseDataInterface = class(TObject)
  strict private
    FDatabase:      TIBDatabase;
    FTransaction:   TIBTransaction;
...
  end;


destructor TBaseDataInterface.Destroy();
begin
  TObjectHelper.FreeAndNil(FDatabase);
  TObjectHelper.FreeAndNil(FTransaction);
...
  inherited Destroy();
end;

And the implementation.

unit ObjectHelperUnit;

interface

type
  TObjectHelper = record
    class function Cast<T: class>(const aValue: TObject): T; static;
    class procedure FreeAndNil<T: class>(var Value: T); static;
  end;

implementation

uses
  System.SysConst,
  System.SysUtils;

class function TObjectHelper.Cast<T>(const aValue: TObject): T;
var
  lException: Exception;
begin
  if Assigned(aValue) then
  begin
    if aValue is T then
      Result := T(aValue)
    else
    begin
      lException := EInvalidCast.CreateFmt('%s; actual type %s but expected %s.',
        [SInvalidCast, aValue.QualifiedClassName, T.QualifiedClassName]);
      raise lException;
    end;
  end
  else
    Result := nil;
end;

class procedure TObjectHelper.FreeAndNil<T>(var Value: T);
begin
  System.SysUtils.FreeAndNil(Value);
end;

end.

–jeroen

Gist:


unit ObjectHelperUnit;
interface
type
TObjectHelper = record
class function Cast<T: class>(const aValue: TObject): T; static;
class procedure FreeAndNil<T: class>(var Value: T); static;
end;
implementation
uses
System.SysConst,
System.SysUtils;
class function TObjectHelper.Cast<T>(const aValue: TObject): T;
var
lException: Exception;
begin
if Assigned(aValue) then
begin
if aValue is T then
Result := T(aValue)
else
begin
lException := EInvalidCast.CreateFmt('%s; actual type %s but expected %s.',
[SInvalidCast, aValue.QualifiedClassName, T.QualifiedClassName]);
raise lException at ReturnAddress;
end;
end
else
Result := nil;
end;
class procedure TObjectHelper.FreeAndNil<T>(var Value: T);
begin
System.SysUtils.FreeAndNil(Value);
end;
end.


procedure TMyServer.UnbindFromIdTcpServerStatusContext(const aContext: TIdContext);
var
lClientSession: TClientSession;
begin
lClientSession := TObjectHelper.Cast<TClientSession>(aContext.Data);
end;
type
TBaseDataInterface = class(TObject)
strict private
FDatabase: TIBDatabase;
FTransaction: TIBTransaction;
end;
destructor TBaseDataInterface.Destroy();
begin
TObjectHelper.FreeAndNil(FDatabase);
TObjectHelper.FreeAndNil(FTransaction);
inherited Destroy();
end;

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

tcp – How can I trigger a script when a certain port becomes available for requests? – Unix & Linux Stack Exchange

Posted by jpluimers on 2018/10/09

Netcat to the rescue waiting for a Windows 10 upgrade to finish (which can take hours):

while ! nc -z 172.22.0.67 3389; do echo "sleeping"; sleep 10; done; echo 'The server is up!'

Via: [WayBacktcp – How can I trigger a script when a certain port becomes available for requests? – Unix & Linux Stack Exchange, quoting from the answer:

  • nc is Netcat, “the Swiss-army knife for TCP/IP”,
  • -z means: do not send any data, just check if the port is open,
  • while ! nc -z …; do sleep 0.1; done: keep checking and sleeping for one tenth of a second until the port opens up, i.e. Netcat returns with a zero (success) status.

–jeroen

Posted in *nix, *nix-tools, Communications Development, Development, Internet protocol suite, Power User, TCP, Windows | Leave a Comment »

Giving up on the official Ubuntu for Odroid C1 image

Posted by jpluimers on 2018/10/09

After the trouble in Ubuntu: Fixing the myserious “Failed to stop apt-daily.timer: Connection timed out” I got into more trouble:
apt-get update && apt-get upgrade hung the device.

It booted fine, but a new update showed it was in a hosed state.

I don’t expect vendor supported distributions to fail this way, so I gave up on the ubuntu-16.04-minimal-odroid-c1-20160817.img.xz .

–jeroen


root@odroidC1:~# apt-get update && apt-get upgrade
Hit:1 http://ports.ubuntu.com/ubuntu-ports xenial InRelease
Hit:2 http://ports.ubuntu.com/ubuntu-ports xenial-updates InRelease
Hit:3 http://ports.ubuntu.com/ubuntu-ports xenial-backports InRelease
Hit:4 http://ports.ubuntu.com/ubuntu-ports xenial-security InRelease
Hit:5 http://deb.odroid.in/c1 xenial InRelease
Reading package lists… Done
E: dpkg was interrupted, you must manually run 'dpkg –configure -a' to correct the problem.
root@odroidC1:~# dpkg –configure -a
Processing triggers for ureadahead (0.100.0-19) …
Setting up initramfs-tools (0.122ubuntu8.8) …
update-initramfs: deferring update (trigger activated)
Processing triggers for systemd (229-4ubuntu17) …
Processing triggers for initramfs-tools (0.122ubuntu8.8) …
update-initramfs: Generating /boot/initrd.img-4.4.0-28-generic
WARNING: missing /lib/modules/4.4.0-28-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/4.4.0-28-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_FQEGW2/lib/modules/4.4.0-28-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_FQEGW2/lib/modules/4.4.0-28-generic/modules.builtin: No such file or directory
root@odroidC1:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 396M 0 396M 0% /dev
tmpfs 81M 3.3M 78M 5% /run
/dev/mmcblk0p2 59G 1.1G 55G 2% /
tmpfs 403M 0 403M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 403M 0 403M 0% /sys/fs/cgroup
/dev/mmcblk0p1 128M 11M 118M 9% /media/boot

Posted in Development, Hardware Development, Odroid | 3 Comments »

A Key’s Odyssey – the path of a keystroke message through the VCL

Posted by jpluimers on 2018/10/09

Blast from the past, but still relevant, this article by Peter Below:

This article follows the path of a keystroke message through the VCL. You will learn how the key processing is implemented, how the OnKey events work and what intervention points for the programmer can be found in the whole process. In addition, things like message processing are explained, and you will learn how to trace messages in the debugger from the message loop to their eventual destination.

Source: [WayBackA Key’s Odyssey

Via: [WayBack] Vcl.Controls.pasprocedure TWinControl.CNKeyDown(var Message: TWMKeyDown);..if IsMenuKey(Message) then Exit; … – Attila Kovacs – Google+

-jeroen

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

Check If A Linux System Is Physical Or Virtual Machine

Posted by jpluimers on 2018/10/08

One day I am going to try to extend this for a few other virtualisation environments and Linux distributions: [WayBack] Check If A Linux System Is Physical Or Virtual Machine

Via: [WayBack] Check If A Linux System Is Physical Or Virtual Machine #Linux – Joe C. Hecht – Google+

–jeroen

Posted in *nix, *nix-tools, Fusion, Hyper-V, KVM Kernel-based Virtual Machine, Power User, Proxmox, View, VirtualBox, Virtualization, VMware, VMware ESXi, VMware Workstation | Leave a Comment »

Video Conversion done right: Codecs and Software – Super User Blog

Posted by jpluimers on 2018/10/08

From a very long time ago, but still a great references: [WayBackVideo Conversion done right: Codecs and Software – Super User Blog.

Read the rest of this entry »

Posted in Audio, ffmpeg, Media, Power User, Video | Leave a Comment »

Seven Steps to the Diagnosis of NSAIDs Hypersensitivity: How to Apply a New Classification in Real Practice?

Posted by jpluimers on 2018/10/08

For Ibuprofen, I have type B, but need to figure out how severe and which subcategory then find out if I’m also affected by other NSAIDs.

[WayBackSeven Steps to the Diagnosis of NSAIDs Hypersensitivity: How to Apply a New Classification in Real Practice?

Tables and figures:

Via: [WayBack李麟 – Google+ commenting at [WayBack] This shirt on one of my fellow archers today… “Sons of Ibuprofen” – Lars Fosdal – Google+

–jeroen

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

Why Youtube’s algorithms push extreme content on every possible subject / Boing Boing

Posted by jpluimers on 2018/10/05

Food for thought: [WayBack] Why Youtube’s algorithms push extreme content on every possible subject / Boing Boing.

the problems of Youtube’s recommender algorithms might be that they overdistil your preferences. Since they’re aiming for “engagement” — a word I am beginning to loathe with an unsettling level of emotion — the real problem with these algorithms is they’re constantly aiming to create an epic sense of drama and newness

More in depth at [WayBackOpinion | YouTube, the Great Radicalizer – The New York Times

Via [WayBack] Kristian Köhntopp – Google+.

–jeroen

Posted in Power User, SocialMedia, YouTube | Leave a Comment »

macOS / OS X / Mac OS X: excessive sysmond or mds CPU usage – via Ask Different and osXdaily

Posted by jpluimers on 2018/10/05

If you suffer from [WayBack] macos – Excessive CPU usage from sysmond – Ask Different, then it could be Activity Monitor itself using that CPU.

If you suffer from high CPU usage in mds, then it is likely the Spotlight search indexer acting up: [WayBack] mds – what MDS process is and why it uses CPU on the Mac

–jeroen

Posted in Apple, Mac, Mac OS X / OS X / MacOS, Power User, SpotLight | Leave a Comment »