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

All buildings in Amsterdam and the Netherlands, shaded by year of construction

Posted by jpluimers on 2017/09/25

Via Kristian Köhntopp – Google+ [WayBack]

–jeroen

Posted in LifeHacker, Power User | Leave a Comment »

Can I invoke Windows Update from the command line? – Super User

Posted by jpluimers on 2017/09/25

For my link archive: Can I invoke Windows Update from the command line? – Super User [WayBack]

–jeroen

Posted in Power User, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows 9, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, Windows Vista, Windows XP | Leave a Comment »

Looking for more examples of Unicode/Ansi oddities in Delphi 2009+

Posted by jpluimers on 2017/09/25

At the end of April 2014, Roman Yankovsky started a nice [Wayback] discussion on Google+ trying to get upvotes for [Wayback] QualityCentral Report #:  124402: Compiler bug when comparing chars.

His report basically comes down to that when using Ansi character literals like #255, the compiler treats them as single-byte encoded characters in the current code page of your Windows context, translates them to Unicode, then processes them.

The QC report has been dismissed as “Test Case Error” (within 15 minutes of stating “need more info”) by one of the compiler engineers, directing to the [Wayback] UsingCharacterLiterals section of Delphi in a Unicode World Part III: Unicodifying Your Code where – heaven forbid – they suggest to replace with the Euro-Sign literal.

I disagree, as the issue happens without any hint or warning whatsoever, and causes code that compiles fine in Delphi <= 2007 to fail in subtle ways on Delphi >= 2009.

The compiler should issue a hint or warning when you potentially can screw up. It doesn’t. Not here.

Quite a few knowledgeable Delphi people got involved in the discussion:

Read the rest of this entry »

Posted in Ansi, ASCII, Conference Topics, Conferences, CP437/OEM 437/PC-8, Delphi, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Development, Encoding, Event, ISO-8859, Missed Schedule, QC, SocialMedia, Software Development, Unicode, UTF-8, Windows-1252, WordPress | Leave a Comment »

Permanently Disable & Prevent Automatic Restart of Windows Update in Windows 10 – Tech Journey

Posted by jpluimers on 2017/09/22

Yay!

Windows 10 automatically restart the PC whenever it installed updates that required a mandatory reboot in order to finish installed. User can no longer delay or postpone a restart indefinitely. […]

The source Permanently Disable & Prevent Automatic Restart of Windows Update in Windows 10 – Tech Journey [WayBack] describes steps to fix a bunch of scenarios:

  • Disable Reboot Task
  • Stop the re-enabling of Reboot task
  • Group Policy (but people reported that Windows 10 ignores the policy when comes to mandatory reboot required for installing updates)
  • Prevent Updates from Installing by forcing your WiFi to act like a “metered” connection
  • Prevent Updates from Installing by setting the Configure Automatic Updates setting in your Local Group Policy Editor
    • For Windows 10 Home edition (that misses the Local Group Policy Editor) setting the above value directly in the registry

–jeroen

via: How to prevent Windows10 from automatically installing updates & rebooting – Primož Gabrijelčič – Google+ [WayBack]

Posted in Power User, Windows, Windows 10 | 2 Comments »

How to Configure and Manage Network Connections Using ‘nmcli’ Tool

Posted by jpluimers on 2017/09/22

Via “In the form over function era: Using Network Manager from the command line” [WayBack]:

As a Linux administrator you’ve got various tools to use in order to configure network connections, such as: nmtui, NetworkManager GUI and nmcli in Linux

Source: How to Configure and Manage Network Connections Using ‘nmcli’ Tool [WayBack]

–jeroen

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

Don’t Use Regular Expressions To Parse IP Addresses!

Posted by jpluimers on 2017/09/21

Interesting piece: Don’t Use Regular Expressions To Parse IP Addresses! [WayBack]

TL;DR:

When have neither then for quad-dotted decimal IPv4 addresses (ignoring for instance octals and grouped quads), this is suitable: regex – Regular expression to match DNS hostname or IP Address? – Stack Overflow [WayBack]

ValidIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";

Which explained looks like this:

https://regex101.com/r/Wyr2Zd/1

Regular expression:

/ ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ / g

Explanation:

  • ^ asserts position at start of the string
    • 1st Capturing Group (([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}
      • {3} Quantifier — Matches exactly 3 times
        A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you’re not interested in the data

        • 2nd Capturing Group ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])
          • 1st Alternative [0-9]
            • Match a single character present in the list below [0-9]
              0-9 a single character in the range between 0 (ASCII 48) and 9 (ASCII 57) (case sensitive)
          • 2nd Alternative [1-9][0-9]
            • Match a single character present in the list below [1-9]
              1-9 a single character in the range between 1 (ASCII 49) and 9 (ASCII 57) (case sensitive)
            • Match a single character present in the list below [0-9]
              0-9 a single character in the range between 0 (ASCII 48) and 9 (ASCII 57) (case sensitive)
          • 3rd Alternative 1[0-9]{2}
            • 1 matches the character 1 literally (case sensitive)
            • Match a single character present in the list below [0-9]{2}
              {2} Quantifier — Matches exactly 2 times
              0-9 a single character in the range between 0 (ASCII 48) and 9 (ASCII 57) (case sensitive)
          • 4th Alternative 2[0-4][0-9]
            • 2 matches the character 2 literally (case sensitive)
            • Match a single character present in the list below [0-4]
              0-4 a single character in the range between 0 (ASCII 48) and 4 (ASCII 52) (case sensitive)
            • Match a single character present in the list below [0-9]
              0-9 a single character in the range between 0 (ASCII 48) and 9 (ASCII 57) (case sensitive)
          • 5th Alternative 25[0-5]
            • 25 matches the characters 25 literally (case sensitive)
            • Match a single character present in the list below [0-5]
              0-5 a single character in the range between 0 (ASCII 48) and 5 (ASCII 53) (case sensitive)
        • \. matches the character . literally (case sensitive)
    • 3rd Capturing Group ([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])
      • 1st Alternative [0-9]
        • Match a single character present in the list below [0-9]
          0-9 a single character in the range between 0 (ASCII 48) and 9 (ASCII 57) (case sensitive)
      • 2nd Alternative [1-9][0-9]
        • Match a single character present in the list below [1-9]
          1-9 a single character in the range between 1 (ASCII 49) and 9 (ASCII 57) (case sensitive)
        • Match a single character present in the list below [0-9]
          0-9 a single character in the range between 0 (ASCII 48) and 9 (ASCII 57) (case sensitive)
      • 3rd Alternative 1[0-9]{2}
        • 1 matches the character 1 literally (case sensitive)
        • Match a single character present in the list below [0-9]{2}
          {2} Quantifier — Matches exactly 2 times
          0-9 a single character in the range between 0 (ASCII 48) and 9 (ASCII 57) (case sensitive)
      • 4th Alternative 2[0-4][0-9]
        • 2 matches the character 2 literally (case sensitive)
        • Match a single character present in the list below [0-4]
          0-4 a single character in the range between 0 (ASCII 48) and 4 (ASCII 52) (case sensitive)
        • Match a single character present in the list below [0-9]
          0-9 a single character in the range between 0 (ASCII 48) and 9 (ASCII 57) (case sensitive)
      • 5th Alternative 25[0-5]
        • 25 matches the characters 25 literally (case sensitive)
        • Match a single character present in the list below [0-5]
          0-5 a single character in the range between 0 (ASCII 48) and 5 (ASCII 53) (case sensitive)
  • $ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
  • Global pattern flags
    g modifier: global. All matches (don’t return after first match)

–jeroen

Posted in *nix, Communications Development, Development, Internet protocol suite, Network-and-equipment, Power User, Software Development, TCP | Leave a Comment »

Mikrotik functions -> hopefully I can translate this to the new syntax

Posted by jpluimers on 2017/09/21

Reminder to self as it would be useful to have these Mikrotik functions in the new function syntax:

–jeroen

Posted in Internet, MikroTik, Power User, routers | Leave a Comment »

What Does Ruby’s Array#shift do? – Stack Overflow

Posted by jpluimers on 2017/09/20

Once you learn that shift/unshift are like push/pop on the other end of the array, you can mentally drop the ‘f’ from the name of the methods to remember which one ‘dumps’ elements and which one ‘inserts’ them. :)

Source: What Does Ruby’s Array#shift do? – Stack Overflow [WayBack]

Via: Originally shared by This is why I Code

 

Posted in Development, Fun, Ruby, Software Development | Leave a Comment »

Dependency Analysis – Pascal Today

Posted by jpluimers on 2017/09/20

Tools and steps for analysing Delphi or FreePascal code: Dependency Analysis – Pascal Today [WayBack]

Used tools:

–jeroen

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

delphi – Is AtomicCmpExchange reliable on all platforms? – Stack Overflow

Posted by jpluimers on 2017/09/19

TL;DR: yes it is.

Answer by Allen Bauer at delphi – Is AtomicCmpExchange reliable on all platforms? – Stack Overflow [WayBack]

On Windows, it directly translates into lock cmpxchg which is way faster than the Windows API call [WayBackInterlockedCompareExchange, as that is a jump to the actual code:

InterlockedCompareExchange:
00417CA8 FF2528E12901     jmp dword ptr [$0129e128]
KERNEL32.InterlockedCompareExchange:
75855E40 8BFF             mov edi,edi
75855E42 55               push ebp
75855E43 8BEC             mov ebp,esp
75855E45 8B550C           mov edx,[ebp+$0c]
75855E48 8B4D08           mov ecx,[ebp+$08]
75855E4B 8B4510           mov eax,[ebp+$10]
75855E4E F00FB111         lock cmpxchg [ecx],edx
75855E52 5D               pop ebp
75855E53 C20C00           ret $000c

whereas AtomicCmdExchange looks like this:

Test.pas.20: RestoreValue := AtomicCmpExchange(FieldToBeModfied, 1 {new value}, 0 {expected value}, Success {true if the expected value was found, and new value set});
0111A838 8B45FC           mov eax,[ebp-$04]
0111A83B 8D500C           lea edx,[eax+$0c]
0111A83E 33C0             xor eax,eax
0111A840 B901000000       mov ecx,$00000001
0111A845 F00FB10A         lock cmpxchg [edx],ecx
0111A849 0F9445F2         setz byte ptr [ebp-$0e]
0111A84D 8945D8           mov [ebp-$28],eax

–jeroen

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