TiNy CLI – Titanium Productivity Tool

I recently found a tool by Fokke Zandbergen called TiNy CLI which has made life a lot easier for me in Titanium development. It allows you to use less keystrokes when building your apps.

I found it simple to set up and use. I went from using large build commands to using a single command and parameter. Here’s an example of the old way and the new way using TiNy CLI.

ti build --device-id xxxFE03B-xxxx-xxxx-xxxx-BB22B1234xxx --platform ipad

tn ipad-retina

First you have to generate recipes by running

tn generate

You can list recipes using

tn list

And if you see a recipe name you don’t like you can rename it using

tn rename oldname newname

I had to use rename to change my android emulator name and make it shorter

I recommend giving it a shot if you use the CLI to build your apps!

What I am learning now

Earlier I wrote a post about how I wanted to move towards web technology and what I planned to learn next. I’m glad to say I have learnt a lot since then but not quite what I was expecting.

At the start of the year I changed roles at work and joined the mobile team. I have always been into mobile but never thought I could have the opportunity to do it for a living. Having come from a desktop development background using C# and SQL server mostly it was a challenge to retrain, but one I was up for!

We use a JavaScript based cross platform SDK, Appcelerator Titanium with Alloy MVC framework, to build mobile apps. I’ve found this very simple to pick up and learn the basics although it does take time to “think mobile” and not desktop. E.g. we need to assume on the mobile devices that we may not have internet connection so we tend to sync data onto the device and work locally as much as we can.

A few months on I’ve delivered my first module for our apps and now feel confident that I can produce quality apps. Here’s some of the skills I’ve picked up in the last 6 months:

  • JavaScript
  • Titanium SDK
  • Alloy MVC Framework
  • JS libraries such as Underscore and Backbone
  • Jasmine unit test framework

That’s all for now, I just wanted to revisit a previous post and update my progress. All I can say is that sometimes things don’t go to plan but just keep moving forward and learn new things!

Learning something new…where to start?

As mentioned in a previous post, I need to start learning web technologies as it’s clear as a desktop developer that things are changing rapidly in the industry and I don’t want to be left behind!

Here are a few things that I have found helpful so far.

1. Learn by doing

To be blunt, I am not one of these people who can stick my head in a book and read all about something then be able to do it. I find that I am better at actually using a new language or technology and learn from mistakes. I find that if it is a language for example, most of the time it is about learning the syntax of that language and it’s probably more effective to attempt simple problems and try to solve them than to read about how to solve them. You are more likely to take it in if you do it yourself.

2. Learning sites

A site I have found extremely useful for this is Codecademy. It basically holds your hand through the basics of a new language like javascript (for me). Taking you through the simple parts of the language like basic syntax and moving on to more advanced things. Sites like these usually let you write code to solve preset problems and grade you on a basic level of pass or fail. Hints are also available so you won’t be frustrated if you can’t figure something out. Another neat feature of this site in particular is the achievements or rewards for passing a module, you can share these with your friends which is cool. Highly recommend!

3. Personal project

This is something that I always have the best intentions with but find hard to follow through and complete as I tend to hit roadblocks during development. However, I still think this is a very important part of the learning process as it challenges you and also gets you thinking about how you can use something new in the real world. You never know, something that starts out small for a personal project could become the next Google or Microsoft, so don’t give up right away. I’d do well to take my own advice here as well!

4. Examples

Examples are always useful when you are trying to use the new language or technology. Usually this comes in handy when you are doing your personal project or trying to solve your own problems. I had a good experience of samples when I tried looking at Knockout. I found they had a great example page and tutorial section which takes you through how everything works, gradually building up the difficulty. Always look for samples as well as using the documentation when you get stuck.

5. Ask an expert

This should probably be number 1 in the list but it can’t really happen until you have looked at something yourself. I find this to be 100x better than googling something. You can quickly communicate the problem to someone who is classed as an expert in the topic and get an answer from them almost instantly and chat about the problems you are having. You’ll find it’s quicker to ask follow up questions and give examples of the specific problem you are stuck on. I know you can do this online but it’s nice to talk!


These are just a few things at the moment but as you can see my emphasis is on the practical side of learning over the theory. Of course I’m not ruling the theory out, I just think it has it’s place and when it comes to development I firmly believe in using the tools to learn rather than looking at them.

I wish you all the best in learning something new and please let me know what you think. Have I missed anything out which you do when learning something new? Let me know. Cheers

Funny Commit Message Generator

After writing a commit message and pushing my latest change up to github I suddenly thought about what I was doing. I just usually go into autopilot and write a generic message, which if I looked at it next week would make no sense.

So I googled around for the rules of the commit message and found this by accident!


What’s funny about it is that I’m sure at some point we’ve all either written one of these messages, thought about writing them or read someone else’s!

It’s just a bit of fun but definitely worth a look to waste 5 minutes

What I’m going to learn next

So far in my career I’ve sort of been pushed down the desktop route with C# and Oracle and SQL Server. Since starting my new job and realising the focus in the technology it made me think that perhaps I should consider retraining myself towards web development. It just seems that a lot of the jobs in the local area are focused on digital media. I’m not saying that desktop will go away but it looks like all new projects will begin with web, and desktop might be more of a maintenance / bug fixing role. This is just my opinion!

So far my list of things to read up on are:

  • ASP.net
  • MVC 4/5
  • Javascript
  • JQuery
  • Backbone (or another similar library)

I feel getting the basics of these topics would give me a good grounding to be able to contribute on a project and even start my own personal projects.

When it comes to learning new things, I first turn to Pluralsight as it tends to have a good range of courses and it can be done in modules.

I’ll keep updates on my progress!

If you have anything to add, please comment below. Is there something I am missing from my list?


Atom is the bomb!

I decided to give Atom, “the hackable editor”, a try since I was jealous the minute I seen a new editor was going to be available and it was released for everyone except windows users. Initial thoughts are that its just another editor but I like the subtle differences.

I particularly like how the packages work. It is so fast to find one you need, add it and then immediately start using it.

toggle preview

The most recent package I’ve tried out is the Markdown Preview. I had to write something in a Trello comment and keep some kind of formatting and order to it. So without pasting my code into Trello every 2 mins to check my syntax is correct, I could just enable the Markdown Preview window which showed up on the right hand side. It updates as you type so you get instant feedback and can try things out. I know this might sound simple but for never having used Markdown before now it was definitely needed. It’s the little packages like this that will make this editor better than the rest.

Other editors such as notepad++ and sublime are probably just as good and can do the same job. I’ve used notepad++ a lot and it may be on purpose but it looks a lot more dated than any of the editors out there. The plugins on notepad++ also have a clunky interface compared to atom. I can’t comment too much on sublime but from what I’ve read it may stop being supported which gives atom the upper hand. I’m not going to say too much as this may just be another new toy at the moment.

Let me know your thoughts on the best editor out there. Aso, if you’ve used any good packages in atom or want to share your opinion on this please comment below!

markdown preview

What ruins developer productivity?

I read a great article by George Stocker recently, I found this on reddit /r/programming and it sums up the little things that distract us from day to day work.

You don’t realise just how much distractions can affect us and the graphs in this post show how small interruptions that happen at all times during the day can really break up a developers flow. This is why sometimes we feel like we get nothing done.

I’ll definitely be trying to follow a few of the ideas in this post!



10 Ways to get inspiration as a programmer

I recently read this article from Halffull.Org about 10 ways to get inspiration as a programmer. Even just reading articles like this inspires me to be a better programmer. I’d like to think I could write an article like this one day.

I particularly like the one which says “Write a game”. I would love to be able to do this, and why not?! Once I’m finished with any personal projects this is going to be my next goal.

Anyway, here’s the link to 10 Ways To Get Inspiration As A Programmer , enjoy!

Google Code Jam 2013 – Update: Passed Qualifying!

Well… I started code jam for the first time on Friday night and got a bit of a shock. My preparation was nowhere near enough! I thought I could hit the qualification points a lot easier than I did. The plan was to start with what looked like the easiest problem, complete the small and large data sets and then carry on. However, I was over tired and wasn’t thinking clearly so things didn’t go to plan. I had spent an hour late at night getting nowhere so decided to go to bed. I was pissed off with myself as I was psyched up for this.

A. Tic-Tac-Toe-Tomek
This puzzle gave you grids of 4×4 tic tac toe games which were in a particular game state. You had to write something which would return the state of the board for each case. There were 4 different possible states which were, X won, O won, Draw, Not yet completed.

Example input is:

. . . .
OO. .
. . . .

Example output is:
Case #n: X won the game

The way I tackled this problem was to check each row first for a winning game, then column and then finally diagonals. If no win and there were no empty squares (.) then it was a draw, otherwise the game was not completed. Having looked at the sample python code from Google, my C# version was long winded!

B. Lawnmower
We are asked to check patterns for grass cutting as the input. We need to confirm if the pattern is achievable by cutting at a set height for a whole row or column of the lawn.

Example Input:

2 1 2
1 1 1
2 1 2

2 2 2 2 2
2 1 1 1 2
2 1 2 1 2
2 1 1 1 2
2 2 2 2 2

Example Output:
Case #1: YES
Case #2: NO

You can see from the first input we can cut this lawn to the desired pattern as we need 2 runs with the lawnmower across the middle row and middle column cutting to height 1.

However, with the second one you can see there is a square of height 1 in the centre of the lawn. This is impossible because we need to cut from edge to edge and cannot start in the middle. We also cannot grow grass back. So this would be impossible.

For my solution to this, I had 2 versions of the lawn. The starting version which I would cut to then match the desired version. This would give me something to aim for and compare against. Firstly, I decided to cut the whole lawn to the maximum grass height found in the whole lawn. This would trim it down all over and allow me to start cutting individual rows and columns next. Then I would check rows to see if all of the squares in the row were the same height. If they were I would cut them, if not move to the next row. Then I’d do the same for the columns. This would hopefully end me up with either the desired pattern or something different. I could work out my output per test case this way.

I realised my mistake with this after the competition. I had checked the max grass height all over when I should have done this check per row and column.

C. Fair and Square
For this problem we are asked to find all of the “fair” and square numbers within a given range. To quote Google on this the definition of a fair and square number is:

“it is a number that is a palindrome and the square of a palindrome at the same time. For instance, 1, 9 and 121 are fair and square (being palindromes and squares, respectively, of 1, 3 and 11)”

So my method for solving this one was to loop through numbers from 1 to the upper limit (probably should have been the lower limit) and first of all check if that is a palindrome. If it is one, I then get the square of it by multiplying it by itself. If this square number is within the range given to me, I then check again if this square is a palindrome. Again if so, it will be added to my count of fair and square numbers!

I’ll post the code soon so keep an eye out!

D. Treasure
I didn’t attempt this question so I won’t have a valuable discussion about it. I will update this part if I decide to give it a shot!

I enjoyed my first taste of competitive programming. However, based on this attempt and how long it took me to finish the problems I attempted, there is no way I will make it past the next round. But I need to remember I have done what I set out to achieve and qualified! Bring on the next round.

How to use C# Conditional Operator ?:

Ok, so I’ve been doing a lot of work with the DataTable in my code recently and one thing I found myself doing a lot of validation to check that a value is not NULL before trying to use it. I did this because I would get an error if the value in the column was NULL but I was trying to assign it to a variable.

I’ll show examples using the following data and we’ll call the DataTable dtUsers:

ID,Name, PostCode, TelNo, MobNo
1,Ross, ED4 9KL, 01234 654987, NULL
2,John, NULL, 01238 765253, 07979876123

E.g. Long winded validation

foreach(DataRow r in dtUsers)
    if(r["ID"] == DBNull.Value)
        id = 0;
        id = (int)r["ID"];

    if(r["Name"] == DBNull.Value)
        name = "";
        name = r["Name"].ToString(); 

You can see here that I am trying to check that each column in the table has a value before trying to assign it but this is obviously a long way to achieve this. We can do the same thing in less lines of code using a Conditional operator “? :”

E.g. Using the conditional operator

foreach(DataRow r in dtUsers)
    id = r["ID"] == DBNull.Value ? 0 : (int)r["ID"];
    name = r["Name"] == DBNull.Value ? "" : r["Name"].ToString();

So what the conditional operator does, is it will first of all check a condition(true or false) and give the first value if true OR the second value if false. To put simply, an IF ELSE statement. In this case, it is basically saying

IF r[“ID”] is NULL THEN (?) give me the value 0 ELSE (:) give me the value of r[“ID”].

MSDN explain it like this.

condition ? first_expression : second_expression;

One other thing we can do to make sure we don’t have to validate on the code side is use the validation in our SQL queries which fill the data tables. If you look at a previous article I wrote about SQL COALESCE and ISNULL this will help us guarantee there is no DBNULL value in the column and it will always give us some value we can use.

I hope this is useful for some people. I find myself using it a lot when I know a column in the database tends to have a lot of null values. I should probably use it all the time but hey! Any questions, let me know.