“Fun” with .bash_profile in OSX

I’m learning me some cocos2d-x at the moment, and one of the things they ask you to do is to add a couple of PATH variables for convenience, such as the following:

  • NDK_ROOT – A reference to where the Android Native Development Kit lives on your system
  • SDK_ROOT – A reference to where the Android SDK lives on your system
  • ANT_ROOT – A reference to Apache ANT (A Java based build tool, kind of similar to ‘make’)

Usually the way you do this in a Linux/Unix terminal is to run the following command (For example, with NDK_ROOT)

export NDK_ROOT="/Users/cameronwilby/Source/android-developer-tools/ndk/"

The problem I found with OSX was that it would only save the NDK_ROOT variable for the current Terminal session. When opening a new terminal window, the variables would be lost. Very frustrating.

I found out that the reason is that Unix has two types of shells. A login shell (When you’re already in a desktop environment or logged in via SSH) and a non-login shell (Imagine in the good old days where you login via a green-text-on-black screen terminal).

Login shells execute .bash_profile before you start typing commands, and non-login shells execute .bashrc first.

When you run the above command, the PATH variable is saved to .bashrc, not .bash_profile.

Now, the problem is that OSX creates a new login shell every time you open Terminal and subsequent tabs, which executes .bash_profile, missing out on the PATH variables we saved in .bashrc.  Thus, any PATH variables saved in a Terminal session will not be loaded the next time Terminal is opened.

The solution according to Josh Staiger is to add some lines to .bash_profile that loads in the PATH variables from .bashrc using to avoid this problem. I did this and it seemed to fix it.

…. I f**king hate Unix. Seriously. I just want to make a game or something.

Swim Counter

header

Technologies Used
C, Pebble SDK

Description
Swim Counter is a basic health and fitness utility for the Pebble Smartwatch. It keeps track of the number of lengths you swim for the four main strokes (Freestyle, backstroke, breaststroke and butterfly).

It’s open source – if you want to check out Swim Counter’s guts, go right ahead.
http://www.github.com/cameronwilby/swim-counter

Features

  • Track the number of lengths for the four main swimming strokes
  • Track lengths swam in the long run – counts are saved when the app is closed.
  • The Pebble is waterproof, rated 5ATM – meaning this app can be used in the pool.
  • Incredible graphics.

 

Working in Coffee Shops

What does a work-from-home type do when they don’t have an office to go to, and they dislike working at their house? Easy – coffee shop! It’s a much nicer environment, the internet speeds are a bit slower (allowing for greater focus on the task at hand), and I have a never ending supply of super-awesome-developer-juice (coffee).

But, as you’re probably already aware – there is a stigma associated with those that choose to work in coffee shops. If you aren’t familiar with this, allow Family Guy to explain.

But in the real world, the coffee shop is essentially a public office/study area/meeting area. As I’m writing this, one person has all sorts of World History textbooks strewn across their table, there are several meetings going on – and then there’s myself pushing out this article as a break away from pushing out a software project at full speed.

However – the thing I try to avoid is taking advantage of the situation without giving anything back. After all, the coffee shop I go to is fantastic. They source their own beans and roast them in house, and they have all sorts of interesting, different ways to make a good cuppa joe. They’re really passionate about their craft in coffee in the same way I’m passionate about my craft in software.

So – I’ve started to build myself a set of guidelines on how to work at a coffee shop without being a douche.

  1. Buy a drink at least once an hour. They’re not giving away this environment for free.
  2. Get to know the baristas and hold conversation with them – they’re really interesting people, and love to talk about their craft.
  3. Bring an extension cord – you’ll be the most popular person in the shop.
  4. On that note – If using a laptop, unplug when fully charged and allow it to discharge fully before plugging in again – this keeps power sockets open for others.
  5. Be social with the other customers, but know when somebody is trying to focus, and do not disturb them.

These are pretty simple, and go a long way in establishing a good relationship with the staff. Who knows, you may even get a free drink and a muffin every now and again!

What about you, can you think of another way to be a good coffee shop worker?