Saturday 5 July 2014

Rooting UG007 AKA Mobicity's Android MiniPC on Ubuntu 14.04

ADB

  1. Plug the stick into the TV then in the settings enable debugging
  2. Unplug the device
  3. Install adb: sudo apt-get install android-tools-adb
  4. Create a new conf file: sudo gedit /etc/udev/rules.d/51-android.rules
  5. The file should contain only the following line, replace <username> with your username: SUBSYSTEM=="usb",ATTR{idVendor}=="2207",MODE="0666",OWNER="<username>"
  6. sudo service udev restart
  7. gedit ~/.android/adb_usb.ini
  8. The file should contain only the following line: 0x2207
  9. adb kill-server
  10. adb usb
  11. Plugin the device
  12. adb devices
Note: 0x2207 is the hex code for the UG007 device

Adapted from: http://www.slatedroid.com/topic/37572-how-to-adb-under-linux-solved/

Rooting

Download SuperSU
adb push psneuter /data/local/tmp
adb shell
$ cd /data/local/tmp
$ chmod 777 psneuter
$ ./psneuter

adb kill-server
adb devices
adb shell
ADB shell prompt should now be a hash '#' to indicate root
# mount -o remount,rw -t rfs /dev/block/st19 /system
# exit
adb push busybox /system/bin
adb push su /system/bin
adb push su /system/xbin
adb install Superuser.apk
If the install hangs or otherwise doesn't work: adb push su /system/app
adb shell
# chmod 4755 /system/bin/busybox
# chmod 4755 /system/bin/su
# mount -o remount,ro -t rfs /dev/block/st19 /system
# exit
adb reboot

Based on this guide from step 12. There are some key things that do not work - in particular adb install Superuser.apk and also I had to use SuperSU (apk filename is the same).

Monday 30 June 2014

Brandscreen: Debian All the Things! Puppet All the Things! Teamcity All the Things!

Brandscreen has a high level of automation for deployment and configuration. The graphing and monitoring is also critical for deployment.

Debian

All code releases at Brandscreen are packaged as deb packages and a number of reference files are also packaged as deb packages. Configuration is nearly all done through puppet. Any cron jobs simply call a wrapper.

A number of third party applications, including pip packages, were packaged as debs.

The deb packages are all installed in a repository. The dependencies made it easy to upgrade and downgrade packages. Therefore we could release very frequently with the confidence that if there were any problems the software and configuration could be rolled back easily.

Puppet

Puppet is used for all configuration that is not handled by a debian. Also most tasks are performed using puppet. Very little is performed using ssh.

Graphing and Monitoring

Brandscreen uses Teamcity to build and deploy releases. We generally deployed to a canary first, then checked the graphs in Graphite and Gdash. If there were any issues the release would then be rolled back.

Some of the items which were graphed in GDash are:

  • discrepancy with partner
  • CPU usage
  • disk throughput
  • disk space used
  • network throughput
  • memory usage
  • partner bid requests
  • partner bid responses
  • partner impressions
  • clicks
  • number of log files
  • pricing
  • response times
  • spending
  • offline requests
  • many many many other things that would give away proprietary information :)
I really can't understate how cool GDash is. And graphite itself is er useful. Here is an example from the GDash website:

Many other items including custom logging is available through graphite itself. The data was collected through collectd.

For other systems logs were processed through logstash and presented using Kibana.

Nagios and pagerduty are used for monitoring. To present the graphs for big screens newrelic and geckoboard are used.

I will go into more detail on graphing and alerts in a later article.

Teamcity

Teamcity is used to build, package and test each check-in. In addition deployment is done through teamcity.

Monday 23 June 2014

Brandscreen: Hive vs. Redshift

Redshift is an instance of ParAccel's 'Big Data' database offered through AWS. It is similar to Netezza and is similarly based on Postgres.

Redshift is relational and ACID compliant, however the types available are limited, there are no indices and no stored procedures.

That doesn't sound great until you start working with data. Redshift will typically be significantly faster working on atomic data than a traditional Oracle or SQL Server installation dealing with summarised, indexed data.

Redshift is also significantly faster and lower latency than using Hive. In addition the AWS pricing makes Redshift more economical for frequent jobs than Hive.

Monday 16 June 2014

Brandscreen Technology: Hive

Hive is a technology that sits on top of Hadoop which allows the searching of text files using SQL  statements.

org.apache.hadoop.hive.contrib.serde2.RegexSerDe in hive-contrib may be used to process irregular text files (e.g. webserver logs).

Hive can directly use CSV files and can directly use s3, which is particularly useful when staying inside the AWS environment.

Key steps to running a query are:

  1. Files in s3 should be laid out as <root>/<top key>/<partition key1=value1>/<partition key2=value2>...
    1. e.g. s3://test/logs/dt=2014-06-16/hr=15
  2. Startup up EC2 for Amazon, login using SSH to hadoop@<master node name> using the pem key you set up for Amazon
  3. 'Add' any external modules (such as hive-contrib) if required
  4. CREATE EXTERNAL TABLE with, specifying:
    1. PARTITIONED BY with partitioning matching partition 1... in step 1
      1. e.g. PARTITIONED BY (dt string, hr int)
    2. ROW FORMAT as:
      1. DELIMITED FIELDS
      2. SERDE (with regex)
  5. ALTER TABLE xxx ADD IF NOT EXISTS PARTITION (key1=partition1...);
    1. e.g. ALTER TABLE abc ADD IF NOT EXISTS PARTITION (dt=2014-06-16, hr=15);
    2. A separate ALTER TABLE statement must be provided for each partition required
  6. Query all the things! Just the same as a normal SQL query
The advantages of Hive are that you don't need to import your log files into a database in order to query them. The disadvantage of Hive is that although it has good throughput it has very poor latency. Some tools such as Shark may be able to mitigate this problem.

Friday 30 May 2014

A Quick Tour of Brandscreen Technology

This article is more likely to be more like a shopping list than an article. Its main purpose is to act as a reminder for when I have time to write a longer article. Items which are starred I have had some interaction. I am not claiming to have set up the systems I have starred.

Packaging and Deployment

  • Debian all the things*
  • Debian repository
  • Teamcity (build and deploy)
  • MSBuild
  • Puppet
  • Vagrant*

Monitoring

  • Nagios
  • Graphite*
  • Sentry
  • Collectd*

Data

  • AWS
    • Hive (on Hadoop)*
    • Redshift*
    • S3*
  • SQL Server
  • MongoDB*
  • Formats:
    • JSON*
    • Protobuf / BSON*
    • CSV*
  • Cassandra

Software Engineering

  • Confluence*
  • JIRA*
  • Rhodecode*
  • Mercurial*
  • Google Mail*
  • Hipchat / Skype / Google Hangouts*

Technologies

  • C++*
    • gtest*
    • protobuf*
    • Boost*
    • Poco*
  • Python*
    • Django*
  • .NET

Monday 27 January 2014

Book Review: Frankenstein

Frankenstein

Although the writing is at times awkward, Shelley explores a number of interesting ideas in this book. 

Dr Frankenstein creates a monster. More like a meat puzzle than the relatively tidy later depictions. One question raised is what is life and what is it to be human? The Monster in fact is superhuman - stronger, smarter and faster than it's creator.

The Monster is driven toward murder and psychopathy by the hatred showed by the human race.

Worth reading, although there does seem to be a good deal of padding at the beginning.

Title: Frankenstein
Author: Mary Shelley
Rating: 4/5

Saturday 4 January 2014

Book Review - 2001: A Space Odyssey and Catch 22

2001: A Space Odyssey

Who would have thought that it was possible to get stranger than the movie of 2001: A Space Odyssey. Well buckle up because this book does it.

The premise of this book is that some form of alien race has left a crystal block which is capable of giving the spark of knowledge to humans.

A major theme of the book is questioning what is life and what is a mind - particularly with HAL the homicidal computer.

Title: 2001: A Space Odyssey
Author: Arthur C. Clarke
Rating: 4/5

Catch 22

This novel was the origin of the term "catch 22" relating to paradoxes. It details the descent into madness of a bomber pilot, Yossarian. The story gives a sense of being trapped, the insanity of war and the reader shares the state of confusion which Yossarian finds himself in.

The concept of catch 22 centres around the paradox that to be found unfit to fly due to insanity the pilot must request to be sent home. However requesting to be sent home - away from dangerous missions - is a sign of sanity. Thus it is not actually possible to be sent home.

An interesting literary device which the author used was to write some text that was so over the top that it throws the reader out of their imagination. Normally this is a very bad thing for writing or movies (Matrix 2 freeway seen for example) and is normally a sign of poor writing rather than a technique.

In Catch 22 however this device is used with a certain rhythm and the confusion of the reader being thrown out of the book helps the reader to share the confusion that Yossarian is facing. As the book progresses Yossarian begins to hallucinate and become paranoid.

He is at war though - so people really are trying to kill him.

An excellent novel which I thoroughly enjoyed.

Title: Catch 22
Author: Joseph Heller
Rating: 5/5