How to access gcc and other build tools of Xcode 4.3 or newer in console

Apple announced Xcode 4.3 for OSX Lion and 4.4 for OSX Mountain Lion last week. The major difference is that Xcode no longer provide an installer which is good thing because you now could update Xcode with AppStore in the future, plus it is much easier to carry the development environment with you. However, there is a little problem with this new version of Xcode, is that all command line toolsets and compilers are not visible in terminal. A simple fix is to update your PATH env:

export PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH

Please be noted that clang does not reside in /Developer/usr/bin, it is now in /Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Now you could access to gcc, g++, git or any toolsets bundled with Xcode. For your convenience, it is recommended to include it in your .bash_profile.

Happy Lunar New Year!

Happy New Year to all friends and readers. You guys have been, are and always be my inspiration to write and contribute to the great Ruby community. I would like to take this opportunity to extend my wish to all of you a year of Dragon full with prosperities, wealths and lucks.

Replace Honda Accord Euro MY05 Battery

This year is the worst year of my life, everything is breaking down. And just a week before X-Mas, my car battery decided to retire after 5 years of hard work. So I started venturing into the World Wide Web to find a best replacement part. After digging into few forums, all recommended to go for ACDelco 430 or Supercharge Gold MF75****. It turns out that those batteries does not fit perfectly with my Accord Euro MY05. Besides, they are quite expensive too ~ around $150 AUD. In the end I called up John Blair Honda Parts and got a good deal for the Supercharge Silver SMF55D23L for $130. Off I went to pick it up and quickly got my dead battery replaced. Now my car roar like a real lion with a full 500CCA (the stock part is 300CCA though). I think I should hit the road now :)

Quantum talk by Damian Conway @ YOW 2011

Damian is a truly world-class speaker. His talk on Temporally Quaquaversal Virtual Nanomachine Programming In Multiple Topologically Connected Quantum-Relativistic Parallel Timespaces is very inspiring. I’d recommend you to check that out once the talk video is up online.

Multi-line comment with Ruby

=begin
line 1 blah blah
line 2 blah blah
=end

Love hopes all things

The Truelove

There is a faith in loving fiercely
the one who is rightfully yours,
especially if you have
waited years and especially
if part of you never believed
you could deserve this
loved and beckoning hand
held out to you this way.

I am thinking of faith now…

Well Love hopes all things and I hope you. I love you

Rails Tip: See ActiveRecord’s SQL Statements log output under Rails Console (rails console)

A good trick for prototyping/testing ActiveRecord is to have the SQL statement output to your console as you work. It could be achieved so with:

$ rails c
Loading development environment (Rails 3.0.10)
ruby-1.8.7-p352 :001 > ActiveRecord::Base.logger = Logger.new(STDOUT)

Whenever your code relates to AR, the SQL statement will be piped directly to STDOUT:


ruby-1.8.7-p352 :002 > Person.find 1
  Person Load (0.1ms)  SELECT "people".* FROM "people" WHERE "people"."id" = 1 LIMIT 1
 => #<Person id: 1, name: "one", age: 23, created_at...

Anagram Solver – extracted from one of my interviews

Hi folks

For whom who is going to undertake RoR/Ruby or general software development position, your employer might give you some sort of short test for Round 1. Anagram is probably one of the good question that they might ask. Because it is a simple test yet involves many techniques that a code reviewer could testify your competence in programming. Here is one of the test question from a Ruby job interview that I had:

Given a file containing one word per line, print out all the combinations of words that are anagrams; each line in the output should contain a set of input words that are anagrams of each other. No word should appear in the output more than once

For added programming pleasure, find the longest words that are anagrams, and the set of anagrams containing the most words.

From the employer perspective, they will pay attention in how you approach this problem and the methodology how you test it too. There are many ways to tackle this question, however I guess the best way is to use Hash due to its n log(n) algorithm is more efficient than other methods. Additionally, an unit test with RSpec would be a plus. Please check my code at:

https://github.com/joneslee85/Anagram-Solver

Howto fix App Store Xcode 4 95% installation freeze AND customize install template to exclude iOS SDK


If you encounter a hang at ~95% when running “Install Xcode.app“, here is how I fix that:

1. Use Activity Monitor to Force Quit the “Install Xcode app
2. Go to Terminal and paste in following command line to uninstall all defunct Xcode:

sudo /Developer/Library/uninstall-devtools --mode=all

3. Go to Finder > Application and right click on “Install Xcode.app” then choose “Show Package Contents“.
4. Navigate through Contents > Resources. There you’ll find Xcode.mpkg which is a old style Xcode installer where you can customise to exclude iOS SDK (saving up 4.5Gb overhead) and more importantly the installer won’t freeze at 95%.

Follow

Get every new post delivered to your Inbox.

Join 57 other followers