programming

Fix to the Error installing Rails on Mac OS X !

Hi,

I was trying to install Rails on my mac by using the command:

sudo gem install rails

But it threw me the following error

ERROR:  Error installing rails:

ERROR: Failed to build gem native extension.

This happens if I haven’t installed the Xcode Command Line Tools properly. To do that

Run xcode-select –install in terminal

This would install the Xcode command line tools. Thats it, you are good to go.

Re run the sudo gem install rails in the terminal and it will install the rails.

To verify if the rails is installed properly. Run rails -v in terminal.

This shows us the version of the rails installed on the machine.

Cheers,

SZ

Advertisements

Programming Style!

I was learning Ruby and I stumbled upon this short note on the programming style. I loved it. The author Huw in “The Book of Ruby” says that “A good programming style has nothing to do with the naming conventions and everything to do with good code structure and clarity.” He also says with his experience that the most important characteristics of well-written code are clarity and lack of ambiguity. Code that is easy to understand and easy to debug is also likely to be easier to maintain.

It makes perfect sense and I loved it, hence I posted it. I am thinking to do this more often as I strongly believe if I write about something I learn, it would retain in my mind for a longer time.

Nuts and Bolts of R Language!

Bonjour,

  • Basic arithmetic is the same. 1+1 = 2 | 5*6 = 30  and so on
  • Printing a string is just typing in  “Hello, World!”.
  • T and F are short hand for True and False simultaneously. i.e., T == True and F == False
  • To store a value in a variable. You do this : x <- 35
  • You can reassign any value to a variable any time. You can assign a string like this: x <- “Hello DataScience! R lang is awesome”
  • printing the value of x is simple.. Just type x and hit return! That will do the magic.It should print 35 as we assigned it earlier
  • you can assign logical values to the variables too.. Do this: x <- T or x <- True
  • You have a sweet function called sum to add up numbers.. like this sum(2,3,4) gives you 9 as output
  • To repeat a string or a number you can use “rep” function like this rep(“Bonjour”, times = 3)
  • Like everywhere.. there is a function called sqrt to find the square root. sqrt(16) gives 4
  • help(functionname) gives you the function’s documentation and syntax. For ex: help(sum) gives all the details of the function
  • example(functionname) gives you the usage of the function and what arguments are valid for the function
  • One can write the script in a file and can save it with .R extension for later usage and execution
  • list.files() gives you the list of files in the current directory
  • To run a script. We need to use source function and the argument is the file name. like: source(hello.R)

Hmm. That ends the basics of R Language. You’ve learned how to create and access variables, and how to call functions. You’ve learned how to run pre-made scripts. And you’ve learned how to access R’s help functionality when you need it.

Cheers,

SZ

IRC.. Blog… Learning and Programming in R…. Tweeting…. simultaneously! – Nerd Life

Bonjour,

Tonight I am doing something very crazy which I haven’t done since very long time. The title of the blogpost says it all. But yes, I want to make it a habit now. Though I don’t have a beer in my hand right now like Mark did when he was coding, I do have chilled H2O to cheer me up.

Lets get started. I have been going through the courses on codeschool . There are plenty of uber cool courses on it. But many are paid. Some are free and they do let you to download some of their screencasts which is pretty amazing. There are some courses on drive, how to use the drive api for the application development and today I was encountered with the R language tutorials which were sponsored by O’Reilly [hence they are free].

I started with R now. I am going through baby steps right now in R. Learning how to evaluate expressions and logical values in R 😀

More to come!

Cheers,

SZ

What do you mean by a Hacker?

Hello pals,

Many people have this misconception that Hacker is someone who exploits the computers and steal the sensitive data or information to use it in an illegal way.

I would like to dedicate this blog post to all those people who are in this fallacy.

One thing I would like to convey before I reveal the perfect or the cyber approved elucidation of “HACKER” is that “the person who exploits the computer for fantasy and steals the critical information to use them in an illicit way  is called as a CRACKER“.

Hence I can conclude that  “HACKING != CRACKING” or “HACKER is not a CRACKER”. This is one of the most important principle which should be known by each and every person who is in the field of Computers and Programming. 

Lets jump over and find out what is the perfect definition of a Hacker in this cyber world:

A Hacker is a passionate, skilled and creative technologist who thrives on building innovative solutions to real world problems.

Hacker

Now Lets dig into the answer for “What is a Hack”?

An innovative solution to a real world problem, a quick and dirty workaround, yet effective.

Finally, “What is Hacking”?

Scratching your own itch is nothing but called as Hacking.

Every good work of a software starts by scratching a developers personal itch 😛 😉

 

Hope by now, people who have read this blog post might got some good knowledge about Hacker,Hacking and Cracking! 🙂

 

Picture Credits: Yahoo! Developer Research

“Failed to load JavaHL Library”!-A Disastrous Error

One may get the following error message while installing Subclipse plugin in Eclipse on Mac OS X.

Failed to load JavaHL Library.
These are the errors that were encountered:
no libsvnjavahl-1 in java.library.path
no svnjavahl-1 in java.library.path
/opt/local/lib/libsvnjavahl-1.0.0.0.dylib:  no suitable image found.
Did find:  /opt/local/lib/libsvnjavahl-1.0.0.0.dylib: mach-o, but wrong architecture
This error usually occurs when you are trying to install the subclipse on the 64-bit machine.(This error doesn’t occur if you are using 32-bit machine).
The above error flashes on your screen due to the following reason:
This is because the 64-bit JVM cannot load a 32-bit native library. The CollabNet binaries for OSX do    not have this problem because they include both 32-bit and 64-bit versions.
Solution: Goto this link and download the correct Universal Subversion Binaries file.
For instance if you are using Snow Leopard,then you might probably download the file with “Universal Subversion 1.6.17 Binaries for Snow Leopard (Mac OS X 10.6)” as header.
Unfortunately to download these binaries,you need to register with the CollabNet which is rather painful.This binary package installs the JavaHL.
After downloading the package install it by double clicking the .pkg file.As usual,the installation steps are uncomplicated.
This file creates a folder with “subversion” as name in the “opt” folder. Usually the path would be /MacintoshHD/opt/subversion.
Next step is to update your ./bash_profile file with the following line:
   export PATH=/opt/subversion/bin:$PATH
After you have updated the file close the terminal and then open a new one again.Make sure that you are using the latest version of the Subversion.
You can check this by executing the following line in the terminal:
 svn –version
This should show you something like this :
Image
To test the JavaHL library you can download the javahltests.jar from subclipse.tigris.org
Now Restart your Eclipse and you are done.No more warnings.You can verify that you have got the right version of JavaHL installed  by going to Eclipse->Preferences->Team->SVN.
Under the Svn Interface you will see the version of your JavaHL installed.
Sometimes in the worst situations ,even though you have installed the binaries and Subclipse plugin properly, the Eclipse may give error when you go onto Eclipse->Preferences->Team->SVN as following:
Failed to load JavaHL Library.
These are the errors that were encountered:
no libsvnjavahl-1 in java.library.path
no svnjavahl-1 in java.library.path
Native Library /opt/subversion/lib/libsvnjavahl-1.0.dylib already loaded in the other classloader
/opt/local/lib/libsvnjavahl-1.0.0.0.dylib:  no suitable image found.
Did find:  /opt/local/lib/libsvnjavahl-1.0.0.0.dylib: mach-o, but wrong architecture
If you observe carefully , you would find a new line which is added up to the error message which is
Native Library /opt/subversion/lib/libsvnjavahl-1.0.dylib already loaded in the other classloader
Reason:This occurs if you have already installed the other subversion plugins in your eclipse environment which is preventing  the actual subclipse plugin to load the javaHL library as it is getting loaded in the other subversive plugins. At this point if you goto Eclipse->Preferences->Team->SVN you would find “javaHL not connected” under the Svn Interface.
Solution:When you are installing subclipse plugin in your eclipse environment, make sure that there are no pre installed svn plugins in your eclipse.It would be always better to install the subclipse plugin into an empty eclipse environment which makes your work simple.
Now if you check the Eclipse->Preferences->Team->SVN you would find it as following:
Image