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 2,095 other followers

Archive for the ‘Scripting’ Category

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 »

 
%d bloggers like this: