My Coda 'Makers Festival' entry

coda_maker_fest.png

I’ve been using Coda in my startup HR Partner for the past year or so, and love the fact that I can create custom dashboards to share and manage data with my team. This week, I noticed that Coda and ProductHunt were having a Makers Festival (No Code Edition) that was pretty cool, and so I thought I would whip up a little mini project in a couple of hours.

The choice of project was a little tricky, but then I remembered that I always wanted to build a mini app to track my liquid intake throughout the day. I have a terrible habit of not drinking enough to keep myself hydrated, and I promised myself that this year, I would improve upon that. What better way that to build a dashboard that would objectively show my how well (or badly) I was doing.

To that end, I decided to build this ‘Waterboard’ app in Coda:

Screen Shot 2019-03-24 at 11.11.14 am.png


This is a very simple app that shows me how I am tracking as far as liquid intake for the day, plus show my trends over the past week.

Here is a breakdown of the app:

At the top of the dashboard, I can set my target goals that I want, meaning the total quantity of liquid that I want to drink every day, plus the time interval between when I take drinks.

Using Coda’s slider widget to set my goals.

Using Coda’s slider widget to set my goals.

If I am below my target quota for the day, the dashboard will prompt me to keep going, and when I exceed the quota, I will get a ‘well done’ message. Similarly, if I go over the time interval set, then the system will warn me that I am overdue for a drink, otherwise I get a thumbs up. Here is what those displays look like in the middle of the page:

Not so good, I am behind in my target quota and it has been a long time between drinks!

Not so good, I am behind in my target quota and it has been a long time between drinks!

And here is the display when I am doing well:

Everything is just ticketyboo!

Everything is just ticketyboo!

Notice also that in this section, I am using Coda’s Rectangle() function do draw in a progressive bar chart which visually shows me my current liquid intake vs the target goal. Makes it easier to see how I am progressing versus trying to do mental maths when I am dehydrated.

The table in the middle of the screen is the actual Coda data table that holds the information on my liquid intake. A really simple table with 4 fields in it:

Coda_Makers_Festival_Entry_5.png

Really, all I am doing is collecting the time of the log entry, the type of liquid (which is a customisable drop down list) and the quantity in ml. The last column is an auto calculated icon that shows me whether the entry was pure water, or a compound liquid like coffee/tea etc. We all know that pure water is best!

Oh, and this table only shows the entries for today. All previous entries are filtered out using Coda’s filter capability in order to reduce clutter.

But seeing as I am a programmer, I hate doing long form data entry. And seeing that my daily liquid intake is usually from one of about three or four different containers, I thought to make up some ‘Quick Hits’ buttons just above the table:

All my favourites. (except Coke - I don’t drink Coke!)

All my favourites. (except Coke - I don’t drink Coke!)

So now just one click will populate the table data with the most popular beverages I drink on a daily basis.

Setting the button action.

Setting the button action.

You can see above how easy it is to set an action to the buttons - I simply nominated that I wanted a click to Add a row to the data table, and I specified the two critical fields that relate to this button (Note that the entry date and time are auto populated using calculated fields within the table itself).

Voila! That is it.

Last on the page is a graph of the past week’s liquid intake, so I can see how I am trending over time:

A veritable roller coaster.

A veritable roller coaster.

That is it. Perhaps about two hours work to put this together, and most of that time was spent looking up the formula syntax for Coda’s date/time and string manipulation.

One downside of Coda is that all timestamps (such as those returned by the Now() function) are in Pacific Time, rather than UTC or local time. Date functions however seem to be in UTC which is strange. Nevertheless, Coda has the concept of Named Functions, so I created a custom function called NowLocal() which converted the returned timestamps from Pacific Time to Australian Central Standard Time.

Coda’s named functions make reusing repeated long formulas so easy.

Coda’s named functions make reusing repeated long formulas so easy.

Where does the 0.6875 come from? Well, Pacific Time is 16.5 hours different from Australian Central Standard Time, so 16.5/24 gives you 0.6875 which is the amount we have to add to the datum to correct the time to my local timezone.

I also created a function called DateLocal() which is basically:

Chaining named functions.

Chaining named functions.

which corrects the Today() function in Coda and returns the correct date for today once adjusted for ACST. See how simple it is to use Named Functions to save typing out the same formulas repeatedly all over the dashboard? In fact, I used several named functions in this dashboard to save time.

Here is an example of using DateLocal() in the graph filter:

Coda supports some quite complex formulas, including IF statements etc. The following formula picks out the last drink time of the day (and returns a sad face emoji if there are no entries for the day). Note copious use of Named Functions to avoid long winded formulae:

Coda_Makers_Festival_Entry_13.png
Waterboard running in the Coda app in iOS.

Waterboard running in the Coda app in iOS.

And yep, it even works in the Coda app to look just like a native iOS app (If you look at the image on the right). I realise that I still need to do some rejigging of a few of the widgets and buttons to make the ‘sit’ properly on the smaller form display, but overall, it is a useful way to use the dashboard and logging too.

TODO: I’d probably add some automation so that a Slack message or notification is sent whenever a drink entry is made. However what I would really like is for a notification to be sent when I am overdue for my next drink, but I don’t think Coda has the ability to send a notification on a formula at this stage.


I am happy to share this dashboard with anyone else out there who is interested in learning how it is built. Feel free to poke around the formulas and functions, and improve/customise it to your liking. Drop me a line if you want a Share link to this dashboard.















Incredible Women in my Life

I know this is a bit late for International Women’s Day, but I thought I would post it anyway.

Some backstory - I used to do a lot of art and painting in my younger days, but haven’t really done anything for the past 3 decades or more. Work, life, music, everything else simply got in the way and I never put pen or brush to paper in all that time.

Until this year, when I decided to try my hand at painting again. But the next problem was - what subject matter? I decided that I would focus on women in my life who have had an impact on me. Not just my immediate family, which consists of strong women anyway, but rather my friendship circle, in which I have many women who I think are totally amazing.

(Note: I have held back from mentioning names in this post. Mainly because I want to protect the privacy of my friends. Most of them are really humble and wouldn’t like to be called out for their strengths, but I think their story deserves to be told).

Here are my (rusty) artistic impressions of my heroes:


IMG_0011.PNG

I first met E when she worked at a client site that I was doing some consulting work at. She always had the brightest smile and a genuine “Hello, how are you?” that went beyond mere politeness and showed an actual interest in the answer, which in turn showed the depth of her soul.

E does it hard raising two very young kids as a single mother, but she does not let that hold her back from showering her children with an abundance of love. And she always has time for others.


IMG_0017.PNG

J was a good friend of my younger sister and spent a lot of time at our house when growing up, and so I consider her another little sister of mine as well as one of my best friends. Many years ago, while in the prime of her life, she suffered an aneurism which nearly took her life. She still suffers many permanent after effects of that incident to this day, including short term memory loss, but she does not let that hold her back, and she still retains her delightful, happy personality.


IMG_0023.PNG

M was another client who turned into a friend. A few years ago she was diagnosed with having multiple brain tumours. Because she lived across the country, I could only follow her journey of fighting through this via Facebook, but I was amazed at her strength, resilience, and most importantly, her absolutely candid sense of humour while going through the worst of times. That is priceless in my opinion.

Even during her recovery, there was no hesitation in outlining funny things that happened as a result of the multiple surgeries and procedures that she underwent - for example, she suffered balance problems following her release from hospital, but she regaled us all with the funny story of how she tripped and fell flat on her face outside her favourite pub when she was on the way to celebrate beating those pesky tumours. It takes someone special to always see the funny side of something so serious. Thankfully M is doing well now and enjoying a full and healthy life.


IMG_0026.PNG

J is a long time business colleague whom I have a lot of respect for. I have known her for many years, which includes the time encompassing two marriages that didn’t work out. What I really admire about J is how she doesn’t let heartbreak hold her back. Every time she met a new love, she would throw herself heart and soul into the relationship with no cynicism or negativity. That kind of bravery, to risk your heart over and over like that, is rare.

More recently, J also came down with breast cancer and battled through that with silent courage. She is now in marriage #3 with her soul mate and is blissfully happy living the life of her dreams.


IMG_0030.PNG

S is a relatively new friend, but has already astounded me with her spirit of generosity and her willingness to go above and beyond to help a friend out. She is an avid traveller and is not afraid to explore the wilder side of places she visits on her own. She is a super smart former lawyer. She is also a former MMA cage fighter, so she is one tough lady that stands for no nonsense. A serial entrepreneur, I always enjoy spending time with her talking about startup life and travelling.


IMG_0033.PNG

D is another friend of my sister who is like a little sister to me too. Always ready with a delightful smile. She is a beautiful soul. She has 2 children with special needs, but I have never heard her complain once - she showers all 4 of her children with boundless love. Tragically, she recently lost her young son, and my heart goes out to her, because of all the people in the world, D does not deserve this. She also had her own personal battle with cancer a couple of years ago, but that never stopped her from being there for her own family. For me, D is proof enough that no higher deity exists, because any god that can put someone as amazing and compassionate as her through such life trials really does not make any sense to me.


I hope to add to this list over the coming months, and I am realising how lucky I am to be surrounded by such strong, inspirational women almost everywhere I go. They have all played a part in shaping me into the person I am today.

People have asked me “Aren’t there any men who have inspired you the same way?” and the short answer is yes, but apart from my own Dad, I really can’t think of any other male figure in my friendship circle who has been through the sorts of battles that the women above have. I am sure there are though, and as soon as I find them, I will do something similar.

Regaining my timing

Regatta_de_Blanc.jpg

Like most musicians, I usually struggled to ‘keep time’ especially when playing solo compositions. But a few years ago, events which resulted in a stress induced condition (which I won’t bore you with here) has resulted in further degradation in my ability to keep time, even in a band situation where there is a drummer doing all the hard work.

I am determined to improve that though, and have been going back to basics and working on scales using a metronome to reduce that neural disconnect between my brain and my fingers. Over the weekend, I decided to challenge myself even further.

I’ve been a fan of The Police for a long time. There was something about their reggae infused punk beats that captured my imagination, and I admire all three musicians for their eclectic ability. I’ve never really played any of their songs on stage (mainly because I’ve never really had the chance to play with a drummer as talented or frenetic as Stewart Copeland), but I found a drum backing track online over the weekend for one of my most favourite songs of theirs and decided to give it a shot.

“Walking On The Moon” - As far as Sting’s bass work, this is actually one of the easiest ones to play, as the bass riff pretty much starts on the first beat of the bar (as opposed to a lot of other songs where the bass starts mid bar (e.g. Roxanne)). The guitar parts though, were the challenge. The chimey, chorus washed bits that come in every second bar is actually on beat four of the bar. It is a huge challenge to sit back and wait for the right timing to hit that Gmajsus4 chord, and then letting the delay slapback echo it for the first beat of the following bar! Even the staccato chord whips later in the verse are on the 2 and 4 - and every music teacher in the world always tells you to emphasise beats 1 and 3, NOT 2 and 4. Yet, this song is made by the choked chords on the 2 and 4. By far, the biggest challenge though, was playing along to Copeland’s frenzied thrashing. I had to keep time outside of his syncopated fills - a further testament to the skill of the original band.

Playing this was a great exercise in freeing up my mind from the usual constraints, and also to reduce those milliseconds of delay that had infused my neural system after that incident all those years ago. Breaking up my usual ‘straight timing’ with offbeat work like this really has seemed to reprogram the synapses in my brain. Time to go learn more Police numbers.

The first programming trick I learned

Most programmers I know experience a moment in early in their code writing careers where they are shocked by a profound moment of discovery & realisation about their craft. I’d like to think that this moment helps to crystallise their love of writing line after line of instructions designed to manipulate a pile of silicon and electrons into doing their bidding.

For a large number of those that attended some form of computer science class, or coding school, it was probably when you first saw a recursive function in action:

carbon (2).png

“WHAT? That function can’t keep calling itself… can it?? Wait…”

I said the same thing above that probably 99% of Programming 101 students said when they saw such a mind twisting piece of code. But no, for me, my major discovery about the beauty and subtlety of the art of programming that lurked a layer beneath the monospaced text on my screen happened way before that.

You see, I was a self taught programmer, and cut my teeth on the very early versions of Turbo Pascal back in the 80’s. I was lucky enough to score a job with a local IBM dealership as a support technician, and also managed to do some small bits of coding on the side for their clients.

One day, a senior IBM System/360 programmer in the company casually asked me: “Devan, do you know how to swap two variables around in RAM?”.

“Sure!” I replied, brimming with 18 year old confidence, “You just create a third variable to hold one of the values temporarily, then you do a reassignment and copy the temporary back into one of the original two…”.

I had fallen into his trap. The same trap that most junior programmers make:

The ‘old fashioned’ way of swapping two variables, using a third.

The ‘old fashioned’ way of swapping two variables, using a third.

I remember him shaking his head sagely. “Nope - did you know that you can do it without using a third variable?? We often have to swap over entire blocks of memory on the S/360, and often, we don’t have any extra memory to spare to hold a temporary value.”

I frowned in consternation. This was impossible, wasn’t it? You couldn’t ever swap two variables without using a third placeholder. The first assignment would corrupt one of the values immediately, or so I thought. I asked him if it took longer, or used more steps than the simple answer above. “Nope” he replied again. “It takes the same number of steps, and on some systems, like the S/360, it is actually faster than your example”.

I pondered this problem for most of the day, but in the end had to admit defeat to him. Surely this was just another hazing of a junior employee that he was dishing out here?

Wordlessly, he write the solution down on a whiteboard in the conference room:

Using XOR to swap values in memory.

Using XOR to swap values in memory.

I stared at what he had written with the same utter confusion that I did much later when looking at my first recursive function. Surely this was impossible. There must be a mistake here. This shouldn’t work. This can’t work.

But it does. Try it.

For those that are curious about the ‘exclusive or’ or XOR function, here is an explanation about it. And our veteran was right, on some CPUs, the XOR operation actually takes less cycles than a PUSH or MOV operation.

What was the ‘moment’ that made you fall in love with programming?