TypeScript: readonly vs. const
From The TypeScript Handbook:
The easiest way to remember whether to use readonly or const is to ask whether your using it on a variable or a property. Variables use const whereas properties use readonly.
From The TypeScript Handbook:
The easiest way to remember whether to use readonly or const is to ask whether your using it on a variable or a property. Variables use const whereas properties use readonly.
Using Microsoft Windows Subsystem for Linux (WSL) to gain access to Linux command line tools within Microsoft Windows 10, I was able to create a consistent backup procedure that can be performed in Windows and Linux environments. I used SyncToy and File Checksum Integrity Verifier (FCIV) to perform backups before adopting this standard approach.
Except where noted, the following procedure can be performed in both Windows and Linux environments.
$ cd /mnt/c/myfolderparent
$ find ./myfolder -type f -exec sha1sum -b "{}" + > ~/myfolder.sha1
$ sha1sum -c ~/myfolder.sha1
or
$ sha1sum -c --quiet ~/myfolder.sha1
Note: myfolder.sha1 contains relative paths. The above command requires execution from a directory where relative paths lead to the files desired for integrity checks.
$ mkdir /mnt/usbdrive
$ mount
$ sudo mount -t drvfs f: /mnt/usbdrive \
-o noatime,uid=1000,gid=1000
This command is specific to Microsoft Windows; a similar command is available in the Linux environment. “f:” is the drive letter that Microsoft Windows assigned to the inserted USB drive in this example. Options are specified to match those highlighted above for the already mounted fixed drives.
$ rsync -n -av --delete --force --progress \
--human-readable ./myfolder/ /mnt/usbdrive/myfolder
$ rsync -av --delete --force --progress \
--human-readable ./myfolder/ /mnt/usbdrive/myfolder
The trailing ‘/’ of the source folder is important to the command’s correctness.
$ cp ~/myfolder.sha1 /mnt/usbdrive/.
$ cd /mnt/usbdrive
$ sha1sum -c myfolder.sha1
Introduced in C# 8.0, the using-declaration language enhancement eliminates nested using-statements. The following code:
using System.IO; class Program { static void Main(string[] args) { var filename = "hello.txt"; using (var stream = new FileStream(filename, FileMode.Create)) { using (var writer = new StreamWriter(stream)) { writer.WriteLine("Hello, World!"); } } } }
is improved with using declarations to the following:
using System.IO; class Program { static void Main(string[] args) { var filename = "hello.txt"; using var stream = new FileStream(filename, FileMode.Create); using var writer = new StreamWriter(stream); writer.WriteLine("Hello, World!"); } }
The following procedure adds encryption to pre-installed Ubuntu 18.04 on Dell XPS 13 7390:
$ sudo su -
# dd status=progress if=/dev/zero bs=1M count=20000 of=/.hostname-home.img
# cryptsetup luksFormat /.hostname-home.img
# cryptsetup luksOpen /.hostname-home.img hostname-home
# mkfs.ext4 /dev/mapper/hostname-home
# mkdir /root/home
# mv /home/* /root/home/.
# mount /dev/mapper/hostname-home /home
# mv /root/home/* /home/.
# rmdir /root/home
# umount /home
# cryptsetup luksClose hostname-home
# echo \
"hostname-home /.hostname-home.img - tries=0" \
>> /etc/crypttab
# echo \
"/dev/mapper/hostname-home /home ext4 defaults 0 0" \
>> /etc/fstab
I recently received my Dell XPS 13 7390 with pre-installed Ubuntu 18.04. My top concern is securing data such as private SSH keys and passwords saved by Internet browsers from the real possibility of losing my laptop to absent-mindedness or theft. My purist side insists on configuring full disk encryption by performing a fresh install from a publicly available Ubuntu download. My pragmatic side pushed me toward adopting the above procedure. Without the needed transparency from Dell on their additions to Ubuntu, it is difficult to determine whether a publicly available Ubuntu download will fully support the features of my new Dell XPS 7390. The above procedure encrypts any data writable by unprivileged users while remaining unprivileged. It introduces a basic layer of security while allowing enjoyment of a system configured by Dell.
As the holiday season nears, a new laptop for developing skills and personal projects is worth considering. The Dell XPS 13 7390, with an Intel® Core™ i7-10710U processor, is really enticing. Windows 10 Pro, an M.2 PCIe NVMe SDD, and non-touch display are motivating as well. As with other big purchases, a decision will require more than a month’s consideration.
Specifications: