Snippets

Quick bits and pieces that could save you a lifetime!

React States & Asynchronous Callbacks

January 17, 2019

We all love the concept of the React state! You can trigger updates on data that are part of the scope of your component, and that'll trigger a re-render reflecting the new state. Now there are 2 ways…

Leveraging Null Safety in Kotlin

January 17, 2019

One of the biggest annoyance in Java is always having to deal with . Looking at any large Java code base, you are bound to see the the expression to check for null which is such an inconvenience…

Flattening Arrays in Javascript Recursively

January 16, 2019

In many cases when processing data you would need to flatten the final result, specially when using promises and resolving multiple pieces of data separately. Here's a recursive and efficient way of…

Simplify assigning properties with Apply in Kotlin

January 15, 2019

Kotlin has this nice apply function that is an extension that allows you to set multiple properties at one time. It returns itself after being called.

Understanding Ranges in Kotlin

January 14, 2019

Often times we need to create a loop, however in many different languages to define a range varies. In Kotlin, there are few ways we can define a range for a for-loop.

Shuffling an Array in Javascript

January 14, 2019

There are many ways to shuffle an arrays. Various algorithms offer different levels of performance, and specially bias! Here's a quick method: Now among shuffling algorithms, the Fisher-Yates…

How to find the Difference between two arrays in Swift

January 14, 2019

In situation where you would like all the elements that are in one array but not the other (ie in one array but not both) - a solution is to use . Sets have a symmetricDifference() method that does…

Search by