Andy Lamb


Header image

Fix Windows Line Endings on Unix

Windows ends a line with a carriage return and a line feed character. (\r \n)
Unix ends a line with just a line feed character. (\n)
Incorrect line endings can prevent Unix from reading the file, especially script files, correctly.
This command uses the Unix sed tool to remove the carriage return character when found at the end of a line.

  sed -i 's/\r$//'

Set Permissions on Multiple Files

When working on Unix web servers, particularly when automating the deployment of websites, it's common to need to update permissions on CGI files.
This can be simplified by combining the find and chmod utilities. The chmod utility modifies permissions on files. The find utility filters files.
The exec parameter of the find ultiity can be used to modify the permissions of all filtered files using the chmod utility.
In this example, I'm finding all PHP and PY files from the home directory and modifying the permissions so they can be executed on the server.

  find ~/ -type f -name "*.php" \
  -o -name "*.py" -exec chmod 755 {} +;

Simple SVG Icons

Simple Icons icon

I came across the Simple Icons site when building my own site. It's a community maintained collection of simple SVG icons for well over 100 brands.

The SVGs themselves are monochrome, but the brand primary colour is also suggested.

A few days ago I saw a tweet from a guy called Elliot Brown.

"If you're on .NET, build your objects in F#. I'm serious."

His argument was that F# records give you sooo much by default, compared to C# classes:

  • IEquatable<T> and IStructuralEquatable are implemented.
  • IComparable, IComparable<T>, and IStructuralComparable are implemented.
  • As such: GetHashCode, Equals, and CompareTo methods are implemented, including overloads.
  • A full constructor for instantiation.
  • A nice ToString implementation.
  • And it's immutable by default.

"A four-line record becomes a quality class."
I had to check this out...
.NET Framework, .NET Standard, .NET Core, .NET 5... There's been alot of change in the .NET space in the last few years. The progression of .NET runtimes is well understood,

.NET Framework begat .NET Core begat .NET 5

But, what about .NET Standard?

.NET Standard Support

The Origin of Swagger

Swagger - verb
  • to walk or strut with a defiant or insolent air.
  • to boast or brag noisily.
Swagger - software
  • a specification for defining the interface of a REST web service.
  • now known as the OpenAPI Specification

REST (REpresentational State Transfer) is an architectural style of stateless web services using the standard HTTP verbs (GET, POST, etc) to expose resources identified by URLs. Swagger is a text based format for documenting RESTful APIs (APIs that adhere to the REST architectural constraints). It is now more formally known as the OpenAPI Specification but the name 'Swagger' stuck.

But why was it called Swagger? Where did the name come from? The team developing a dictionary site called in 2011 became frustrated by the then standard way of describing HTTP APIs, WADL (Web Application Description Language). WADL is based on XML, so suffers from the angle bracket tax. The data to syntax ratio is low, the noise is high, maintaining it manually is hard. The Wordnik team designed Swagger to be easier to read/write by humans, while still being parsable by computers for code and documentation generation.

WADL is pronounced 'waddle'... like a duck. Zeke Sikilianos, of the Wordnik team, coined the term 'Swagger' as in:

"Why WADL when you can Swagger?"
Bart Simpson swaggering

© 2021 Andy Lamb