Friday, 20 December 2024

sed on FreeBSD file listing

sed can be used to modify a FreeBSD file listing with regular expressions, allowing you to convert an ls into a csv, for example.

Given a file listing like:

-rwxr-xr-x   1 Andrew.Potts  wheel   7417965 Apr 12  2023 Yoi.MOV

-rwxr-xr-x   1 Andrew.Potts  wheel  13536345 Apr 12  2023 Yondan Hands.mp4

-rwxr-xr-x   1 Andrew.Potts  wheel  11488336 Apr 12  2023 Zuki.mp4

You can create and test the regular expressions on Sed Tester: https://sed.js.org/

Note however, early versions of FreeBSD don't support characters like \s, \S or \d.
Instea you must use commands like [:alpha:]

ls -la | sed -E 's/^([-drwx\+]*)[[:space:]]+([0-9]+)[[:space:]]+([[:alpha:].]+)[[:space:]]+([[:alpha:]]+)[[:space:]]+([[:digit:]]+)[[:space:]]+([[:alpha:]]+[[:space:]]+[[:digit:]]+[[:space:]]+[[:digit:]]+)[[:space:]]+(.+)$/\7,\5,\6/p'



's/\(.* [A-Za-z]* [0-9]*\) \([0-9]*\) \([a-z|A-Z]* [0-9]* [0-9]*:[0-9]*\) \(.*\)/\4,\2,\3/'

 ls -la | sed -E 's/^([-drwx\+]*)[[:space:]]+([0-9]+)[[:space:]]+([[:alpha:].]+)(.+)$/\3/p'

Capture 

([-rwx]*)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\w+\s+\d+\s+\d+)\s+(.+)$

--regexp-extended --expression='s/^([-rwx]*)\s+([0-9]+)\s+(\S+)\s+(\S+)\s+([0-9]+)\s+(\S+\s+[0-9]+\s+[0-9]+)\s+(.+)$/\5,\6,\7/'





Tuesday, 30 July 2024

Outlook PWA opens email links in Edge

 I prefer Outlook Personal Web App (PWA) over the thick client.

The problem I was having was that clicking on a http link within an email opened Edge rather than my default Chrome.

I double-checked the default App settings in Windows 11 and everything was set to Chrome.

Sadly, the instructions for setting the browser in the Outlook thick client application do not apply to the Personal Web App. Even though you set it to "use the default browser" that setting is not respected in the PWA, nor can you set it in the PWA.


The solution is to actually set the PWA as a Chrome app, not an edge app. 

In Chrome, navigate to https://outlook.office.com/mail/.
The button to install it as a PWA is on the search bar. Click on that.



Saturday, 22 June 2024

Mounting an external FAT32 USB drive with FreeNAS

Mount the FAT32 disk

dmesg | grep da1
mkdir /mnt/usbhdd
mount_msdosfs -o large /dev/da1s1/ /mnt/usbhdd

rsync -recursive --ignore-existing --human-readable --progress "/mnt/usbhdd/Matthew Potts iPhone 12 Photo Backup/" "/mnt/Data/My Media/Matthew/Photo Backup/"

To copy a file pattern:

rsync --include='**/*.MOV' -recursive --ignore-existing --human-readable --progress "/mnt/usbhdd/Matthew Potts iPhone 12 Photo Backup/" "/mnt/Data/My Media/Matthew/Photo Backup/"

To count files:

find . -maxdepth 1 -type f -print | wc -l

Tuesday, 11 June 2024

Syntax Highlighter

 https://github.com/syntaxhighlighter/syntaxhighlighter/wiki/Brushes-and-Themes#official-brushes

Monday, 10 June 2024

Syncing Files from Mac iOS to Freenas

Pre-requisites

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install sshpass

brew install sshpass

Synchronisation

rsync -av -e 'sshpass -p <password> ssh -oHostKeyAlgorithms=+ssh-dss root@freenas' ./* <destFolder>

FreeBSD utility commands

list the number of files in the directory

ls -1 | wc -l

Display the subfolder usage

du -h

Recursively find files with the name

find . -name IMG_0003.JPG

Thursday, 28 March 2024

Audio mutes when you switch devices in Windows 11

 -Go to Control Panel

-In Control Panel, select Large icons from the View by drop down menu.
-Select Sound.
-Select the Playback tab
-Right click the Speakers and click Enable.
-Right-click it again and select Set as Default Device.
-Right click Speakers and click Properties.
-Click on Advance Tab
-Uncheck the box to "Allow Application to take exclusive controls on this device"
-Click OK.

Tuesday, 23 January 2024

ASP.NET Development Certificates in Traefik

The ASP.NET Core HTTPS development certificate can be created with the dotnet dev-certs command.

It is found in Certificate Manager (User Certificates, NOT Local Computer) under the Personal Certificates and Trusted Root Certification Authorities nodes.

You can search for it by it's SHA-1 hash (known as the thumbprint in the Certificate Details tab).

To export the certificate for use in a Traefik Reverse Proxy, type:

dotnet dev-certs https --export-path aspnet.crt --trust --format Pem --no-password

and follow these instructions to add it to Traefik:

https://www.andrewdixon.co.uk/2020/03/14/using-https-certificates-with-traefik-and-docker-for-a-development-environment/

Wednesday, 10 January 2024

CSS Selector syntax in Chrome

 

Chrome allows you to search for elements using CSS selectors or XPath.

Puppeteer uses 

  1. Type selector 
  2. CSS Selector
  3. Class selector 
  4. ID selector 
  5. Attribute selector 

xpath selector

Find the anchor within the tdtd a

XPath

Find element with the text//p[text()='Asset']
Find parent of the element with the text//p[text()='Asset']/..