Find and replace text in Linux terminal, bash scripts or Jenkinsfiles

I manage the build process for Android applications. Part of the process automatically updates the version of the application in various build.gradle files. In a Jenkinsfile, a list of file paths are passed into a for-loop in which the find-and-replace sed command is run to set the new version number. Sed for Find-and-Replace Sed is a library used for performing all sorts of text operations, which makes it very handy for scripting related work....

December 1, 2021 · 2 min · Shariq Jamil

Solution for Advent of Code 2021 - Day 1

To count the number of increases in depth, this function iterates over the given input and checks to see if the previous number was smaller than the current one. If so, the counter gets incremented. At the end, the value of the counter is printed which refers to the total number of times that the depth measurement increased. def day1(): input_file = open("day1/day1-input") lines = input_file.readlines() counter = 0 for index, line in enumerate(lines): if index !...

December 1, 2021 · 1 min · Shariq Jamil

Automated image optimization for publishing on a blog

After a few attempts, I have automated the process for optimizing images for JamilGhar. As my wife adds images to the project’s git repository, a bash script that runs on regular intervals will compress them. The end result is fantastic because she no longer has to wait on me to manually optimize them for her and the Raspberry Pi that sits under my desk is being very useful. Why is optimizing images important?...

November 27, 2021 · 4 min · Shariq Jamil

Adding search functionality to a Hugo website

Search is an important functionality for any content heavy website. Our decision to use a static site for our recipe blog meant that adding complex features that involve server operations would be difficult to implement without relying on third-party tools. These features include comments and custom metric tracking. Luckily, this problem has been solved by a Javascript library called Lunr.js. Lunr provides a fast search experience for the user by processing JSON documents produced by static site generators like Hugo....

November 26, 2021 · 4 min · Shariq Jamil

GitHub 'repository not found' error when using an access token

At my work we use Personal Access Tokens (PATs) to authenticate to a GitHub repository (as opposed to using a password). I was having trouble cloning the repository and seeing the following error After browsing Stack Overflow posts, I realized that I didn’t set the right “scopes” or permissions for my token. I generated a new token but this time I made sure to set all the scopes under “repo”....

October 4, 2021 · 1 min · Shariq Jamil