Michael de Silva's Blog

Software Engineer. Rubyist and Roboticist.

Michael de Silva's Blog

Software Engineer. Rubyist and Roboticist.

Got an app in mind?

Since 2010, I have crafted apps for mobile and web for clients around the world via my consultancy — Inertialbox. My specialities include Rails, client-side Javascript frameworks such as Backbone & Ember.js, TDD/BDD, and DevOps — just to name a few.

We should talk.

Instrumenting Android UI with Espresso and AndroidJUnitRunner

August 2016, and I cannot believe the number of hoops I had to jump through, and several hours of Googling just to be able to Setup Espresso in Android Studio.

The bit that I needed was to perform a certain exclusion,

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2')
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support:support-annotations:24.2.0'
androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.0') {
    exclude group: 'com.android.support', module: 'support-v4'
}

Works great with an API 23 app I'm working on for a client. Just make sure that you add testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" into your app/build.gradle's defaultConfig block.

First CryptedIoT Dev Boards (PCBs)

The very first boards have arrived and they are looking rather purdy...

Looking to the Future

Some may wonder as to the drastic drop in blog posts over the past couple months but it's due to my being far more engaged with both work, family, and life in general.

I've been able to take time out from my work as a Consultant and spent a glorious get away at Peace Haven Anantara in Tangalle, Sri Lanka (second time around) availing all the delights of both private butler service and our very own private villa and plunge pool as well as spending around 3-nights at the newly opened Shangri-La resort in Hambantota, as well as catching up with family visiting us from Switzerland.

This time has allowed me to reflect on my past achievements, strengths and weaknesses, areas for improvement and generally where I want to take my career over the next 10 years. It's similar to how in most interviews, you get tossed that eventual question of "Where do you see yourself in the next 10-years?" — well that is what I've been asking myself as well.

My work with global brands s ...(continued)

Why Constant Learners All Embrace the 5-Hour Rule

Benjamin Franklin did this one hour a day, 5 hours a week. Why you should do it too.

At the age of 10, Benjamin Franklin left formal schooling to become an apprentice to his father. As a teenager, he showed no particular talent or aptitude aside from his love of books.

When he died a little over half a century later, he was America's most respected statesman, its most famous inventor, a prolific author, and a successful entrepreneur.

What happened between these two points to cause such a meteoric rise?

Underlying the answer to this question is a success strategy for life that we can all use, and increasingly must use.

The 5-Hour Rule 

Throughout Ben Franklin's adult life, he consistently invested roughly an hour a day in deliberate learning. I call this Franklin's 5-hour rule; 1 hour a day on every weekday.

Franklin's learning time consisted of:

  • Waking up early to read and write.
  • [Setting personal growth goals](h ...(continued)

CAP and Concurrency with Multiple Worker Processes

Anyone who's played with distributed systems knows the kind of pain one would end up with. There's mutex/transaction locking, pessimistic locking, and then there's the joy of dealing with multiple concurrent workers, running jobs asynchronously

Having played with Searchkick I stumbled on an interesting discussiong on race conditions which ultimately led me to 'Preventing Race Conditions With Fencing Tokens In Rails'.

And if you haven't heard of it before, this falls under CAP theorem.

Thankfully a friend of mine was to the rescue regarding a particular usecase of mine with,

Multiple workers can't get into a split-brain if they're all talking t ...(continued)

You can get US$200 for FREE from Amazon. Cold hard cash.

Here's how you can make some free cash, if you're living in the US.

First, go order an Amazon Fire TV Stick for $39.99 (use free shipping of course!). Now, order 2x units of Amazon Echo Dot = $179.99 outlay.

Sell it sealed on eBay as an auction - look at the past auctions. These go for $160-190 each!

You're set to basically make ~$120 or more if you keep the Fire stick. Otherwise, you can turn a profit of $160-$200 quite easily. Just return that Fire stick.

Using BrowserSync and Gulp with the Rails Asset Pipeline

I have detailed this approach in a simple gist which allows you to run BrowserSync along side a Rails app and its asset pipeline quite nicely — I have tested with a Rails 5 app that I'm currently working on for a client.

A while back I created a Yeoman Foundation Generator that included BrowserSync and getting a similar work-flow for Rails has been on my TODO list. For the longest time, I've relied on Rack::LiveReload and guard-livereload, which has its downsides — as CSS injection doesn't always work, and the browser takes a while reloading.

You simply need to add in the gulpfile.js as detailed below and make sure you install dependencies via npm install -g npm and npm install --save-dev gulp browser-sync. If you're already injecting Rack::LiveReload into your app middleware, stop doing that and you'll be set!

<script ...(continued)

HOWTO: Providing Clients with an IAM Account to Manage Billing & Payment Methods for their Root AWS Account

Pay credit card online

Start by heading to the IAM management console within your AWS console, and head to Policies. Create a policy and name it ViewAndManageBilling.

Use the policy document provided below to configure this policy.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1460354930000",
            "Effect": "Allow",
            "Action": [
                "aws-portal:ModifyBilling",
                "aws-portal:ModifyPaymentMethods",
                "aws-portal:ViewBilling",
                "aws-portal:ViewPaymentMethods"
            ],
            "Resource": [
                "*"
            ]
        },
        {
            "Effect": "Deny",
            "Action": "aws-portal:*Account",
            "Resource": "*"
        }
    ]
}

Create a group called 'Billing' in Groups and now you can create your client IAM accounts and assign them to the Billing group. It's a good idea to log-in and confirm e ...(continued)

Sneak Peak: Building a Ruby Gem to Provision Amazon AWS Services

Here's a quick demo of a Ruby gem that I'm in the process of designing, well at least its internal DSL, wrapping around the excellent aws-sdk gem by AWS.

I wanted to take a dependency based approach rather than resorting to Cloud Formation, which ultimately is a visual 'wrapper' around the AWS APIs — this could easily be achieved in other languages such as Python or even with a bunch of bash scripts.

However, as a Rubyist, I wanted to take the 'gem' approach, as this would allow me to integrate this into other apps, i.e. I could create an inertialbox internal dashboard type app, or even route calls through to an iOS app — potentially far fetched considering the amount of polish and time it would take to go that far, but at least, this serves as the initial groun ...(continued)

Feeling Refreshed, Back from Taking Time Off (April 2016)

I have been coding full-time for the past 6-years, straight with very little 'down time' or gaps in my resume. Everytime I've finished working with a client, I've transitioned into a new project with a new team.

In terms of building experience, it has been great and my newly deployed resume at http://desilva.io shows it. Just this week I had a couple interviews, having gained attention on Twitter that I'm now looking for work — and recognition of my past work is rather rewarding.

Whilst looking forward to the next project I take on, I have some plans for making some improvements to my AWS deployments, and those details will serve for a future blog post.

Post Archive