Some useful commands

This post will contain a list of useful commands that I find interesting. Git commands To update git in Windows, use the following: git update-git-for-windows Hugo commands hugo new --kind post posts\2021\read-post.md will create a new post which is an archetype. Dotnet commands dotnet new gitignore - Who knew that this will be a useful command. Forget copying .gitignore files from Github, this will create one for you with pretty good defaults....

July 19, 2021 · 1 min · Samuel Tambunan

Builder pattern

Overview What is the telescoping constructor problem? This is a problem when overloaded methods that contains additional parameters exist in a class. An example would be: public void AddFruit(string type) { } public void AddFruit(string type, string color) { } public void AddFruit(string type, string color, string taste) { } A telescoping constructor problem can lead to messy code that becomes not only complicated to read, but we can use a better pattern to provide arguments to the method....

September 25, 2024 · 2 min · Samuel Tambunan

Sargable vs Non-sargable queries

Sargable vs non-sargable query What are sargable and non sargable queries? A query is considered to be sargable if it’s able to take advantage of an index to speed up the execution of a query. A non sargable query is the opposite of that where the dbms engine is unable to take advantage of an index. Person table Let’s say there’s a Person table and an index with the following SQL:...

September 3, 2024 · 3 min · Samuel Tambunan

SQL Constraints and Triggers

Overview Data integrity in SQL server can be enforced by the use of constraints and triggers. This post will quickly compare both constraints and triggers and explain the main differences between them. Constraints Check constraints are used to validate that the data going into the table follows certain rules. Constraints are really simple to use but also have the downside of not being as complex as triggers. They can be placed in the column to ensure that data in the column follow certain rules....

August 25, 2024 · 4 min · Samuel Tambunan

Curl with hostname mapping

Introduction There might be times when you need to send a curl request to a specific server but do this with a custom hostname mapping. For example, let’s say your application does a different thing depending on the hostname and a request to the application with a different hostname will result in a different response. This can be tested by using the following command: curl "https://api.samueltambunan.com/d/example.mp3" -v -o test2.mp3 --resolve api....

August 16, 2024 · 1 min · Samuel Tambunan

Fun with timespan

Introduction and caveat Timespan is a .NET object that can be used to represent a time interval. For example, a 15:00:00 is a timespan that represents 15 hours. However, I feel that the way timespan works when trying to create a time interval of 24 hours or more is a bit weird. Instead of 24:00:00 representing 24 hours, .NET instead assumes this is 24 days. This can be quite confusing when someone tries to create a Timespan to represent 24 hours and uses 24:00:00 it’ll turn out to be 24 days....

March 27, 2022 · 1 min · Samuel Tambunan

Private vs service endpoints

Introduction When it comes to ensuring resources can communicate to each other privately, Azure provides two ways to enable this. The first being service endpoint and the second being a private endpoint. This post will look into the benefits of service and private endpoints, the differences between them, and what criterias we should be looking out for when choosing one or the other. Traffic between services in Azure When two Azure resources communicate with each other, unless otherwise specified or configured, they will use the internet to do domain resolution and send data via the public network....

March 20, 2022 · 2 min · Samuel Tambunan

Problem details response

How should we return non 200 responses? When creating an API, returning non 200 ok responses can be quite tricky as you might not know what information should be provided to the consumers. A 200 OK response is very straightforward as we understand that it represents a successful request and in the case of a GET, a response can be provided. In the case of a non 200 response however, things can be a bit more tricky....

August 30, 2021 · 4 min · Samuel Tambunan

TLS and SSL Certificates

What is a TLS certificate? TLS stands for transport layer security and is a protocol that will allow a client and a server to communicate with each other securely. A TLS certificate or a digital certificate is a certificate to be used with the TLS protocol. One thing to note is the certificate is independent of the protocol. A digital certificate can be used with either protocol, which can be set by the server....

August 27, 2021 · 4 min · Samuel Tambunan

Thoughts on layers and DI

Notes An alternative to n-layer applications architectural style is to use the CQRS pattern. Not too sure how this might be used for building applications instead of the n-layer architecture. With the n-layer architecture, such as a 3 layer application, it is easy to visualize this. There would be a data access layer, domain layer, and UI layer. The data access layer will be responsible for retrieving data from the database....

August 22, 2021 · 4 min · Samuel Tambunan