Nov 30, 2018

More Docker Fun

Handy command pulled from SO to ensure when you enter a docker container, the terminal buffer size isn't 100% messed up:

https://stackoverflow.com/questions/38786615/docker-number-of-lines-in-terminal-changing-inside-docker/49281526#49281526

goinside(){
    docker exec -it $1 bash -c "stty cols $COLUMNS rows $LINES && bash";
}
_goinside(){
    COMPREPLY=( $(docker ps --format "{{.Names}}" -f name=$2) );
}
complete -F _goinside goinside;
export -f goinside;

Sep 5, 2018

Docker Thoughts

Run the following command to get the IP addresses of the host machine. You an then use the docker IP address within the container to access the host machine: ip -4 addr

Trash all unused images: docker image prune -a


Jun 29, 2017

Ubuntu 16 and MySQL Fun

Did a fresh install of Ubuntu 16 LTS on Azure and installed MySQL with defaults (no password). For whatever reason, I could only connect to the database via sudo. I tried all sort of grant options to no avail. Finally this link here helped https://askubuntu.com/questions/766334/cant-login-as-mysql-user-root-from-normal-user-account-in-ubuntu-16-04

Jun 9, 2016

Android Splash Activity "gotcha"


The title might be misleading, but here's the essence of the gotcha. Last year I had an app that would throw some exceptions sometimes on some devices when the app had been in the background for awhile. There were static singleton variables that were created in the "splash" activity, the main entrance activity. This is the one that we use to determine where to take the user (e.g. if the user is logged in, take them to the Dashboard activity; if the user isn't logged in, take them to the Login activity). This splash activity also loaded the current user into a global static var that the subsequent activities would reference.

However - the gotcha is that when your app is killed by the system (most likely due to low memory), the splash activity is bypassed and Android will open up the last activity that was on the stack.

The solution - move the logic for setting the current logged in user into the Application class. The application class is always run before it loads any other activities. You can simulate this by running the following command from adb:

am kill <com.favpix.yourpackage>

Hope this helps someone else out!

Sep 16, 2015

Android Event Bus

We've used Otto for event notification. If you're not familiar with this, it allows your application to subscribe to events and other parts of your application to listed for when those events are fired. Otto was okay for awhile, and still is. It comes with one major caveat - new Android developers don't realize they need to unregister() off the bus when the lifecycle of the view is over - this creates a memory leaks on apps with more than one Activity or Fragment, which causes apps to eventually crash.

One of the items I've been waiting for is either the ability for Otto to get a bit smarter and allow the user to register as a weak reference. A new library, EventBus (also boasting faster performance) has emerged, and one of the outstanding feature requests is to enable this very feature. Hasn't been implemented yet, but something I've subscribed to and am interested in seeing implemented.

Realm.io - Android/iOS Database

Coworker pointed out Realm, a mobile database for Android and iOS. Offers increased performance vs native SQLite databases, on both iOS & Android. In addition, there is a plugin for Stetho so you can view your database inside Chrome dev tools (Stetho is absolutely one of the most useful Android tools I've come across in awhile).

Chuck Norris Quick API

Came across a quick URL to testing hitting up an API (well aware there are roughly over a million of these already).

GET http://api.icndb.com/jokes/random

{"type": "success","value": {"id": 466,"joke": "Chuck Norris doesn't do Burn Down charts, he does Smack Down charts.","categories": ["nerdy"]}}