Go: Declaring and using objects

Go (or Golang) doesn’t have the concept of classes. The class equivalent in Go loos like this:

  // Make a Car class equivalent
  type Car struct {
    // object properties go here
    doors int


  // Get the number of doors 
  func (car *Car) Doors() int {
    return car.doors

  // Set the number of doors in a car
  func (car *Car) SetDoors(doors int) {
    car.doors = doors

The above declaration can now be used as an object like so:

  import fmt

  func main() {
    lamborgini := new(Car)

    fmt.Println("This lamborgini has: " + lamborgini.Doors()  + " Doors")    


First impressions of Go

I have been in search for a language I can use for web programming, writing computationally intensive and general scripting among other things. The language that came close to fitting all of these things was Racket, a dialect of Chicken Lisp. It can even do geometry drawings. However, there were issues with it so I ended up concluding it wasn’t that language in was in search of.

I started learning Go some time ago and, at first, found its syntax backwards. Declaring types after variable names was hard to get used to. And, the syntax for writing “classes” is even more weird. However, when I found out that Go supported concurrency (and parallelism) natively, I was intrigued. On a side note: default Python and Ruby interpreters do not support parallelism. PHP has some support through pthreads but using it could mean you not being able to use other extensions.

If you want to have a true parallel app in Ruby or Python you have to get the interpreter that runs on JVM. So, you Ruby code is run by the Ruby interpreter which is running on JVM. Ruby and Python support concurrency but their threads run one at a time. So, no parallelism.

Once you get past the syntax weirdness, Go is actually a pretty cool language. It makes it easy to write concurrent apps. They call them “go routines”. From what I have learned, go routines are cheaper to create and maintain than normal threads and the way Go is designed, it is very easy to communicate between threads (using channels). And, all of this makes sense since one of the goals of Go was to make multi-threaded network applications.

Those used to dynamic languages might find it a bit difficult to work with Go in the beginning as it is strongly typed. I was, however, able to adjust pretty easily (then again I have done C++, Java and C# in the past). Your mileage may vary but I highly recommend trying it out. You might like it.

Arduino Uncategorized

Programming Macros for Ergodox

The default configuration tool on Input Club or Massdrop don’t allow for macro programming. So you will have to get your hands dirty and mess with the firmware code a little. It’s not hard.

  1. Run the following commands on your terminal to clone Ben Blazak’s firmware code from github and create a custom layout for yourself
              git clone
              cd ergodox-firmware
              # Macros are supported in his partial re-write branch 
              git checkout partial-rewrite
              cp firmware/keyboard/ergodox/layouts/qwerty--ben.c firmware/keyboard/ergodox/layouts/qwerty--custom.c
  2. Open keyboard/ergodox/ and add qwerty–custom to the KEYBOARD_LAYOUTS and change the KEYBOARD_LAYOUT to qwerty–custom. The keyboard layout will look something like this :

    KEYBOARD_LAYOUT := qwerty--custom
    # default layout for this keyboard
        test \
        arensito--ben \
        qwerty--ben \
        qwerty--custom \
        colemak--kinesis-mod \
        dvorak--kinesis-mod \
  3. Edit keyboard/ergodox/layout/fragments/macros.part.h and create a function for your macro. As an example, we will do a macro that prints b4.

    // Define a constant for the keys
    #define K_4 0x5C   // 4
    #define K_b 0x05   // b
    // Our macro's name is m_b4
    void keys__press__m_b4(void) {
        // Press and release b
        usb__kb__set_key(true, K_b);
        usb__kb__set_key(false, K_b);
        // Press and release 4
        usb__kb__set_key(true, K_4);
        usb__kb__set_key(false, K_4);
    // Do this for all your macro functions
    void R(m_copy)(void) {}
  4. Now that the macro is ready, it can be placed in the layout. Put m_b4 for whichever key you want the macro to trigger. Edit firmware/keyboard/ergodox/layouts/qwerty–custom.c and put your macro in it.

        MATRIX_LAYER(  // layer 2 : symbols and function keys
    // macro, unused,
           K,    nop,
    // left hand ...... ......... ......... ......... ......... ......... .........
      lpo2l2,       F1,       F2,       F3,       F4,       F5,      F11,
      transp,   braceL,   braceR,    brktL,    brktR,      nop,   lpo2l2,
      transp,  semicol,    slash,     dash,        0,    colon,
      transp,        6,        7,        8,        9,     plus, lpupo3l3,
      transp,   transp,   transp,   transp,   transp,
                                                                  transp,     m_b4,
                                                        transp,   transp,   transp,
                                                        transp,   transp,   transp,
    // right hand ..... ......... ......... ......... ......... ......... .........
                   F6,       F7,       F8,       F9,       F10,      F11,      F12,
                lpo2l2,    caret,  undersc, lessThan, grtrThan,   dollar,  volumeU,
                         bkslash,        1,   parenL,   parenR,    equal,  volumeD,
              lpupo3l3, asterisk,        2,        3,        4,        5,     mute,
                                    transp,   transp,   transp,   transp,   power,
      transp,   transp,
      transp,   transp,   transp,
      transp,   transp,   transp  ),
  5. In the terminal, run make It will create firmware.hex
    Upload the file to Ergodox and your macro will be ready for use.

You can look up the hex codes for keys here:


What should I learn?

This is a question I get asked a lot. Mostly by those who are just starting off their career as programmers/developers, but often times also by veterans of IT field.

Recently, I found myself asking that question when I came to the realization that PHP, as a language was not as much in demand as it once was. Not that I didn’t know this before but it became more apparent when I moved away from New York. With hundreds of companies and their office, it was never hard for me to find a job with great pay. Now, not so much.

With new technologies emerging faster than a New York minute how do you keep yourself relevant and keep moving up that corporate/salary ladder? A big part of that is knowing which technologies are in demand and being able to predict if they will stay in demand long enough for you to never run out of work.

After some experimentation (and a lot of help from God), these are the things that helped me realize where the market is going and what I need to learn next.

  1. Search the job sites
    Check out various job listing sites (,, etc) and search for jobs of all the technologies you are interested in and take a note of how many jobs are available and what their salaries are.

    If you are planning to move soon, then perform this search for the city you are going to move to (or thinking of moving to).

  2. Talk to recruiters
    The first time I heard big data was increasing in demand is when a recruiter mentioned it to me. She also told me PHP was becoming more of a niche skill than a mainstream skill. So, I decided to learn Ruby. I have always been fascinated by the meta-programming capabilities of Ruby.

    However, I came across an article published by Stack Overflow which showed Ruby was even less (much less) popular than PHP. I haven’t stopped learning it though. It’s a fun language and I want to explore it more.

  3. Go to startup meetups and see which technology stack is being used

    A few years ago, Python was the popular kid on the block. All the cool kids (new startups) were using it. If you told someone, your new project was not in Python or Node, you were looked down upon (I wish I was exaggerating).

    The only reason I found this out was because I noticed that at networking events, most new companies were using Python and Mongo.

  4. Other Thoughts

    These three things help you get a general idea of what you should learn next. However, there other things you should take into consideration. What is the most important thing you want your employer or your job to have? If you like working 9-5 then find out what big companies are asking for. If you like the startup culture, then find out what they want.

    Sometimes, you don’t know what you want until you have gone through a few jobs. When I started by career as a developer, my first few jobs were great. I was part of planning process for projects and it opened my mind to all the possibilities. I enjoyed that a lot. I felt intellectually challenged and learned a great deal.

    Later on, one of the jobs I got was at a firm where my manager expected his team to be robots. On top of that he micro-managed everything. I hated it. I didn’t like being micro-managed. Some people prefer it. Some developers are okay with vague requirements, some get paralyzed by them. In an ideal world we would have clear cut business requirements, but depending on where you work, that is often not the case. You need to figure out what you want and then narrow down your search based on that criteria.

    Currently the popular technologies seem to be: NodeJS, AngularJS, React, Big Data (data analysis, machine learning, etc). I think the reason for this is that quite a few new companies are being founded and investors (as well as business owners) need to know if the business plan will work and how to make it work. Javascript is is supported outside the browser, (applications like Mirth let you write code in JS for custom rules) which has added to its popularity.

    Java will always be in demand in the financial sector. You can never go wrong with learning C/C++. As long as computers are in use, C/C++ will be in demand.

    I hope this helps others are out who confused about their next step. Please feel free to contact me, if you have anything else that might be helpful. Below are some useful links: (a great resource)


Macports Ruby: Symbol not found: _SSLv2_client_method error

This error usually shows up when you try to run the following command:

sudo gem install 

For those that don’t know what I am talking about, this is the error message:

ERROR:  Loading command: install (LoadError)
	dlopen(/opt/local/lib/ruby2.2/2.2.0/x86_64-darwin15/openssl.bundle, 9): Symbol not found: _SSLv2_client_method
  Referenced from: /opt/local/lib/ruby2.2/2.2.0/x86_64-darwin15/openssl.bundle
  Expected in: /opt/local/lib/libssl.1.0.0.dylib
 in /opt/local/lib/ruby2.2/2.2.0/x86_64-darwin15/openssl.bundle - /opt/local/lib/ruby2.2/2.2.0/x86_64-darwin15/openssl.bundle

The only way to get this to go away is to re-compile ruby so it will use the new openSSL library. Macports, however, installs packages from binaries. So, after hours of trial and error, I found a way to get around this. You can re-install ruby with the following command and the error message will go away:

 sudo port install ruby23 +mactk

You will have to replace ruby23 with whatever version you want to install.


Setting, removing and reading cookies in Javascript

Copy/paste these methods and use them

 * Create a cookie
 * @param string  name
 * @param mixed   value
 * @param int     days
function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        var expires = "; expires="+date.toGMTString();
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";

 * Read a cookie
 * @param string  name 
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    return null;

 * Remove a cookie
 * @param string  name
function eraseCookie(name) {


Sunlit Garden

I have been painting landscapes mostly so I wanted to try something different this time. Another reason I wanted to do this painting is to experiment with sunlight (and little details like the gate) change how the viewer feels when he/she looks at the painting. Thankfully, my experiment was successful. Here is the painting:

Sunlit Garden

I added the sun rays by mixing titanium white with fluid medium, then painting straight lines. After that, lightly brushing over the white lines in the direction of the light and blending it with the object it is falling on. If you use water to thin the paint, the paint dries up too fast to do any blending.


Ergodox: Make LEDs indicate the layer you are on

This article assumes that you are working with the source code downloaded from MassDrop.

Open the file lib /key-functions/public/basic.c and add the following line below after all the #define statements.

extern uint8_t keyboard_leds;

Then go to the push function of the layer you want the LEDs to light up on. Let’s assume we want to turn on NumLock LED when layer 2 is active. In kbfun_layer_push_2 function, we add the following line:

keyboard_leds = 0x01;

So the function will look like this:

 * [name]
 *   Layer push #2
 * [description]
 *   Push a layer element containing the layer value specified in the keymap to
 *   the top of the stack, and record the id of that layer element
void kbfun_layer_push_2(void) {
	keyboard_leds = keyboard_leds | 0x01;

 * [name]
 *   Layer pop #2
 * [description]
 *   Pop the layer element created by the corresponding "layer push" function
 *   out of the layer stack (no matter where it is in the stack, without
 *   touching any other elements)
void kbfun_layer_pop_2(void) {
	keyboard_leds = keyboard_leds & ~(uint8_t)0x01;

You will notice that there is a keyboard_leds = keyboard_leds & 0x01 in the pop function for layer 2. This will turn the LED off when we exit the layer. For CapsLock LED set keyboard_leds to 0x02 and set it to 0x04 for scroll lock.

What if you want to turn on multiple LEDs when you are on a specific layer? If you want the NumLock and Scroll Lock LED to turn on when you are on layer 2, you would write the following:

keyboard_leds = keyboard_leds | 0x01 | 0x02; 

//To turn them off
keyboard_leds = keyboard_leds & ~(uint8_t)0x01 & ~(uint8_t)0x02;

Ergodox – The customizable ergonomic split keyboard

A few months ago, I got a mechanical keyboard called Ergodox. It is an open source keyboard (which means its schematics are posted online for anyone who wants to build it.) that you need to build yourself. You cannot buy it pre-built. Although, recently people have been putting up Ergodox with Cherry MX blue switches.

It has 2 halves (like every other split keyboard) that are separated by a wire. And, you can put the two pieces as far or as close as you want. I usually have a 6-7 inch separation between them.

Why did I get it?

I hated the placement of the apple command key on regular keyboard and wanted it to be in a more convenient place so I set out to search for keyboards that have it placed more to the middle. Das seemed like a great choice for this as their alt key is located below the letter C (not below X where it usually is) but I still wasn’t satisfied. So, after some research I found out about Ergodox.

I did quite a bit of research (read reviews, visited geekhack, etc) and decide to take a leap of faith and just get one for myself. Massdrop was doing a group buy and it was going for cheap so I joined the group buy and received it in about 2 months.

Ergodox’s design is heavily influenced by Kinesis Advantage which is an amazing keyboard in its own right. I love that they (both Ergodox and Kinesis Advantage) have a thumb cluster (a set of keys intended for use by the thumb).

It uses Teensy to register key presses and you can make any key register anything you want. You can choose to have a qwerty, colemak, dvorak or a custom layout. For alphabets, I use qwerty layout but for other things I have it customized to help me program. You can find a link to my layout at the bottom of this post.

The Good

You can customize pretty much anything you want. You can have one layout or multiple layouts. Very few keyboards let you do that and those that do, have a limited selection of layouts you can use. With Ergodox, you can make your own layout, if you wanted.

If you know a little C you can even customize the LEDs. Usually the LEDs are used to indicate if caps lock or num lock is on (I don’t think anyone uses or cares about scroll lock). I have never needed to use caps lock or num lock so I programmed my Ergodox to tell me which layer I am on (I use one layout for regular use and another for gaming and I have another layer for multimedia keys like volume control, etc).

The thing I love a lot about Ergodox is the thumb cluster. I have found it to be very useful. It has reduced my hand travel by quite a bit and this has, in turn, reduced the typing mistakes I make.

It is truly a split keyboard. You can have the two halves of Ergodox as far or close as you want. You can also detach the wire separating them for easy storage.

The Bad

There is a big learning curve initially – just like if you moved to Kinesis Advantage from a regular keyboard. So, you will have to be patient with it for the first month. I got fairly comfortable with it in a week but it took me about a month or two to treat it like an extension of my hand.

You have to wait about 2 months to get it after you order it (if you want it for a cheaper price). Or, spend over 500 dollars.

You cannot order it whenever you want if you want to get it for an affordable price. Massdrop, which is pretty much the only distributor that sells Ergodox for an affordable price, does a group buy every 2-3 months. So, if you miss the drop you have to wait 2-3 months to get it.

Ergodox cannot wake up your Mac from sleep. If your computer is in hybernation or sleep then hitting a key on the keyboard will wake it up. This is not the case with Ergodox. So, you will need to use your mouse to wake your computer up.

Although, if you connect your Ergodox to your computer through a USB hub then it will be able to wake the computer up (but not when Ergodox is connected to the computer directly).


I have been using Ergodox for over 3 months now and I don’t want to use any other keyboard. I love it so much that I take it to work and back home since I have just one. Although, will be getting another one for work because I don’t want to carry it everyday.

I have been tweaking it ever since I got it. Moulding it to my needs – making my life easier as I keep using it. I have had a complaint with all the keyboards I have ever used including Kinesis freestyle 2 and Kinesis Advantage. For the most part, you can’t do anything about it but with Ergodox you can and there is a huge community of people at geekhack to help you.

It is, however, not for everyone. My friend tried it and said he preferred the staggered layout of a regular keyboard vs the matrix layout of Ergodox. I have found matrix layer to be better for me when typing. So, it is all subjective.

The keycaps that Massdrop sells for Ergodox make it hard to use the top row in the thumb cluster. However, Signature plastics sells DCS R5 keycaps on their website that make using those keys so much easier. Kinesis Advantage does the same thing.

If you can afford it, I suggest you try Ergodox out and if you don’t like it you can sell it on Ebay for nearly its cost price and maybe even more than it.

Ergodox’s website:
My layout (which keeps changing):


My mechanical keyboard

In my last post, I talked about mechanical keyboards and how great they are to type on. I figured I would show you guys what my keyboard looked like. I have a Corsair K60 with custom key caps (well some of them are custom). Corsair did a great job with the keyboard and the only thing I didn’t like about this keyboard is that the right shift wasn’t smooth to press if I were to press it on the edge. I, accidentally, solved this problem by changing the keycaps. So here is what my keyboard looks like: