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"]}}

May 18, 2015

Recommended Podcasts

After having being recently asked some of my favorite podcasts, what better place to record than here. In no particular order.


  1. This American Life
  2. Radio Diaries
  3. Love + Radio
  4. 99% Invisible
  5. The Memory Palace
  6. HBR IdeaCast (nerdy, I know)
  7. StoryCorps
  8. Death, Sex &amp; Money
  9. The Moth Podcast
  10. StartUp Podcast
  11. Serial 
  12. Reply All
  13. Planet Money
  14. Invisibilia
  15. Freakonomics Radio
  16. Criminal
  17. Radiolab from WNYC
  18. Criminal
  19. Every Little Thing
  20. Hidden Brain
  21. My Favorite Murder
  22. Revisionist History
  23. Science Friday
  24. Science Vs
  25. The Daily Show 
  26. The Kevin Rose Show
  27. The Pitch
  28. The Way I Heard It with Mike Rowe
  29. Tribe of Mentors
  30. Uncivil
  31. Without Fail

Sep 22, 2014

Ubuntu Gradle Update

Came across this issue when updating gradle on my Ubuntu VM. I'd run `apt-get upgrade gradle` which indicated it would upgrade to 2.1. However, a quick `gradle -v` indicated it was still on the 1.x version.

The fix for me was to remove the old file: /usr/bin/gradle and then link up the latest one:

sudo rm /usr/bin/gradle
sudo ln -s /usr/lib/gradle/2.1/bin/gradle  /usr/bin/gradle 


As always, hope this saves someone some time.

Sep 17, 2014

SSL Certifcate Fun...

Found it rather annoying to try to convert certificate files for the HealthVault platform. They expected .cer format which seemed to be of some funky variety. After digging a bit further, this is simply a self signed certificate which normally takes on a .crt file extension. Knowing this, you can simply google the best way to self sign a certificate for Microsoft, or you can use the commands below:


openssl req -new -key  server.key -out  server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
cp server.crt server.cer

Hope this saves someone some time!

Apr 8, 2014

Local Testing from the Web

Useful tool that does port forwarding. It's a bit slow, but it get the job done if you need to test a local site on a device that isn't on the same network.

https://ngrok.com

Sep 12, 2013

D3 Charting

D3, a very powerful, low level charting package, can be difficult to start with. To create just a simple line graph can take a few hours to get off the ground. I found this site which has all a few templates to gets started: http://nvd3.org/ghpages/examples.html.

And, if you're interested in the more advanced D3 visualizations, there's always the Github gallery with some impressive examples:

https://github.com/mbostock/d3/wiki/Gallery.

Jul 16, 2013

Developer Application Management

Microsoft, Facebook and Google all have different URLs to manage applications.

Facebook is the easiest to remember: https://developers.facebook.com/ (Makes sense). Plus, if you're like me, I usually miss the "s" on developers, yet Facebook is smart enough to redirect me.

Microsoft and Google are both difficult to find. It's a good few minutes each time. 


Google also supports the "developers" subdomain, but it presents with too much information. You'd need to know you're looking for the API console.

This will certainly save me a few minutes next time I need to open up a dev server that has a different URL yet still needs the same API access.

jQuery Isotopes

Coworker pointed this out today, jQuery Isotopes. Looks interesting - a bit of eye candy. I'm not sure if I would put this on a website (using their homepage example), but it has a bit of promise for some other purposes. Something I'll keep in mind for future layouts.

Ubuntu Linux Items

Turns out installing items on Ubuntu is extremely easy. The following items turned out to be useful tips (if not also the "proper" way to install additional items).

For PHP, to install additional modules, it's also a "sudo apt-get install php" command. Press the tab key "tab out, as it were, and it will show you the additional items that can be installed.

For Apache, to enable additional modules, instead of modifying the httpd.conf file, the files are separated out into separate directories. Use the "a2enmod" (presumably it's the 'Apache2 enable module' command.

I'm working on getting Ubuntu running Symfony and connecting to the Azure SQL Server database - this is turning out to be quite the challenge. After that nut is cracked, or when I crack and install MySQL instead (using apt-get), I'll post the results here to save the next person some work.

Jun 17, 2013

Composer and IIS

When running composer on a site hosted by IIS, the permissions of downloaded files aren't correct. The IIS user is not added, which means all of those packages you just downloaded cannot be used by your application. Fret not, there is a simple command to recursively update permissions (a la chmod, chgrp for linux).

icacls ./ /grant:r IUSR:"(OI)(CI)"F /t /inheritance:e

This took a bit of time to start and finish, but when it was completed, everything was good to go.

Jun 3, 2013

Updating Group File Permissions

From the command line:
chmod -R g+w *

This will give recursive group write access to everything. This is useful for me when my Apache is run under one user and my text editor is running under a different user (e.g. the user I logged in as). This will ensure both users, provided they're in the same group, will be able to edit the file.

May 15, 2013

XDebug

So - followed the steps to paste the phpinfo() output into the following webpage: http://xdebug.org/wizard.php. Pasted the instructions, followed the step where it said "add the following line to php.ini".

Few notes:

  1. XDebug needs the full path.
  2. The link above will say to just add zend_extension="path to dir". That is wrong. It needs to be the full path, including the directory, to  the xdebug dll.

Apr 10, 2013

WAMP MySQL Data File Location

Took me a few minutes to realize the default location for MySQL installation is under C:\wamp\bin\mysql\mysql5.5.20\data, whereas I was expecting it to be located under the C:\ProgramFiles\MySQL\ folder.

Mar 22, 2013

Creating SSL Certificates

Needed to do a bit of searching on the exact steps to create a ".cer" certificate. The default ssl-keygen will generate public and private keys, but this isn't enough for some applications. Some need a signed X509 certificate, which involves a couple extra steps. Note, because the certificate will not be signed by a trusted certificate authority, your browser/application may throw a fit and complain the certificate has errors. If that's the case, you can purchase an actual certificate from Verisign (very expen$ive) or from GoDaddy or some other lesser priced Certificate Authority your computer trusts. (Note, you could become your own certificate authority if you have complete control over the machines using your certificate. In which case, you can sign your own certificates and the browsers/apps will never complain).

Okay - let's get started. The following steps worked for me, and since I'll forget them, I've written them down as I'll likely need them again in the future.

First, run the ssh-keygen tool. 
cachedmemory>ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/cachedmemory/.ssh/id_rsa):
(Press Enter to accept the default location)
Enter passphrase (empty for no passphrase):
(Enter a passphrase if you like - it's more secure if you do)
Enter same passphrase again:

Your identification has been saved in /home/cachedmemory/.ssh/id_rsa.
Your public key has been saved in /home/cachedmemory/.ssh/id_rsa.pub.
The key fingerprint is:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx cachedmemory@localhost
The key's randomart image is:

You should have two files created in the default folder: id_rsa and id_rsa.pub. These are your private and public keys. Woo hoo!

Okay - lets get cracking on generating that certificate things like browsers use, the X509 certificate.

cachedmemory> cd .ssh
cachedmemory> openssl req -new -x509 -key id_rsa -out unsigned-cert.csr -days 1095
(Enter whatever values you feel are necessary.)

You now have a .csr file you can use. All set!