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 2016

Some notes on modifying NIB files on Mac OS X to add/change shortcuts

Posted by jpluimers on 2016/10/19

One of the nitpicks in VMware Fusion is that it has no keyboard shortcut for Resume or Suspend. I was trying to add Command-R and Command-S for those but that didn’t work out.

Since the links below seem to work for some other applications, I’ve kept them:

–jeroen

Posted in Apple, Development, Keyboards and Keyboard Shortcuts, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, MacMini, OS X 10.10 Yosemite, OS X 10.11 El Capitan, OS X 10.9 Mavericks, Power User, Software Development | Leave a Comment »

Loading your MAINICON and VersionInfo through plain text .RC resource files.

Posted by jpluimers on 2016/10/19

I like repositories to have as much of the information in text format.

Delphi traditionally puts both the MAINICON and the VersionInfo resources in a binary .res file and also updates that file on almost every recompile.

There are quite a few posts explaining how to get them from text, but a version controlled example works best for me, so there is one at https://github.com/jpluimers/atom-table-monitor/blob/master/ATOMScannerConsole

The trick is to:

  1. put your resources in a text RC file that can be compiled through a resource compiler
  2. add these to your Delphi project via the project manager, so it generated RcCompile elements which instructs the build process to run the resource compiler first:


<RcCompile Include="MAINICON.rc">
<ModuleName>MAINICON.rc</ModuleName>
<Form>MAINICON.res</Form>
</RcCompile>
<RcCompile Include="VERSIONINFO.rc">
<ModuleName>VERSIONINFO.rc</ModuleName>
<Form>VERSIONINFO.res</Form>
</RcCompile>

Here are the example files:

Read the rest of this entry »

Posted in Delphi, Delphi 10 Seattle, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, QC, Software Development | 2 Comments »

IMPLICITBUILDING in your .dpk files: a Delphi XE2 specific thing

Posted by jpluimers on 2016/10/18

While upgrading a truckload of Delphi stuff for a client, I came across the IMPLICITBUILDING directive in a few .dpk files that Delphi XE2 sometimes inserts but XE8 doesn’t.

This appears to be a Delphi XE2 specific thing that in younger Delphi versions has been solved properly SolarWind‘s answer on Stack Overflow:

 The compiler directives which appear between the $IFDEF IMPLICITBUILDING and $ENDIF are normally passed as parameters by the compiler when explicitly compiling a package. Because these options change based on the configuration (debug / release) and target platform (Win32, Win64, OSX32) it’s problematic to have them statically defined in the package project source. When defined in the project source they will always override the options passed by the compiler. The $IFDEF prevents these options from being used during explicit compilation.

Source: Delphi XE2: What is the purpose of IMPLICITBUILDING directive found in package – Stack Overflow

and comment by Andreas Hausladen:

That seems to be a workaround for the problem that compiling packages with the msbuild script ignored all dproj compiler options because they were read from the dpk file by the compiler.

Some more references (I’ve saved them in the WayBack machine as the forums auto-expire posts):

–jeroen

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

Multi-line comments in a bash shell script

Posted by jpluimers on 2016/10/18

I’m used to multiline comments in many languages, but since I don’t use bash very often, I only recently learned it can do that too.

So this is how to have comments span multiple lines in bash by using the : command which according to the bash man page does nothing:

: [arguments]
No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned.

So the syntax is:

: '
your comments here
'

–jeroen

via: Shell Script Put Multiple Line Comment.

Posted in bash, Development, Scripting, Software Development | Leave a Comment »

When a PC lost its trust relationship with a domain controller: “The trust relationship between this workstation and the primary domain failed”

Posted by jpluimers on 2016/10/17

(Don’t ask for details; at a site with Microsoft Data Protection Manager an external company monitoring that DPM didn’t notice various backups – including the domain controller – were months old despite daily tape changes; so then the RAID fell out because multiple disks failed within hours, contingency aftermath took weeks)

When you logon to a client machine and get “The trust relationship between this workstation and the primary domain failed”

  1. do not rejoin your client machine to the domain
  2. ensure on the client machine:
    1. you can logon without a domain account (part of any contingency plan should be logging in with a local account or without a domain controller if you have the – potential risky – cached domain logon enabled, otherwise you’ve to do more nasty measures)
    2. you have PowerShell v3 or later on the client machine
  3. on the client machine
    1. Ensure it’s connected to the same network as the domain controller
    2. Ensure you can ping the domain controller
    3. Test with Powershell Test-ComputerSecureChannel to see if the connection is indeed lost:
      1. if it returns True then you have a different problem (have not seen this, but just in case: this blog post won’t solve that)
      2. if it returns False, then continue with the next step
    4. Run Powershell Test-ComputerSecureChannel -Repair and check if the output is True (when False there )

Note there are various posts suggesting to use Powershell Reset-ComputerMachinePassword and netdom.exe resetpwd /s:dc-hostname.domain /ud:domainadminusername /pd:*. Though faster than rejoining the domain, the Powershell Test-ComputerSecureChannel is even faster and easier.

–jeroen

via:

Posted in Power User, Windows | Leave a Comment »

VMware ESXi – converting a thick disk to a thin disk – via: Server Fault

Posted by jpluimers on 2016/10/17

There are various places that tell you you cannot resize a thick disk to a thin disk using vmkfstools.

When you do it wrong, you get this error:

DiskLib_Check() failed for source disk. The file specified is not a virtual disk (15).

This happens when you directly try to resize the physical disk image:

# vmkfstools --clonevirtualdisk msmxp-flat.vmdk --diskformat thin msmxp-flat.thin.vmdk
DiskLib_Check() failed for source disk The file specified is not a virtual disk (15).

Whereas you should point vmkfstools to the disk descriptor file which has the shortest name:

# vmkfstools --clonevirtualdisk msmxp.vmdk --diskformat thin msmxp.thin.vmdk
Destination disk format: VMFS thin-provisioned
Cloning disk 'msmxp.vmdk'...
Clone: 100% done.

(Note that many people shorten the --clonevirtualdisk to -i and --diskformat to -d).

For performance, it doesn’t matter much if your disk is thick or thin as explained by Death to false myths: The type of virtual disk used determines your performance.

But various people issues expanding a thick disk. With thin disks, that usually works fine.

This post explains the correct steps of resizing: VMWare ESXi 5.1–convert virtual disk (vmdk) from thick to thin provision.

Here is a summary:

Step zero: shutdown the VM and ensure you have a backup!

For instance with rsync is great for making a local backup:

# time ./850EVO1TBR1B/bin/rsync -aiv --info=progress2 --progress ./850EVO1TBR1B/Raid6SSD-VM/msmxp/ ./850EVO1TBR1A/Raid6SSD-VM/msmxp/

Step one: show the disk files:

/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # du -h *.vmdk
12.0G   msmxp-flat.vmdk
0   msmxp.vmdk

There are two: msmxp.vmdk describes the disk and msmxp-flat.vmdk has the data.

Step two: ensure you have enough free space on the volume:

# ls -al /vmfs/volumes | grep "552f5788-33e30274-8dba-001f29022aed"
drwxr-xr-t    1 root     root          2660 Aug  5 04:35 552f5788-33e30274-8dba-001f29022aed
lrwxr-xr-x    1 root     root            35 Aug  5 06:11 850EVO1TBR1B -> 552f5788-33e30274-8dba-001f29022aed
# df -h | grep "850EVO1TBR1B\|Use%"
Filesystem   Size   Used Available Use% Mounted on
VMFS-5     930.8G 736.8G    194.0G  79% /vmfs/volumes/850EVO1TBR1B

Convert the disk:

# vmkfstools --clonevirtualdisk msmxp.vmdk --diskformat thin msmxp.thin.vmdk
Destination disk format: VMFS thin-provisioned
Cloning disk 'msmxp.vmdk'...
Clone: 100% done.

Observe the size:

In my case the flat disk was almost full and fragmented, so the thin disk is not smaller:

/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # du -h *.vmdk
12.0G   msmxp-flat.vmdk
12.0G   msmxp.thin-flat.vmdk
0   msmxp.thin.vmdk
0   msmxp.vmdk

Rename both disks

Use vmkfstools (do not use mv as that will not keep the descriptor/data vmdk files bound together) and check the rename.

You can replace --renamevirtualdisk with -E:

/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools --renamevirtualdisk msmxp.thin.vmdk msmxp.vmdk
## /vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools -E msmxp.vmdk msmxp.thick.vmdk
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # du -h *.vmdk
12.0G   msmxp-flat.vmdk
12.0G   msmxp.thick-flat.vmdk
0   msmxp.thick.vmdk
0   msmxp.vmdk

Turn on the Virtual Machine to verify it still works.

If it does, then delete it (you can replace --deletevirtualdisk with -U) which will remove both both the descriptor and data vmdk file:

/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools --deletevirtualdisk msmxp.vmdk 
## /vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools -U msmxp.vmdk 
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # du -h *.vmdk
12.0G   msmxp-flat.vmdk
0   msmxp.vmdk

After shutting down the VM again and making a new backup, you can now expand the disk as described in VMware KB: Adding space to an ESXi/ESX host virtual disk.

You can replace --extendvirtualdisk with -X.

/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools --extendvirtualdisk 14G msmxp.vmdk 
## /vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools -X 14G msmxp.vmdk 
Grow: 100% done.
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # du -h *.vmdk
12.0G   msmxp-flat.vmdk
0   msmxp.vmdk


/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools --renamevirtualdisk msmxp.vmdk msmxp.thick.vmdk
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools --clonevirtualdisk msmxp.thick.vmdk msmxp.vmdk --diskformat thin
Destination disk format: VMFS thin-provisioned
Cloning disk 'msmxp.thick.vmdk'...
Clone: 100% done.
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # diff msmxp.thick.vmdk msmxp.vmdk
--- msmxp.thick.vmdk
+++ msmxp.vmdk
@@ -7,18 +7,18 @@
 createType="vmfs"
 
 # Extent description
-RW 29360128 VMFS "msmxp.thick-flat.vmdk"
+RW 29360128 VMFS "msmxp-flat.vmdk"
 
 # The Disk Data Base 
 #DDB
 
-ddb.adapterType = "ide"
-ddb.thinProvisioned = "1"
-ddb.geometry.sectors = "63"
-ddb.geometry.heads = "16"
-ddb.geometry.cylinders = "29127"
-ddb.uuid = "60 00 C2 9f 5e f8 33 76-6e c5 48 3c f2 84 d8 1e"
-ddb.longContentID = "5659579edebed2ebdd8e0c8fda15abd4"
 ddb.toolsVersion = "9221"
 ddb.virtualHWVersion = "8"
 ddb.deletable = "true"
+ddb.longContentID = "5659579edebed2ebdd8e0c8fda15abd4"
+ddb.uuid = "60 00 C2 95 66 1b cf 7a-e3 db 3f 30 17 7e 00 2d"
+ddb.geometry.cylinders = "29127"
+ddb.geometry.heads = "16"
+ddb.geometry.sectors = "63"
+ddb.thinProvisioned = "1"
+ddb.adapterType = "ide"
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # du -h *.vmdk
12.0G   msmxp-flat.vmdk
12.0G   msmxp.thick-flat.vmdk
0   msmxp.thick.vmdk
0   msmxp.vmdk
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools --extendvirtualdisk 14G msmxp.vmdk
Failed to extend disk : One of the parameters supplied is invalid (1).
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools --extendvirtualdisk 14G msmxp.vmdk
Failed to extend disk : One of the parameters supplied is invalid (1).
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools --extendvirtualdisk 14G msmxp.vmdk
Failed to extend disk : One of the parameters supplied is invalid (1).
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools --extendvirtualdisk 15G msmxp.vmdk
Grow: 100% done.
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # du -h *.vmdk
12.0G   msmxp-flat.vmdk
12.0G   msmxp.thick-flat.vmdk
0   msmxp.thick.vmdk
0   msmxp.vmdk
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # vmkfstools --deletevirtualdisk msmxp.thick.vmdk 
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # du -h *.vmdk
12.0G   msmxp-flat.vmdk
0   msmxp.vmdk
/vmfs/volumes/552f5788-33e30274-8dba-001f29022aed/Raid6SSD-VM/msmxp # 

–jeroen

via: vmware esxi – vmkfstools returns error when trying to copy thin vmdk – Server Fault.

Posted in ESXi4, ESXi5, ESXi5.1, ESXi5.5, ESXi6, Power User, Virtualization, VMware, VMware ESXi | Leave a Comment »

OK Google – all you can ask Google

Posted by jpluimers on 2016/10/14

An interactive list of over 150 commands and 1000 variations that you can ask Google’s voice assistant. Made by @thekitze

Source: OK Google

Via: Amazing site lists nearly every ‘OK Google’ voice command

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

datetime – Round time to nearest 15min interval in Excel – Stack Overflow

Posted by jpluimers on 2016/10/14

Easy, but I always forget:

= (ROUND((A1 * 1440) / 15, 0) * 15) / 1440

Thanks David for answering.

–jeroen

via datetime – Round time to nearest 15min interval in Excel – Stack Overflow.

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

letsenctrypt certbot-auto – finding what certificates are there and which apache configurations use them

Posted by jpluimers on 2016/10/13

IRC #letsencrypt-dev today:

wiert

Is there any way for `certbot-auto` to show for which domains/apache-configs it has certificates?

pdeee

wiert, we actually made a ticket for 0.10.0 to do that

https://github.com/certbot/certbot/issues/3615

in the mean time, your imperfect options are:

for file in /etc/letsencrypt/live/*/fullchain.pem ; do echo -n $file ;  openssl x509 -text -noout -in $file | grep DNS; done

for installation in Apache configs, you can follow that with:

grep /etc/letsencrypt/live /etc/apache2/sites-enabled/*

wiert

@pdeee on OpenSuSE, the last statement should be

grep -r /etc/letsencrypt/live /etc/apache2/*

–jeroen

Posted in *nix, Encryption, Let's Encrypt (letsencrypt/certbot), Linux, openSuSE, Power User, Security, SuSE Linux | Leave a Comment »

Differences between SFTP and “FTP over SSH” – Stack Overflow

Posted by jpluimers on 2016/10/13

As I will likely have to secure some external FTP sessions soon and the endpoints the current FTP connects to are vague in what they support:

Here is the difference:

  • SFTP (SSH file transfer protocol) is a protocol that provides file transfer and manipulation capabilities. It can work over any reliable data stream, but is typically used with SSH
  • “FTP over SSH” uses the regular old FTP protocol, but an SSH tunnel is placed between client and server.

Source: Kristopher Johnson answering in c# – Differences between SFTP and “FTP over SSH” – Stack Overflow

–jeroen

Posted in Communications Development, Development, Internet protocol suite, Software Development, SSH, TCP, TLS | Leave a Comment »