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

Archive for the ‘Scripting’ Category

Learn How To Debug JavaScript with Chrome DevTools – codeburst

Posted by jpluimers on 2020/10/06

Long read for later: [WayBack] Learn How To Debug JavaScript with Chrome DevTools – codeburst

Ditch console.log debugging once and for all! Learn how to use breakpoints to debug code within the Chrome Developer Tools

Via: [WayBack] Learn How To Debug JavaScript with Chrome DevTools… – Lars Fosdal – Google+

–jeroen

Posted in Chrome, Development, Google, JavaScript/ECMAScript, Power User, Scripting, Software Development | Leave a Comment »

Go character and string literals: regular (‘), double (“) and back-tick (`) quotes

Posted by jpluimers on 2020/10/01

For my link archive:

Back-ticks can be very useful for instance when you need to specifying json tags.

References for that:

–jeroen

Posted in Development, Encoding, Go (golang), JavaScript/ECMAScript, JSON, Scripting, Software Development | Leave a Comment »

bash – convert comma separated values into a list of values using shell script – Stack Overflow

Posted by jpluimers on 2020/09/07

For a simple comma separated list (no quotes), I was expecting a sed script (and indeed it is possible), but tr is more elegant:

Use tr to change , into newlines:

tr , "\n" < list.txt

See https://en.wikipedia.org/wiki/Tr_(Unix)

Source: [WayBack] bash – convert comma separated values into a list of values using shell script – Stack Overflow.

–jeroen

Posted in *nix, *nix-tools, bash, bash, Development, Power User, Scripting, Software Development | Leave a Comment »

find – display only files starting with . (hidden) – Unix & Linux Stack Exchange

Posted by jpluimers on 2020/08/21

find . -type f -name '\.*' -print

Must work if you want list every hidden file down in the directory hierarchy.

This sort of works on Linux, but fails on VMware ESXi (on Linux it only works when applying -maxdepth 1, deeper levels fails because they list all files where the top directory starts with a .):

If you want hidden files and hidden directories, without . and .. :

find -regex '\./\..+' -print

This works on both Linux and VMware ESXi:

If you want hidden files and hidden directories, without . and .. :

find . \( -type f -o -type d \) -name '\.*' -print

Based on:

–jeroen

Posted in *nix, *nix-tools, bash, bash, Development, Power User, Scripting, Software Development | Leave a Comment »

windows – Batch-file: undocumented wild card characters to check for file pattern existence – Stack Overflow

Posted by jpluimers on 2020/08/19

I wish I had known these undocumented wildcards exists like two decades ago: [WayBackwindows – Batch-file: Check if file with pattern exist – Stack Overflow, thanks Squashman:

There are undocumented wildcards that you can use to achieve this as well.

IF EXIST "D:\*Backup*.<" (
   ECHO "file exist"
) ELSE (
   ECHO "file not exist"
)

This wildcard option and other were discussed in length at the following two links.

From those links:

The following wildcard characters can be used in the pattern string.

Wildcard character  Meaning

* (asterisk)
Matches zero or more characters

? (question mark)
Matches a single character

" 
Matches either a period or zero characters beyond the name string

>
Matches any single character or, upon encountering a period or end of name string, advances the expression to the end of the set of contiguous >

<
Matches zero or more characters until encountering and matching the final . in the name

–jeroen

Posted in Batch-Files, Development, Scripting, Software Development | Leave a Comment »

Nick Hodges on SOLID in TypeScript using Angular

Posted by jpluimers on 2020/08/18

For my link archive: after a long history of Delphi programming, Nick Hodges did a

SOLID series with TypeScript using Angular

They explain these SOLID – Wikipedia concepts:

  1. Single responsibility principle – Wikipedia
  2. Open–closed principle – Wikipedia
  3. Liskov substitution principle – Wikipedia
  4. Interface segregation principle – Wikipedia
  5. Dependency inversion principle – Wikipedia

After that, he did a series on:

[WayBack] Angular 101 – Angles and Types

More Angular and TypeScript

Since Nick likes that combination so much:

and his TypeScript series start:

and what started as a trilogy in 5 parts of his [WayBack] Angular 101 – Angles and Types became much longer:

Related:

DIID update

Nick also updated the public repository with the changes that did make it in his Dependency injection in Delphi book earlier:

–jeroen

Read the rest of this entry »

Posted in Design Patterns, Development, Scripting, Software Development, TypeScript | Leave a Comment »

PowerShell: checking minimum version

Posted by jpluimers on 2020/08/13

Nowadays, often your PowerShell code uses features unavailable in older PowerShell versions. When running it on a version that is too old, you usually get an error message, for instance like this:

Unable to find type [Ordered]: make sure that the assembly containing this type is loaded.

Back in the days, this was a new feature introduced in PowerShell 3.0: [WayBack] Use cases of [ordered], the new PowerShell 3.0 feature – Stack Overflow

It is way friendlier to show a message indicating the version is too old in stead of throwing this error.

That’s where the # Requires Version 3.0 directive comes in: [WayBackabout_Requires | Microsoft Docs.

Adding this line to the top of a script gives output like this on a stock Windows 7 SP1 system that has PowerShell 2.0:

# PowerShell -f List-Delphi-Installed-Packages.ps1
The script ‘List-Delphi-Installed-Packages.ps1’ cannot be run because it contained a “#requires” statement at line 1 for Windows PowerShell version 3.0. The version required by the script does not match the currently running version of Windows PowerShell version 2.0.
+ CategoryInfo : ResourceUnavailable: (List-Delphi-Installed-Packages.ps1:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ScriptRequiresUnmatchedPSVersion

Note that PowerShell 3.0 is also the minimum version for debugging it in Visual Studio Code (which means you do not have to use PowerShell ISE any more; it is still there , but so far behind as a development tool that many prefer Visual Studio Code):

–jeroen

Posted in CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »

PowerShell: finding WSD printer details enumerating through HKLM\SYSTEM\CurrentControlSet\Enum\SWD\DAFWSDProvider

Posted by jpluimers on 2020/08/13

WSD seems the way Microsoft Windows 8+ does printing, which makes it a lot harder to find the IP address of a printer, for instance to configure a Mac to print to it.

The key seems to be enumerating over HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\SWD\DAFWSDProvider.

Some links that should help me doing this:

–jeroen

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

Installing and updating Windows PowerShell – via Microsoft Docs

Posted by jpluimers on 2020/08/11

Since I keep forgetting that PowerShell is part of WMF (Windows Management Framework) and about the compatibility/installation matrix: [WayBack] Installing Windows PowerShell | Microsoft Docs:

The installation package for PowerShell comes inside a WMF installer. The version of the WMF installer matches the version of PowerShell; there’s no stand alone installer for Windows PowerShell.

If you need to update your existing version of PowerShell, in Windows, use the following table to locate the installer for the version of PowerShell you want to update to.

Windows PS 3.0 PS 4.0 PS 5.0 PS 5.1
Windows 10 (see Note1)
Windows Server 2016
installed
Windows 8.1
Windows Server 2012 R2
installed [WayBack] WMF 5.0 [WayBack] WMF 5.1
Windows 8
Windows Server 2012
installed [WayBack] WMF 4.0  [WayBack] WMF 5.0 [WayBack] WMF 5.1
Windows 7 SP1
Windows Server 2008 R2 SP1
[WayBack] WMF 3.0 [WayBack] WMF 4.0 [WayBack] WMF 5.0 [WayBack] WMF 5.1

To upgrade to WMF 5.0 from 4.0 you need to install .net 4.5 or later on your machine first. Then install WMF 5.0 RTM.

–jeroen

Posted in CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »

Brew reminder to self

Posted by jpluimers on 2020/08/05

From the update process:

==> Caveats
==> hub
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> python
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

You can install Python packages with
  pip3 install 
They will install into the site-package directory
  /usr/local/lib/python3.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> youtube-dl
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> mpv
zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> node
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

–jeroen

Posted in Apple, Development, Home brew / homebrew, Power User, Python, Scripting, Software Development | Leave a Comment »