Git & Titanium Tips

Up until recently most of my SCM experience has been around SVN and the Microsoft tooling. After jumping into the Titanium eco system I quickly found git was the best way to manage these projects.

Below are two tips I found helpful in reducing my commit noise and better managing my repos.

I also recommend checking out a great wiki article on Spheriki called "Git for the lazy". It is a fast way to get started.

Ignore Build Directories

By adding a .gitignore file into the root of your /[project]/build directory you can avoid having git track the files that Titanium auto generates.  You should be versioning your apk and .app files that you send to your testers, but I found that I do so many compiles it is best to have a separate process for this.

Creating your .gitignore file:

  1. Open terminal and go to your project’s build directory. It should be something like [Your Workspace]/[Your Project Name]/build
  2. In terminal type nano .gitignore
  3. The nano edit will open in your terminal session
  4. Add the tmp, android/, and iphone/ entries you see below
  5. Press Control + X to exit
  6. Press Y to save your changes
  7. Press return to finish


tmp
android/
iphone/




view raw .gitignore This Gist brought to you by GitHub.









Tell git to globally ignore .DS_Store files



Another pet peeve of mine is around .DS_Store files. To globally ignore them just open a terminal window and type the below.







git config --global core.excludesfile ~/.gitignore

echo .DS_Store >> ~/.gitignore






Appcelerator DevLink Blog Buttons

One of my favorite topics lately has been Appcelerator’s Titanium Mobile product. A great and extremely active community has developed around their open source products.

They have Q&A forum similar to stackoverflow so when I was re-theming my blog I wanted to add a button for my Appcelerator’s DevLink profile.  If you’d like to do the same below are some icons you can use and steps to get your DevLink setup and find your profile url.

Badge Icons


 

48 x 48

32 x 32

*Please download instead of linking to the above, the icon locations change every once & awhile.

Getting Your DevLink Profile Url

  1. Go to developer.appcelerator.com
  2. Login and the press the DevLink button
  3. If you haven’t setup your account there is a “Get Started” button at the top of the page that will guide you through the process
  4. Once you have your account setup just find your name in the list and click
  5. This will bring up your profile in a dialog, press the View full profile option at the top and copy that Url. This is the direct link to your profile.

Updated:

Tony Guntharp from Appcelerator provided some official icons that look much better.

Titanium Time Helpers

For a recent project of mine I have to present different picker controls to the user based on their device time settings.  Unfortunately I couldn’t leverage the standard picker control since I need to present the user with only the hour picker instead of the full time picker.

Below is a function that will return a bool indicating if the user’s device settings are configured to AM/PM or to display 24 hour time.

 

1 function deviceTimeIs24(){
2 //Get Time Formatted value and remove the separator
3 var temp = String.formatTime(new Date())
4 .replace(':','')
5 .replace(/^\s\s*/, '')
6 .replace(/\s\s*$/, '');
7
8 /*If not in 24 hour format the temp value
9 will not be a number for example 641PM.
10 If is in 24 hour format it will be all numbers */
11 return !isNaN(parseFloat(temp)) && isFinite(temp);
12 };