This is a chapter-by-chapter summary (including my own insights) of Dr. Russell’s book Human Compatible. It is a great read as it raises a lot of questions, invokes quite a few debates, and provides some answers. Dr. Russell is a serious researcher in AI, so I do not doubt him when he suggests that based on the three fundamental guidelines he proposes (very different from the three laws of robots in Asimov’s work), we will be able to construct a beneficial AI sometime in the future. …

Using fastlane screengrab on react native app is also challenging

This is a sister article of Make Fastlane Snapshot Work with React Native. While fastlane snapshot works with iOS app, fastlane screengrab is its Android version that programmatically takes Android app screenshots using the UI Testing functionality supported by Android Studio. Although the screenshot requirement on Android Play Store is less stringent than that on Apple App Store (no hard requirement on dimension, can skip tablets, etc.), the journey of getting fastlane screengrab to work with React Native is still quite a mouthful. …

Using fastlane snapshot on react native app requires quite some efforts

Update 02/10/2021: for the Android version, i.e. fastlane screengrab, we have shared our experience in Make Fastlane Screengrab Work with React Native.

We recently submitted an app made in react native to Apple App Store. The whole process was highly complex, but with the help of fastlane, it was bumpy but still manageable…until we started to generate screenshots of the app. Screenshots are required by Apple App Store for two sizes of iPhone (6.5-inch and 5.5-inch) and two versions of iPad Pro (12.9-inch 2nd and 3rd generation). Although screenshots can be produced manually, it is not a scalable solution once…

Update 01/05/2021

I have ditched the enzyme solution and fully embraced @testing-library/react-native , which makes testing hooks and triggering events much easier. The same testing as shown in the original article can be written in just a few lines and without the need to mock.

Updated testing code using @testing-library/react-native

Recently, I need to write tests for a functional component that uses useState and useEffect to toggle an internal state based on whether the virtual keyboard shows up. A simplified version of the functional component is displayed below.

Source code for the sample component

The basic functionality is that a piece of…

Workflow of command-and-response using AWS IoT Jobs


This is Part II of a series discussing one way to integrate IoT device with AWS IoT using Python. Other parts of the series are listed below:

  • Part I: upload data to MQTT topic
  • Part II: command-and-response (this article)
  • Part III: command-and-response using API
  • Part IV: remote SSH login with ngrok
  • Part V: over-the-air software update

For background information of this series, please refer to the Introduction section of Part I.

Before You Start

It is highly recommended that you go through Part I to set up your development environment and configure AWS. This article assumes that you have already downloaded the source…

Workflow of uploading data from IoT device to AWS IoT MQTT topic


This is part I of a series discussing one way to integrate IoT device with AWS IoT using Python. Other parts of the series are listed below:

  • Part I: upload data to MQTT topic (this article)
  • Part II: command-and-response
  • Part III: command-and-response using API
  • Part IV: remote SSH login with ngrok
  • Part V: over-the-air software update

This series attempt to build a fairly robust system for the IoT device. Thus, the source code follows proper design, linting, and type checking to the best of my effort. Unfortunately, due to time constraint, unit test is currently not included.

The IoT device…

Column names “displ” and “hwy” not in scope. The code executes correctly, but the warning scorches my eyes.

Since I just started to learn R, I wanted to do as many things correctly as possible the first time. Therefore, I turned on all the diagnostics in RStudio, including “Warn if variable used has no definition in scope”, which by default was not selected.

Five minutes later, I ran into a problem.

I was following the code on this reference. Upon copying ggplot(mpg) + geom_point(aes(displ, hwy)) to the diagnostics-enabled RStudio text editor, I got this warning:

no symbol named ‘displ’ in scope

no symbol named ‘hwy’ in scope

This was understandable, as these two symbols have not been declared…

I have been working on IoT devices recently and one of the tasks is to figure out an easy way to perform Over The Air (OTA) software update. Given that our IoT devices are registered under AWS IoT, and that the executable binary is quite small (about 6 MB), a fairly straightforward solution is to put the updated binary on an internal S3 bucket, which will be downloaded by each IoT device whenever update is needed.

However, looking deeper into this, I realized that AWS IoT authenticates IoT devices differently from other AWS resources (such as S3). The former uses…

Python with Log

In Python3, logging into a single file from different multiprocessing.Process is not supported, because there is no way to “serialize access to a single file across multiple processes in Python”. However, this document provides a brilliant solution to work around the limitation. Basically, we set up ONE logger in a listener process to handle log writing exclusively, while all other loggers log their messages to a queue that is processed by the listener process. However, the demo code in the document doesn’t cover some of the nuances that I encountered when trying to make it work for my own project…

pre-commit git hook is a very useful tool to run linter, formatter, or complexity checker for your code before committing it. A popular framework is pre-commit, which, with a few easy steps, allows you to set up linting/formatting/checking tools for pre-commit hook. However, the pre-commit framework does not support all the tools for linting/formatting/checking purposes. For instance, wemake-python-styleguide doesn’t seem to be supported by pre-commit . Therefore, we will have to configure pre-commit git hook manually if you want to use wemake-python-styleguide, instead of the flake8 provided by pre-commit, for linting and checking your python code.

To integrate wemake-python-styleguide in…


Hi, I am from the Earth. And you?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store