Articles
home/Blog

Programming blog

I started this blog with the philosophy to create notes in order to refer back to, read and quickly re-learn the content.

Atom/RSS Feed

Latest posts

undefined

How to use IR Emitters on Linux

I wanted to use Face unlock on Linux and receive all the same features as Windows Hello. Using howdy and this guide, you can!

undefined

Resolve Howdy exception when adding your face

I wanted to setup face unlock on Linux with my new Dell XPS 13. This is how you can set it up for yourself!

undefined

How to reset the Windows password of a locked computer

I recently found myself locked out of my old school laptop. I did not have the windows password or the ability to login to any account on the machine.

undefined

How to fix ReferenceError: globalThis is not defined

"ReferenceError: globalThis is not defined" is an error produced by some newer JavaScript libraries as they access globalThis.

undefined

How to fix refreshing on a new tab extension for Google Chrome

By default if you try to refresh custom new tab in a Google Chrome extension, you are met with a file not found error.

undefined

The story of my first Chrome Extension and its tragic demise

I had the idea in my mind that I wanted to create and have my own chrome extension for a few years now.

undefined

Lazy load services using Socket Activation

Lazy loading services allows services to only be started once they are needed.

undefined

How to make a div fit the size of its children

You can make a div fit the size of its children by using `display: inline-block`

undefined

How to pause a script in Bash

In order to make a script in Bash pause, sleep or wait for a period of time you need to use the command `sleep`

undefined

Start a new Flutter project and Connect it to Firebase

It can be tricky to get a new Flutter project to connect to Firebase and work. Version mismatches can be a real killer!

undefined

Use promises in Google Apps Scripts

To use the latest es6 Promises in google app scripts it is very trivial to do so.

undefined

List all installed apt packages in Linux

To list all the installed apt in linux you can use `apt list --installed`.

undefined

Get the last element of an array in TypeScript

There are a few ways you can get the last element of an array in typescript

undefined

My personal rules of programming

These are some rules I try and stick to while programming. I suggest you have a think about adopting these as I feel they are great values to code by.

undefined

How to request different scopes on a Google Apps Script

To request scopes in a Google Apps Script you need to add them to the appscript.json file.

undefined

Keep phone unlocked while USB Debugging

It is a real time saver to keep your phone unlocked while developing an app. 'Stay awake mode' allows you to keep your phone unlocked.

undefined

Run the application you are developing on your device

There are a few steps and potential gotchas in setting up application debugging on your local device.

undefined

How to make xscreensaver stop from promiting for user input

Sometimes xscreensaver will prompt the user to enter their password thinking they are trying to unlock the computer.

undefined

IF/ELSE syntax in LUA

If/ If Else is an integral function in any program or script. This is the syntax for such statement in LUA.

undefined

How to show the git branch in Fish

Show the git branch on the end of the terminal prompt is a really useful modification as you can always see the branch you are on!

undefined

How to find the current git user

To find the current git user you can use the following git command

undefined

Install fish terminal and set as the default terminal

Fish terminal is a great terminal. I was initially heisitant to try it but cnce I gave it a go I really liked it.

undefined

Get additional lines before and after grep match

To get additional lines before and after the grep match you can add the arg **-n**

undefined

How to iterate over a map in Typescript

You can iterate over a map using the `forEach` method.

undefined

SQL INSERT, UPDATE, DELETE like a pro with RETURNING

You would recognise the following as a pretty typical `SQL` insert query with an extra line unlocking a powerful feature.

undefined

Efficiently: The Chrome extension to save your time!

Do you ever find yourself unconsciously opening webites out of habbit?

undefined

Disable Hibernation on Windows to speed up your pc

Having Windows hibernation on is a big killer due to the `Hiberfil.sys` file.

undefined

Clear up unused space in docker

Every time you run `docker compile` on a Dockerfile a container is created, taking up space on your computer.

undefined

Enable the caching of Images in Google Cloud Storage Buckets

To enable the caching of images in Google Cloud Storage buckets you need to set the file or bucket to public and set the `Cache-Control` attribute.

undefined

Fix the routing while using Firebase hosting

To fix the routing you need to include the rewrites section in `firebase.json`

undefined

Get IP Address in Linux

To get the IP Address in linux you can use `ifconfig` or `hostname -I`

undefined

Connect Bitbucket Pipelines with Google Source Repositories

To allow Bitbucket Pipelines access to your personal Google Source Repositories you need to do a few steps.

undefined

Calculate the remaining scroll distance in Angular

To Calculate the remaining scrollbar distance in Angular you need to perform some simple calculations on various window and document variables.

undefined

How query the Firebase Firestore in Angular

To query the firebase firestore in angular you can do the following

undefined

Get the Debug Certificate SHA1

How to get the debug certificate SHA1

undefined

AngularJS component lifecycle cheatsheet

These are the lifecycles to remember in AngularJS.

undefined

How to use ng-repeat in AngularJS

Here is a quick example of ng-repeat usage and implementation

undefined

Using ng-switch in AngularJS

ngSwitch is the equivalent of a `switch` in java or other modern languages

undefined

How to make an element autoexpand right to left in HTML

Making an element expand the opposite direction is a useful html trick to remember

undefined

Create an Observable using RxJS

Creating an Observable in different ways is sometimes required based on the situation at hand. This is all you need to know!

undefined

How to alias a command in git

Aliasing a command is very useful as it lets you shortcut a normal workflow and work more efficiently!

undefined

How to add environment path to Fish terminal

This is how you add an environment path to Fish terminal

undefined

How to add keybindings in fish

Keybindings are really useful and save time.. this is how you utilize them in Fish terminal!

undefined

How to make tab autocomplete in fish terminal

Making tab autocomplete in Fish terminal is a great customisation I strongly recommend as it allows you to press tab to complete the command.

undefined

How to try Fish terminal temporarily

Trying fish without the burden of changing your current terminal is useful incase you do not like Fish terminal

undefined

Create a Bootable usb on Linux

**WoeUSB** is the easiest and has the best compatibility for for all ISO's including Windows

undefined

The difference between services and providers in AngularJS

An easy way to remember it is that **Providers** are at config time (before the application has finished loading).

undefined

Create a delay or sleep in JavaScript/TypeScript

To create a delay or sleep you use setTimeout. setTimeout is an essential function for every developer to memorise!

undefined

Why and How you should use a Sinon Spy

Sinon spys and stubs are very using in testing code. Spys and Stubs allow you to verify if a function was called and how it was called (args).

undefined

How to use Component/Directive's in AngularJS

Here is a easy way to create a component or directive in AngularJS. This is an AngularJS Essential!

undefined

Change the DNS in Linux

Changing the DNS in linux is pretty useful to get past any censorship your isp has imposed on you. *For example thepiratebay.org, 4chan.org*

undefined

Essential hotkeys for Google Chrome

Hotkeys in Google Chrome make your life way easier! All the power users of Google Chrome are using these hotkeys!

undefined

Setting the src for html elements

Setting the **src** attribute for elements is different if you need to reference a AngularJS variable.

undefined

Filtering an array with a function that returns a Promise

You cannot filter an array using `Array.prototype.filter` using a promise as the function is synchronous and therefore does not support promises.

undefined

Install kdeconnect on linux

KDEConnect is a very useful application which allows you to control your computer and send commands from your smartphone!

undefined

How to copy files in linux using CP

You can copy files in linux using CP

undefined

Ensure fonts render nicely in Google Chrome on Linux

Be default linux does not tell fonts to render with antialiasing and other nice features.

undefined

How to add numbers in bash

To add a number you need to encase the expression in `$((` `))`

undefined

All Form Options for Angular Schema Form

Here is a cheatsheet for every option for a form value in Angular Schema Form

undefined

How to nest commands in bash

To use nested commands in bash you can surround the child command with backticks **\`** or **`${}`**

undefined

How to create an empty list in Java

Lists in Java are pretty powerful and this is how you create them

undefined

How to find a files age in git

You can find a files age using the git log command. As seen below

undefined

How to find a files latest changed time in git

You can find a files latest changed time using the following

undefined

Check if a file exists in Java

To check if the file is is a file in Java you need to do the following

undefined

Compare arrays with Java

There are many such use cases where you will find yourself required to compare two arrays in Java.

undefined

Convert list to array in Java

This is how you convert a list to an array in Java

undefined

Convert bytes into a String in python

I recently needed to convert a bytes object into a readable string format. I found that I could do so very easily using the following method.

undefined

All the ways to create a List in Java

The various ways you can create a list in Java

undefined

How to create a symlink in linux

Symlinks are very useful as they allow you to make one file point to another file

undefined

How to decode a string in java

To decode a string in Java you can import java.net.URLDecoder.decode

undefined

Ensure relative paths work in a bash script

To ensure relative paths work in a bash script you can set the working directory to the directory the script is in.

undefined

Adding a default value constraint to a column in SQL

To add a default value to a column in SQL you can do the following

undefined

Alter a table droping a columns default value

To drop a default value from a column you need to alter the column and `DROP DEFAULT`

undefined

Add/Remove/Modify a column on a table in SQL

Sometimes you need to alter a table without dropping it. A big use case for this is a migration script adding or removing a column on a table.

undefined

Check a column does not equal another column in SQL

To check that a column does not equal another column in SQL you can do the following

undefined

Convert an array to a object in TypeScript

To convert an array to a object in typescript you can use the following helper function

undefined

How to copy files over ssh

You can copy files over ssh using the command scp.

undefined

All about functions in LUA

Functions are the core of any good program or script. Functions in LUA are in the following format

undefined

How to create a SSH key

SSH keys are useful as they allow you to securely identify yourself. You can create a SSH key by doing the following

undefined

How to create a view in SQL

You can create a view in SQL by following the following syntax.

undefined

How to drop a function in SQL

Dropping or deleting a function in SQL is useful for many different scenarios. You might need to drop and re-create or you might not need the function anymore

undefined

Drop a trigger from a table

To drop a trigger from a table you need this command

undefined

Load a properties file in Java

This is how you load a properties file in Java

undefined

How to merge a branch in git with an unrelated history

You can merge a branch with a different history by adding the flag `--allow-unrelated-histories`

undefined

Proxy requests using Webpack

Using webpack you can proxy requests from one directory eg `http://localhost:8080/profile` to another address.

undefined

How to put phantomjs on $PATH

Putting phantomjs on the path will stop it downloading every time and therefore decrease the amount of time requiried to npm install.

undefined

How to remove a file from a Git Repo

To remove a file from a git repository you need to remove the cached version of it.

undefined

How to allow insecure hosts in Docker

To allow docker to connect to a insecure host (a host using http instead of https) you need to edit the daemon.json to have some config!

undefined

Scroll to the the top of the page automatically in AngularJS

You can scroll to the top of the page automatically by injecting Window and using the function scroll(x,y).

undefined

Installing Google Drive on Linux

Google Drive is really useful *I use it for the central location of this blog infact!*

undefined

Installing or uninstalling a package with pip

To install or remove/uninstall a python package you use pip.

undefined

How to install AwesomeWM on xubuntu

Installation guide for AwesomeWM on xubuntu.

undefined

How to list active processes in linux

You can list the active processes in linux using `ps`

undefined

How to load more days on the Agenda view in GCalCLI

By default gcalcli loads 7 days on the agenda view. You can specify how many you want if you give it 2 number args, for example:

undefined

Incrementation in LUA

There is no such thing as *Advanced Operators* **`++`** or **`--`** in Lua

undefined

How to read from a properites file using Bash

Reading from a properties file is a set some config outside of the script for ease of editing.

undefined

How to refresh the build image using docker-compose

To refresh the build image, you need to add `--build` to the docker-compose command.

undefined

Remove the New Login button from xscreensaver

To remove the xscreensaver `New Login` button you need to set the entry for `XScreenSaver.newLoginCommand` to an empty value.

undefined

Using services in linux with Systemctl

Services in Linux are generally things that run in the background providing a useful function or 'service'. Systemctl is the 'service manager'.

undefined

Setting properties in a properites file using bash

To set or update properties in a properties file from a bash script you can use **sed**

undefined

Set the default value via Form - Angular Schema Form

Currently it is not possible to declare a default value via the form object.

undefined

What is TAIL in Linux and how you should use it!

You might wonder 'how do I get the last lines of a log file' or 'how do I get new lines written to a file in linux'. Well tail is what you need!

undefined

The power of Stream.of() in Java

Stream.of() can be used instead of creating an array then iterating over it.

undefined

Using OAuth with Google APIs

This is a guide to using OAuth with Google APIs. This document shows how to get a Refresh Token which you can use inside your application.

undefined

Using OR statements in Gmail filters

Creating filters in Gmail is a great way to help manage and achieve a tidy inbox.

undefined

Why its important to use private 0arg constructor for Java

When creating util classes in java you should ensure you add a 0arg private constructor