Sunday, November 3, 2013

// // 1 comment

RescueTime weekly summary and Google Script

I was cleaning up my mac before handing it to systems on my last job. I had a couple of days just for the Knowledge Transfer of projects and nothing else. I have always run two or three passive self policing apps like Rescuetime and Timing etc.,

I have been using Rescuetime for little over two years. Since I'm a cheap/free user, I cannot use their premium features like view or export past data. However, they send a weekly summary email with enough data. So I was curious to know the pattern of the way I work.

I wrote a small Google script that parses the text part of their email and save it in a Google Spreadsheet for analysing.

Though I have two years of rescue time summary email, there are two different template. So I have parsed the email since Jan'13. (I believe they recently changed the template as of Oct-13.)







I was quite happy that I am not that lazy ass as I thought. I have spent quality no. of hours on Software development and Utilities. Utilities are mostly Terminal/iterm2, nvalt, custom tools I use outside of IDE but related to development. And I see I am consistent with my productivity % and the way no. of hours logged per week.

You can find the script here and the spreadsheet template I use to find the data here. I have cleared the content of "mail" sheet after running the "collectSummaryEmails" method from your clone of the sheet, you should see data from your Gmail. I left the other sheets with the data so you can follow.


Read More

Sunday, August 18, 2013

// // 1 comment

Raspbian + XBMC + Airplay

TL;DR: Yes, you can. If you are only interested in the steps skip to the relevant section.

I own a Raspberry Pi for closer to a year now. I was not able to use my Netgear N150 (WNA1100) dongle until last week with it, I was kind of lost my enthusiasm by this bitter experience and hold my experiments for long time. Other than installing some console emulators and XBMC in last 6 months, I have not done anything with my Raspberry Pi.  You can refer my adventures here and here.

Ever since I heard about Pidora (Fedora distribution for rPi); I wanted to try Pidora to check whether it supports my wifi dongle. I also recently learnt that Raspberry team officially announced Berryboot alternative called NOOBS (technically both are not same, I believe with Berryboot you can dual-boot with multiple OS). I got curious and finally took a day off to try.

NOOBS packs 6 OS for rPi. Raspbian, Pidora, Risc OS, RaspXBMC, OpenElec, Arch linux) in a 1.2G zip file.

I have tried Arch, Risc and Raspbian in the past, and I was not able make my wifi dongle work with any of them.

Much to my surprise with stock Raspbian disro my WNA1100 got detected and connected to my wifi out of the box; almost zero steps.

Steps:

  • Download NOOBS archive and unzip into your SDCard.
  • Reboot to your SD card and select Raspbian from the welcome screen.
  • This should wipe your SDCard and install Raspbian in about ~15 minutes. Not to worry you can still have all the OS available for you to install later.
  • Once Raspbian boots for the first time. Configure  your network (eth0 or wlan0).
  • Do the usual system upgrade by running the following command in terminal.
    sudo apt-get update
    sudo apt-get upgrade
  • Install XBMC by running the command. This should install XBMC and its dependencies
  • sudo apt-get install XBMC
  • Install Airplay daemon by executing the command
    sudo apt-get install avahi-daemon
  • Once avahi installed, Enable Airplay in XBMC -> system -> services -> Enable Airplay services.
That is all to it, once your iDevice and Raspberry are connected to same network you should be able to share photos/Videos/Audio via Airplay from your iDevice to Rasbperry Pi.

Other Notes:

  • Instead of dd-ing the image to SD card, install it directly on rPi. If my memory serves me correctly, my Macbook Pro late 2010 took almost 40-60 min to dd Raspbian image to the SDCard. Where as installing Raspbian with NOOBS, directly on rPi took only about 15-20 minutes.
  • I couldn't get my wifi configure with hidden SSID.
  • For those who keeps tab: I did try Pidora, it was very slow compared to Raspbian and I was not able to configure my wifi dongle with it.
  • If you are only looking for media center, I would suggest you to try OpenElec distribution from NOOBS. It is noticeably faster compared to XBMC on Raspian and RaspXBMC distro.
  • Keyboard is not functional when XBMC displays onscreen keyboard. The workaround at the moment is to execute XBMC as super user.
    sudo XBMC-standalone.
  • XBMC does not support Airplay mirroring. However there is a new application called rPlay seems to solve this problem.
  • Not sure if rPlay is a free application. The folks at rPlay are kind enough to share a licence as a beta tester. I have not tested it yet.

Why Raspian + XBMC

 Well, I'm a greedy b!@$%!$d, I want to use it as linux machine + media center + airplay receiver + gaming console. So direct boot to OpenElec is not my solution.

Other Links


Since I have checked off this task, now I can buy Apple TV and still be proud that I had configured and played with Raspberry Pi as Apple tv alternative ;-)

Read More

Saturday, July 20, 2013

// // Leave a Comment

Grep - Swiss army knife


I have used this command sparingly in the past and I recently learnt more options by solving couple of my problems. I really don't know whether grep is the right choice here, but hey! it worked :-)

Problem 1: Filtering CSV

I had a very large CSV file of size 620Mb, a report exported from salesforce. I have to find the duplicate accounts and contacts with same email id.

Excel and Numbers were either crashing or taking light years to respond to any of the action I had to perform on the data.

The CSV was in the format:

Email: unique@domain.com

Contact: 1 Sales Contact
Duplicate Contact 1

Email: duplicate-exists@domain.com

Contact: 2 Sales Contacts
Duplicate Contact 1
Duplicate Contact 2

Email: duplicate-exists@another-domain.com

Contact: 3 Sales Contacts
Duplicate Contact 1
Duplicate Contact 2
Duplicate Contact 3

I knew I could just see how many contacts has duplicates by simply doing a grep -i 'contacts' | wc -l but I would like to know the email id associated with the contacts which is not in the same line.

Quick search on man grep lists an option to print previous lines in addition to the line which matches the string. Here is the recipe I used to solve the problem.

#this is to return all emails and sales contacts
Ξ ~/Desktop → grep -B 2 'Contacts' filename.csv | grep 'Email:'

From Manual 
-B num, --before-context=num
    Print num lines of leading context before each match.  See also the -A and -C options.

 

 Problem 2: Objects and APEX classes linked to a particular object.

We are in need to provide effort required to do an impact analysis of migrating an existing salesforce object to a new object. This activity includes identifying the no. of classes has a reference to the object in question and an effort estimate to analyse those source files which has also has a reference to the object.

To arrive an approximate effort estimate, we need a list of files and no. of lines of each files.

Salesforce Schema browser is not very helpful if I want to know just the _number_ of objects associated, not what is the relation and how it is related to another object. And it is also a real pain to collapse and follow the links/pipes in a production environment with larger number of objects.

Like every other occasion, management was asking the numbers as soon as possible. And developers were doing a Ctrl + F on Eclipse on classes and counting the no. of files. I could not suggest or question the team as I have only very little knowledge about salesforce APEX development.

Since I am the author of iForce (a Sublimetext extension to help salesforce development) I knew that all the files are just text with metadata. So If I know the pattern to search for I could use grep to get the list of files and pipe it to wc to get approximate number we were looking for.

Well, it took more time to finalise the pattern of object usage in APEX code than to find the number. Also the default payload.xml of iForce doesn't fetch all the required objects so I had quickly replaced the payload.xml on my iForce working copy with the one from Eclipse workspace.

Once I refresh my iForce working copy with one from the server, the answer is just a minutes away. Here is the list of commands I ran to get the number, I just copied it to excel, formatted columns with bright colour background for the people above my food chain to process ;)

Ξ salesforce-sandbox/classes → grep -iE 'new contact||new account|' -l *.cls |wc -l
    
Ξ salesforce-sandbox/triggers → grep -iE 'new contact||new account|' -l *.trigger |wc -l
      
Ξ salesforce-sandbox/components → grep -iE 'new contact||new account|' -l *.component | wc -l

P.S: Though count from wc -l doesn't provide the meaningful number of lines as CLOC. But I was in a hurry, and I have not tried CLOC with APEX code.
Read More
// // Leave a Comment

Link: This is Linus

Last week Zite suggested this article, I've known about Linus and his rude comments. But reading this article, I realised that being polite is not right solution for everything. Having the experience of working with the many developers over the years, I met only very few people who act on subtle comments I pass during discussion about code/best practices. The rest just ignore and do what they have always been doing.



The fact is, people need to know what my position on things are. And I can't just say "please don't do that", because people won't listen. I say "On the internet, nobody can hear you being subtle," and I mean it.

Because if you want me to "act professional," I can tell you that I'm not interested. I'm sitting in my home office wearing a bathrobe. The same way I'm not going to start wearing ties, I'm *also* not going to buy into the fake politeness, the lying, the office politics and backstabbing, the passive aggressiveness, and the buzzwords. Because THAT is what "acting professionally" results in: people resort to all kinds of really nasty things because they are forced to act out their normal urges in unnatural ways.

At times you need to be King Leonidas and kick them hard so they learn and do not repeat the mistake.

Link: Linus Torvalds defends his right to shame Linux kernel developers
Read More

Sunday, July 7, 2013

// // Leave a Comment

WWDC'13 - Hidden Gems in Cocoa and Cocoa Touch


If you did not have enough time to go through the 50G contents from WWDC'13, I highly recommend you to watch the session 228, aptly named "Hidden Gems in Cocoa and Cocoa Touch".

Links: PDF | Video - SD | Video - HD

There were like 30+ tips, if you are interested my score, it is only 8.

Third year in a row, I published the compiled list of sessions and download links here. Note: You need iOS developer program credentials to download the files.

Read More

Sunday, April 28, 2013

// // Leave a Comment

Request To Webdevs: Include Ip/User-Agent Info In Forgot Password Email


The Forgot password email template has been the same for more than a decade. It is time to include more information in the email.

Here are the couple of Forgot password email I received from Facebook and Twitter recently. Both of them were not initiated by me, my Facebook account is deactivated a long time ago. I have also recently changed the email id to a different email id, and I still receive at least once every month.





I suggest to send more information to the user to take decision. For eg., Gmail displays a notification bar if there are any suspicious activity, like login from two different countries in short span of time. Other webapps should also do the same, it is not 2004 anymore. People ignore these emails if they don't initiate it, and the web apps don't have enough information to block the IP if there are patterns.

So kindly include information like IP Address, Browser Agent, Country/State if possible.


Read More

Saturday, April 27, 2013

// // 1 comment

Some funniest moments from my appraisal

I had my one-on-one meeting for 2012-13 appraisal this week. I was disappointed with the feedback given to me. Well, I have been working for very long time, and I know if you are not hurt then it is not an appraisal.
We received a lo..ong email from my manager couple of days before the one-on-one meeting, explaining his expectations from resources. A week after we submitted our self appraisal. Though unofficial first rule of appraisal is not to talk about appraisal, I couldn't help myself from posting this.
  • We have raised our bar, so no one get 4. (Points: 1-worst, 4-best)
  • Discipline: 1 Reason: I'm not available in office at 9am.
  • Communication: 2 Reason: My emails were always short, 3 to 5 sentences.
  • Kaizen/continuous improvement/initiative and resourcefulness: 1 Reason: You didn't participate in any kaizen/improvement or initiative
  • Interpersonal skills: 2 Reason: It is my honest feedback.
  • I got three on other parameters.


 --- ✄ ----
We have raised our bar
If no one get a 4, what is the point in keeping?

Discipline : I'm not available in office at 9am.
Our official work hours starts at 9:30 and only handful of people (less than 5) including security  on the days I go early. I have asked is the only parameter? their answer was yes. They don't consider the fact my flexi-timing is actually 11:30 - 8:30 and I log 12+ hours a day  at least once a week. Also not ready to consider, I need to support both AUS and US (CST) client.
I have explained my work timing numerous occasion, It is the way I could skip stupid traffic, and above all I ain't a morning person. On the days I go early I reach office at 8:00 and stay till 8:30.

Communication: My emails were always short, 3 to 5 sentences.
Yep, That is the only parameter. Oh! well, you don't use signature just name at the end.
  • Do you know sending a short email is the right way of doing it? 
  • Have you aware of three.sentenc.es or five.sentenc.es?
  • Any of my email were ambiguous?
  • Did you know I always send my vcard with all necessary info for the first time?
  • Do you know your signature breaks my search has:attachment workflow?
  • Did you ever find an attachment when required within seconds while you are on a call?
I didn't participate in any kaizen/improvement or initiative
  • Did you know anything about Joel Test?
  • Are you aware that I was the one who get repositories created in org's svn server and checks in code in whole of department?
  • Did you know I made sure the team know what is the use of SCM. And follow up with everyone  in team to ensure they check in code at least once a day? Well, he did call me and asked what is SCM? when reviewing my self appraisal :-(
  • Did you know none of other team's code gets a backup anywhere except customer organisation?
  • Are you aware of the fact I created a portal for the team to share knowledge? in which you are admin and receive notification?
  • I share articles within team (mostly inexperienced programmers straight from college) about new technologies, productivity (libraries, scripts, automation)
Interpersonal skills: It is my honest feedback
"It is very subjective" was the feedback. They didn't point me the direction on where to improve. One other feedback is, I stop them abruptly when talking. Well, it is intentional; If I don't get what they (customer) was talking about, I stop people harping "Yes, you are absolutely right".

One other incident this week, I was explaining benefits of native application over  mobile web. People on top of my food chain was saying native is not secure as we need to re-implement login and other security features, so it is better to go with the default features provided by salesforce. If it was not a conference call I could have stopped them and would have wrote "OAuth" on white board.

Writing about it more was actually a demotivating task, yet I did it. I may redirect this hate to write a manifest for my imaginary startup.


Read More

Saturday, April 20, 2013

// // Leave a Comment

Book Recommendation: Testing with coffeescript by Jack Franklin [Free ebook]

TDD (Test Driven Development) was introduced to me around 2006 with PHPUnit. As a naive, I couldn't see the benefits, eg., I saw the pattern of code has been updated very often (growing organically) and frequent failing test. I was like, Why should I write unit test to test my own code? with the same data I used for manual testing? As they say I was seeing the forest for the trees. I failed to realize the failing test is actually the benefit of practicing TDD.

I feel little embarrassed to admit that none of my projects followed unit testing or automated unit testing. Because of the kind of projects and technology I use in my day job. To clarify all my projects was always extensively tested but manually. "The Specs" are always in either comment or in commit logs.

Nowadays, I'm trying to introduce unit testing, automation/continuos integration wherever possible. I'm still learning, but I get the big picture now.

Though my only coffeescript was an utility script which I wrote to test the water. I got a chance to read this book on a weekend, it is only 50+ pages long and it explains how to practice BDD (Behaviour driven development) with Coffescript and Jasmine framework.

Did I say, the author Jack Franklin is only 20 years old? Kids these days :-) It took half a decade and 20-year-old to put me to shame for not practicing TDD/BDD earlier.

As they say, When in doubt always test.

Book link - Testing with Coffeescript by Jack Franklin

Read More

Friday, April 19, 2013

// // Leave a Comment

Disable networking/internet from command line on a Mac

If you want to quickly disable internet/networking to test offline features. Doing it frequently with System preferences GUI is quite a slow workflow.

Here is the command to disable your ethernet quickly.
sudo ifconfig en0 down
to activate it again
sudo ifconfig en0 up

If you are connected via wireless you can disable it with
networksetup -setairportpower en1 off
to activate it again, use
networksetup -setairportpower en1 on

en0 and en1 are device name, which you can get from running the following command
networksetup -listallhardwareports

Read More

Tuesday, April 16, 2013

// // Leave a Comment

IdeaVault - RPi dashboard

I couldn't help myself after listening to John & Marco discussion about the pricing of Panic's new app Status Board.

I agree with the pricing of the app, who could deny John's reasoning? With all due respect,  a dedicated iPad just to display a dashboard? sounds like diamond studded car. It is a overkill and I would argue you ruining the destiny of your iPad. It deserves more care than hiding behind your old TV/Monitor.

Raspberry pi is the right candidate for this task, though I guess Arduino is also cheaper solution, but from development perspective (I'm not sure, I have come across some nodejs modules), I would suggest to go with Raspberry Pi with Html5 (http://shopify.github.io/dashing/).

Wish I could develop a quick prototype that is compatible with Panic api for Raspberry store.

Read More