Jenkins doesn’t load under OS X Mountain Lion (or Server)? Here is the fix!

Answer: your machine doesn’t have Java installed on it. This happened to me. Jenkins installed fine, but then when I opened it on its default port of 8080, nothing happened.

To fix it, open Terminal and type “java” without the quotation marks.

This will tell you that you have to have Java SE installed on your computer and then will download and install Java SE automatically for you. Done! 🙂

Network-Connect 2 Macs

I was looking for a way to connect my two Mac Minis and transfer files between them, see the other Mac’s desktop and etc.

People were suggesting, FireWire, Thunderbolt cables, etc. Save your money. None of that really works.

The solution? Good old Gigabit Ethernet (CAT5E) cable and connect the two Macs together. Even if you have the latest MacBook Pro or MacBook Air that don’t have Gigabit Ethernet ports, there are Ethernet to USB cables that you can get from Apple which will do the job for you. So you still use the ethernet cable but at both ends or 1 end use the Ethernet to USB cable. Easy peasy.

In case you don’t know what an Ethernet cable looks like, it’s like this:

Image

Building and Running Python Scripts with Xcode 4.x

 Edit 1 (20th October 2014): Xcode 6.1 instructions can be found here: https://vandadnp.wordpress.com/2014/10/20/building-and-running-python-scripts-with-xcode-6-1/

So you have installed Python and you want to use Xcode to write and run your Python scripts… is that correct? Ok then, follow these steps to create a simple project and run it with Python using Xcode 4.x…

  • Open Xcode and select File->New->Project…
  • From the left hand side, under the OS X category, select Other
  • Now on the right hand side, select External Build System and press the Next button, as shown below

Click to Enlarge

  • Now open a Terminal window and type which python in it, and keep the results in mind or just keep Terminal open for future reference, as shown below. This will tell you where Python is installed on your system.

Click to Enlarge

  • As you can see, in my case Python is installed under /usr/bin/Python
  • Now back to Xcode, set the following values on the second screen of project creation:
    • Product Name: test
    • Organization Name: company
    • Company Identifier: com.company
    • Build Tool: enter the path to Python which we retrieved from Terminal. I have entered /usr/bin/Python (see below)
  • Once you are done entering all four values, press the Next button.

Click to Enlarge

  • Once you pressed Next, now you should choose where you want to save your project, save it somewhere that makes sense for you. I am going to save it in ~/Desktop/Development/Projects/Python/Sandbox/test/ as that’s how I have structured my development environment. Once you are happy with the folder that you are saving your project in, press the Create button in Xcode’s dialog, as shown below

Click to Enlarge

  • Now select the “test” target from the breadcrumb menu on top left corner of Xcode’s main window and choose Edit Scheme, as shown below

Click to Enlarge

  • In the Edit Scheme screen, on the left hand side, choose the Run option. Then on the right hand side, choose the Executable section and press the Other… item. This will open an Open dialog for you asking you to choose the binary of Python. For me, Python was sitting in /user/bin/python as you saw earlier. So in Mac, I press Cmd+Shift+G to “Go to Folder” and then I type in /usr/bin/, as shown below and then press Go:

Click to Enlarge

  • Now that you are in the folder that contains the Python binary, find and pick the binary and press the Choose button
  • Back in Xcode, on the same Scheme window that we were on before, under the Debugger section under Info, make sure that you choose None. This is very important.

Click to Enlarge

  • Back in Xcode, on the same Scheme window that we were on before, navigate on the right hand side to the Arguments tab and under the Arguments Passed On Launch, press the + button and type test.py, as shown below:

Click to Enlarge

  • Now go to the Options tab, under the Working Directory, click the Use custom working directory and then put the full path to where you are intending to save your Python files in this project. My project is at ~/Desktop/Development/Projects/Python/Sandbox/test/ and I’m intending to save my first file as ~/Desktop/Development/Projects/Python/Sandbox/test/test.py so I will choose ~/Desktop/Development/Projects/Python/Sandbox/test/ as my working directory, as shown below:

Click to Enlarge

  • We are now done with the Schemes. Press the OK button to close this window.\
  • In Xcode, from the Menus, choose File->New->File…
  • From the left hand side of the dialog, under the OS X section, choose Other and then on the right hand side, choose Empty and press the Next button, as shown below:

Click to Enlarge

  • In the next screen, make sure that you set the value of Save As as test.py. This is what we have been preparing our Scheme for, that we are going to have a file called test.py that needs to be passed to the Python interpreter. Have a look at the following screenshot. Once you are done, press the Create button:

Click to Enlarge

  • Now enter the following code in your test.py file: print “It works!”, as shown below:

Click to Enlarge

  • As the final step to make sure everything is working fine, in Xcode, from the menus, choose Product->Run, the Debugging Area will popup and show you the output of the print command like so:

Click to Enlarge

Lovely, it’s all working. I hope this tutorial helped you. If you have any questions or suggestions, please leave them in the comment sections down below…

Screen Resolution SmackDown – 2012 Retina MacBook Pro and 2009 MacBook Pro

Here is the SmackDown between the 2012 Retina MacBook Pro and the 2009 MacBook Pro’s screens:

Mid 2009 MacBook Pro Retina MacBook Pro (Mid 2012)
Login Screen  
iTunes 1  
iTunes 2  
Safari  
Finder    
GarageBand  
Menu  

Find cpp, c++, clang++ and clang in Xcode 4.3.x and Higher

 

So you have some scripts that use “cpp”, “c++” or “clang” and etc but you cannot find them in your path? Not to worry, read on…

With OS X Lion and sandboxing, you can find your c++ compiler using the “find” command:

find /Applications/Xcode.app/ -name “c++”

This will return something like:

find /Applications/Xcode.app/ -name “c++”
/Applications/Xcode.app//Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
/Applications/Xcode.app//Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++

The one in the “bin” folder is the one we are looking for so the folder that contains our toolchain is here:

/Applications/Xcode.app//Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/


Navigate to that folder to do some inspection:

cd /Applications/Xcode.app//Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/
ls -la c++
lrwxr-xr-x 1 root wheel 7 19 Jun 22:41 c++ -> clang++
ls -la clang++
lrwxr-xr-x 1 root wheel 5 19 Jun 22:41 clang++ -> clang
ls -la clang
-rwxr-xr-x 1 root wheel 22985632 19 Jun 22:41 clang

You can see right away that c++ is a symlink to clang++ and clang++ is a symlink to clang. What a mess!

Now let’s find “cpp”:

ls -la cpp
ls: cpp: No such file or directory

Oopsy daisy, it’s not there. That’s one of the issue a lot of developers will be facing. So let’s remedy this by first creating cpp as an alias. We want this alias to be permanent between Terminal sessions so we put it in our bash_profile and we also have to make sure the toolchain bin url highlighted above is in our path:

vim ~/.bash_profile

And then change the content of your bash profile so that your path includes:

/Applications/Xcode.app//Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/

and also create an alias for cpp to point to clang. The contents of my ~/.bash_profile now looks like this:

export PATH=~/bin/:/Applications/Xcode.app//Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/:$PATH
alias cpp=’clang’

Once you are done, press Escape in vim and then type :wq and press enter. That will “write” and then “quit”.

After you are done, close Terminal and open it again and type cpp:

cpp
clang: error: no input files

Lovely, it’s working. Any questions? Leave them down below 🙂

Installing Git on Mac OS X

If you want to install Git on your OS X Lion, whether you have Xcode or not, you can head to:

http://git-scm.com/download

There choose your platform and the install process will start automatically. This will download a .dmg package to your machine. Simply follow the installation process. After installation, you should be able to find Git in the following folder:

/usr/bin/git

And since this folder is already added to your path, you can simply access it in Terminal by typing git

Mac OS X Tips & Tricks – #4 (Folder with selection)

To place more than 1 file in a  folder, you can simply select all the files and then right click and then choose “New Folder with Selection” in the menu that will appear. Plain and easy. No need to create the directory and place the files in it manually!