Tuesday, November 26, 2013

clearer code using underscore chaining syntax

I was working on a story with a client that had to take a list of filters and intersect them.

Using uderscorejs and the reduce and intersect functions i implemented a fix. Below is an example implementation of said functions

   val1 = _.reduce([1, 2, 3], function (v, a) {
        return v + a;
    });

After pushing this, I noticed not everyone was familiar with functional programming and found it taking a little bit longer to wrap their head around the code from a readability point of view

I decided to take a second dive but this time focus more on the readability. 

 val2 = _([1, 2, 3]).reduce(function (v, a) {
        return v + a;
  });

And the crowd went... no crowd... but in my head they cheered and bought me nachos!

Tuesday, August 13, 2013

my foray into javascript

I was an Oracle PeopleSoft developer for over 5 years and just over a year ago decided to write custom software using non proprietary tools (JAVA, Ruby, e.t.c) with .Net being an exception. I've been doing back end development in Java and have had very little contact with Javascript. 

On my present project, we ran into a bug when refactoring some JavaScript. This bug involved comparing two objects using a predicate being passed into an underscoreJs function _.some.

For those not familiar with underscoreJs's _.some, it takes a collection and a predicate, and returns a boolean if a search based on the predicate matches or not as seen below:


When you try this with an object, it fails. This made us scratch our collective heads for quite a while. running this fails:


The solution was to use JSON.stringify(arg) to convert the object to string literal. This would not work if the fields in the object are not in the exact order as shown below. Preferably you should compare on the object fields. But for what we wanted, that was not an option.

Saturday, August 10, 2013

insurance, lost wallet and passbook

A few months ago my wallet got stolen, it involved lots of kung-fu fighting, ninjas and pirates, but unfortunately, they won. I did put up a good fight though. ٩◔̯◔۶

Anyway, as with all victims of stolen wallets, I had to cancel my credit cards and the whole nine yards. I got most of my cards replaced, except my medical insurance card. In reality there are some cards you do not need to carry on you, the only information that's needed from them is some identification number. So I thought to myself; how can I store my info where it can be easily accessible? Email! Google Drive! DropBox! Just take a picture, upload it and viola, use your fancy phone and there it is!

All that made just too much sense and was way too simple! I needed something more interesting, more techy, time consuming and equally useful. Then came PassBook!

I scoured the universe looking for articles to create just a passbook pass and then saw this amazing figure everywhere $99, so I modified my search adding the discount code "free" and came up with this site passkit.com. They are not free, but they let me template stuff for free and install it, then keep it for $0.99 on my device.
 

I created a template for my Insurance provider under my present place of employment ThoughtWorks and made it publicly available. I have no idea how long the free account lasts, but it can be found here


Password protected, use the wifi password for ThoughtWorks
Serial No: <<Your Insurance ID >> this helps generate a barcode that spits out your ID when scanned.

Modify the details to add your name and Insurance ID, then the passbook is created and stored automagically! (Look at that, the dictionary did not complain with red squiggly lines, automagically is a word, who knew? *types "techy"* hmm now its asking for my English teacher's name ).

It also asks you for your email so you can retrieve a new pass if your phone gets lost, stolen or replaced. 

Screenshot: Click for larger image



Let me know what you think and if this is something worth building an in-house  API.

init

Well This is my first blog post, so come back here for my musings, questions, and new found awesomeness that I always seem to be the last at finding out... They slice bread now? Wow, what's next? Cloning?

Seriously, my reasons for starting this blog are:
  1. Improve my writing skills! More like attain one first.
  2. Share my knowledge and resourcefulness in acquiring said knowledge to help advance my career

Does this support comments?