Monday, October 27, 2014

Android Deprecated My App

So after getting sidetracked with other upgrades and updates, I finally got to working on updating my Android app to use the latest version of the software development kit, version 21, called Lollipop.

As I started reading about the changes, I realized that Android was deprecating an api called getRecentTasks with a new package called android.app.usage.

At first glance, it looks like this new API will give me a lot of the same information that I struggled to get on my own. Because this API didn’t exist before, I had to do use Broadcast Receivers to periodically check on the state of the phone and figure out which app was in the foreground. I always had some lingering fears that I was draining the phone of its power or could potentially do some other damage to the phone by having something run in the background so often.

So the new android.app.usage API is great news. I can rely on that to fetch data, instead of my own home spun solution.

Of course, things aren’t so simple. Since many phones will not have the latest APIs, I will still have to support using my own home-made solution, and switch depending on whether a phone is ready.

I think it will be an interesting software challenge to refactor my code to support both the old and new sets of APIs, while keeping my code as clean as possible …

Resources I used …

Sunday, October 26, 2014

Weekend updates

I sat down at my computer this weekend to do a little update – testing my Android App with Android 5.0 (Lollipop) and incorporating some elements of Material Design.

Unfortunately, I never really got started.

I lost an hour updating my computer to OS X Yosemite. Then, I lost time reading about and playing with the shiny new OS update. When I tried to start working again, I found that macvim was no longer working. I lost some more time realizing that I needed to update Xcode and its command line tools to get macvim to work.

I was about to get back to my original task of updating my Android App, when I found out that my listng in the Google Play Store required a ‘feature graphic’ (something I didn’t have). So, I fired up Gimp, read through this (helpful tutorial)[http://www.gimp.org/tutorials/Floating_Logo/] and created a very crude image to serve as my feature graphic. If I ever make it big, I’d love to contract this sort of work out.

So, I finally got to the main task, and I started downloading the files for the new SDK. But downloading the SDK has been taking a while, so I started writing this post.

It feels like one of those days where things aren’t working out for me.

Resources I used …

Thursday, October 16, 2014

ELK.stack.on.my.laptop

ELK Stack

Combining Elastic search, Logstash, and Kibana (ELK) gives you an easy way to analyze logged data. The typical pipeline goes like this.

  • Some tasks output logs into files.
  • Logstash monitors those files.
  • Logstash translates those logs into records.
  • Logstash saves the records into elastic search.
  • Elastic search indexes the logged records.
  • Kibana allows you to query the elastic search engine

It is a powerful combination, so I wanted to give it a try.

I followed the steps outlined in http://aarvik.dk/a-bit-on-elasticsearch-logstash-kibana-the-elk-stack/ . You can obviously do the same, but here are my notes on the process (I did this on my Macbook Air).

Get the files

curl -OL https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.0.tar.gz
curl -OL https://download.elasticsearch.org/logstash/logstash/logstash-1.4.0.tar.gz
curl -OL https://download.elasticsearch.org/kibana/kibana/kibana-3.0.0.tar.gz

It is amazing that all of this is completely free to download and try out.

Testing each of the downloads

# Start your (elastic search) engines ... 
elasticsearch-1.3.4/bin/elasticsearch
curl -X GET localhost:9200
curl -X POST localhost:9200/person/1 -d '{ "info" : {"height" : 2, "width" : 20 } }'

# Testing logstash with command line arguments:
logstash-1.4.0/bin/logstash -e 'input { stdin { } } output { stdout { codec => rubydebug } }'
# or run with a config file
logstash-1.4.0/bin/logstash -f ./logstash.conf

I used the same logstash config file listed in the reference page I noted above. However, I did change one of the inputs to read from /var/log/system.log . At this point, I just wanted it get input from a file I knew was geting updates.

Setting up a local web development server - apache

In order to use kibana, you need a web server. Luckily apache is pretty much ready to use on Macbooks. I followed steps outline in http://ole.michelsen.dk/blog/setup-local-web-server-apache-php-macos-x-mavericks.html. Update The setup is slightly different for Yosemite.

I followed that site to get my server started, until my browser said "It works". Then I configured kibana to use my elastic search engine. To do this, update kibana/config.js to have this line:

elasticsearch: "http://localhost:9200",

This replaces -->

elasticsearch: "http://"+window.location.hostname+":9200",

This works because everything is on one machine. Finally, I moved the kibana folder over to be read.

mkdir ~/Sites
cp -r kibana-3.0.0 ~/Sites/
sudo apachectl start

You should now be able to visit your kibana dashboard at http://localhost/~username/kibana

Conclusion

Getting the ELK stack up and running was really easy. Hopefully I can think of a way to put this cool technology to good use.

Resources I used ...

  • http://aarvik.dk/a-bit-on-elasticsearch-logstash-kibana-the-elk-stack/
  • http://ole.michelsen.dk/blog/setup-local-web-server-apache-php-macos-x-mavericks.html

Wednesday, October 15, 2014

Blogging with Vim, Dropbox and StackEdit

The past

I have been using Blogger (formerly blogspot) for a while. It’s the obvious choice for any new blogger. It’s free, it’s easy to use and it’s from Google.

However, I have always sort of hated using the graphical user interface provided by Blogger. It doesn’t work offline so well. Sometimes it crashed and I lost some work. I couldn’t use my vim text editing skills. Jumping between the WYSIWYG and the HTML code mode sometimes caused erratic behavior.

The future

Given my distaste for Blogger’s given tools, I am trying out to find a new workflow. It’s a bit convoluted for now, but these are new steps that I am doing now to write posts:

  1. Go to a folder within my Dropbox directory called Blogposts.
    I will be creating files locally, which will be synchronized (backed up) to my dropbox folder.
  2. Write the original blog post in Markdown with vim.
  3. As I write, I preview what the formatted post looks like with Chrome and the Markdown Preview Plus Chrome extension.
  4. When I am done editing, use StackEdit to a) open this file (available through Dropbox) and b) publish to blogger.