Craig RussellBlog Posts on craigrussell.iohttps://craigrussell.io/posts/
Recent content in Blog Posts on craigrussell.ioHugo -- gohugo.ioen-usWed, 24 Apr 2019 00:59:50 +0100Craig RussellA WorkManager Pitfall: Modifying a Scheduled Workerhttps://craigrussell.io/2019/04/a-workmanager-pitfall-modifying-a-scheduled-worker/
Wed, 24 Apr 2019 00:59:50 +0100https://craigrussell.io/2019/04/a-workmanager-pitfall-modifying-a-scheduled-worker/This post describes a potential WorkManager pitfall when refactoring or deleting your Worker subclasses.
Overview When using WorkManager, you define a Worker subclass, optionally add some constraints and enqueue it with WorkManager so that your work will happen sometime later.
How bad things might happen But what happens if:
you schedule a job for sometime in the future before the job runs, you update your app to rename, move or delete the Worker class?Craig RussellInstalling Fathom Analytics on Amazon EC2https://craigrussell.io/2019/03/installing-fathom-analytics-on-amazon-ec2/
Fri, 15 Mar 2019 02:03:53 +0000https://craigrussell.io/2019/03/installing-fathom-analytics-on-amazon-ec2/This post describes how to install Fathom analytics on an Amazon EC2 instance. Fathom allows you to have privacy-respecting website analytics. If you host it yourself, you&rsquo;re the only one who gets to see that data and the software is FOSS.
Alternative to Google Analytics Fathom is best described as an alternative to Google Analytics. GA has pervaded the entire web, and has done so by offering itself for free.Craig RussellAdding Author tag to RSS Feed using Hugo static site generatorhttps://craigrussell.io/2019/03/adding-author-tag-to-rss-feed-using-hugo-static-site-generator/
Thu, 14 Mar 2019 01:34:15 +0000https://craigrussell.io/2019/03/adding-author-tag-to-rss-feed-using-hugo-static-site-generator/This post details how to include the author tag in the generated RSS feed for a Hugo-generated site.
Default RSS Template Hugo comes equipped with a template by default. In fact you might be pleasantly surprised to discover your site has an RSS feed already. You can try it out by visiting your site and adding /index.xml on the end of either of your home page, or your section containing your blog posts.Craig RussellSend Firebase FCM Push Notification from AWS Lambdahttps://craigrussell.io/2019/03/send-firebase-fcm-push-notification-from-aws-lambda/
Wed, 06 Mar 2019 23:50:21 +0000https://craigrussell.io/2019/03/send-firebase-fcm-push-notification-from-aws-lambda/This posts provides an example of how to configure an Amazon AWS Lambda to send a push notification to Firebase FCM, written with the Node.js 8.10 runtime.
What is AWS Lambda This post assumes you are familiar with AWS Lambda already. If not, you can read more about it staight from the docs.
Configure the lambda Create a new AWS lambda using the AWS Console. Configure these two options:Craig RussellCoroutine Support in ViewModels using the new ViewModelScope Extension Propertyhttps://craigrussell.io/2019/03/coroutine-support-in-viewmodels-using-the-new-viewmodelscope-extension-property/
Tue, 05 Mar 2019 00:00:00 +0000https://craigrussell.io/2019/03/coroutine-support-in-viewmodels-using-the-new-viewmodelscope-extension-property/This post describes how to use Coroutines in ViewModels, making use of the new ViewModelScope extension property. This allows coroutines to be cancelled automatically when the ViewModel is being cleared.
Overview As of lifecycle 2.1.0-alpha01, there is now easy support for coroutines in ViewModels, using an extension property called ViewModel.viewModelScope.
Example viewModelScope is likely best explained by starting with an example. Let&rsquo;s imagine we are following the standard Android Architecture Components setup, and we have a ViewModel which extends androidx.Craig RussellShooting Yourself in the Foot While Adding an Element to a Kotlin Listhttps://craigrussell.io/2019/03/shooting-yourself-in-the-foot-while-adding-an-element-to-a-kotlin-list/
Sat, 02 Mar 2019 00:00:00 +0000https://craigrussell.io/2019/03/shooting-yourself-in-the-foot-while-adding-an-element-to-a-kotlin-list/This post discusses the functions add() and plus() which are available on some Kotlin collections, and how despite their similar looking names, their underlying implementations can make a big difference
A primer on operator overloads Kotlin supports Operator Overloading, which means you can make use of operators like + and += as a shorthand for calling otherwise normal functions. However, it&rsquo;s always worth checking what the underlying function actually does as otherwise you might catch yourself out.Craig RussellScripting with Kotlin - Kscripthttps://craigrussell.io/2019/02/scripting-with-kotlin-kscript/
Tue, 26 Feb 2019 01:00:00 +0000https://craigrussell.io/2019/02/scripting-with-kotlin-kscript/This post discusses kscript, an easy way to write and execute scripts in Kotlin. This post covers what kscript is, how to install it on a Mac, and offers some kscript examples.
What is Kscript Enhanced scripting support for Kotlin on *nix-based systems.
While Kotlin has some support for scripting already, it lacks a few things which would help its adoption. Chief among them for me, is the extra friction caused by having to run it using kotlinc.Craig RussellBreaking Up With Mediumhttps://craigrussell.io/2019/02/breaking-up-with-medium/
Tue, 26 Feb 2019 00:00:00 +0000https://craigrussell.io/2019/02/breaking-up-with-medium/Medium. We need to talk. 💔
In the Beginning When our relationship started, it was a breath of fresh air. I must admit, the first thing that attracted me was your looks. You had no ads. No clutter. You were neat and organized, and looking at a Medium article was a joyful experience.
Having created my 1st article on @Medium, I can see why it is popular; writing a post is a delight.Craig RussellLaunching a Kotlin Coroutine for immediate execution on the Main threadhttps://craigrussell.io/2019/02/launching-a-kotlin-coroutine-for-immediate-execution-on-the-main-thread/
Fri, 15 Feb 2019 21:14:36 +0000https://craigrussell.io/2019/02/launching-a-kotlin-coroutine-for-immediate-execution-on-the-main-thread/If you launch a coroutine using launch(Dispatchers.Main) while already on the main thread, will the code execute immediately?
No, is the short answer. This post explains why.
Consider the following code. As this is the onCreate function of an Activity, we know it is running on the main thread.
We expect that two things will be printed to the logs; “A” and “B”. But in which order?
OUTPUT:Craig RussellSSH Keys with Multiple GitHub Accountshttps://craigrussell.io/2016/08/ssh-keys-with-multiple-github-accounts/
Wed, 10 Aug 2016 00:26:52 +0000https://craigrussell.io/2016/08/ssh-keys-with-multiple-github-accounts/This article explains how to manage multiple SSH keys for different GitHub.com accounts so that you can access multiple accounts and projects, each with different credentials.
These instructions focus on Mac OSX and GitHub.com specifically; be warned if you are using another OS or a different hosted git repository.
If all goes well, you’ll likely be up and running within 30 minutes if you follow this guide.
Who Has Multiple SSH Keys?