A quirky take on programming languages

OK, this is going to be a little bit un-PC, but what the hell.

PHP is your teenage sweetheart, the girl you first awkwardly fumbled around with that one summer. Just don’t try and start a more serious relationship – this girl has serious issues.

Perl is PHP’s older sister. She might be a bit old for you, but she was pretty popular back in the 90s. She’s looking pretty ugly and scarred now, so you don’t hear from her too much.

Ruby is the cool kid of the scripting family. When you first saw her, she took your breath away with her beauty. She was fun, too. At the time she seemed a bit slow and ditzy – though she’s matured a lot in the last few years.

Python is Ruby’s sensible (and slightly more boring) sister.

Java is a successful career woman. What she lacks in raw intelligence she makes up for in dress – always turned out in immaculateCamelCase, sure to impress the enterprise customers. You might feel like she’s the sensible type you should settle down with. Just prepare for years of “NO THAT DOESNT GO THERE GOD YOU ALWAYS USE THE WRONG TYPE AND YOU MISSED A SEMICOLON” nagging.

C++ is Java’s cousin. Similar to Java in many ways, the main difference being she grew up in a more innocent time and doesn’t believe in condoms/automatic memory management, so be cautious.

is C++’s mom. Mention her name to some old grey beard hackers and they’re sure to reminisce with a twinkle in their eye.

Objective C is another member of the C family. She joined that weird church a while back, and won’t date anyone outside of it.

Haskell, Clojure, Scheme and their friends are those hipster, artsy, intellectual girls you probably spent a blissful college summer with a few years ago. The first girls who really challenged you. Of course, it could never have become something more serious (you tell yourself). Though you’ll always be left asking “what if?”

You might be put off C# due to her family’s reputation. But they’ve gone legit, the last few years, they tell you. Once you’re one of us, you’re one of us, you hear? You need a database? Her brother MSSQL will hook you up. Need a place to stay? Heck, her daddy will even buy you your own mansion on Azure avenue. What’s that, you’re having second thoughts about all these overly friendly relatives? No, you can never leave. You’re part of the family, now, ya hear?

Javascript – hey, wasn’t that the girl you first kissed, way before even PHP came on the scene? I wonder what she’s doing now. I hear her career’s really taken off in the last few years. Would be cool to catch up some time, if only for old time’s sake… (You catch sight of her, dressed head to toe in designer jQuery)… wow,somebody grew into a beautiful swan…

 

 

***Originally posted on quora by Isaac Lewis (http://thectonetwork.com/blog)***

Advertisements

My city

Enabling Root user in Ubuntu

Now root user in Ubuntu is by default disabled. The reason for this is simple, if you login as root user and you did some horrendous or deleted some files in a hurry or by mistake your system might become unusable, but if you still would like to enable the root user and you know what you are doing then its straight forward. Open the terminal and add the following command


$  sudo passwd root

$ <you will be prompted to add the root password twice>

add the root password. Now this will enable the root user in command line interface. If you wish to login as the root from the main system you will have to add the following line

sudo sh -c 'echo "greeter-show-manual-login=true" >> /etc/lightdm/lightdm.conf'

Adding a user to sudoers list

I had been tired of getting this error for a while in my Ubuntu machine “The user is not in the sudoers list. This error will be reported”. Now this was kind of getting over my nerves so I browsed the internet and got this solution. The sudoers list is available in /etc/sudoers so to edit it login as the root and then edit it by hitting the following command visudo. Now navigate the sudoers file and just under


root ALL=(ALL) ALL

add the following line for eg. if the user is testuser to be given sudo privileges


testuser ALL=(ALL) ALL

now save the file by hitting CTRL X and Y

Adding Users and Creating Home Directory in Ubuntu

So it turns out that if you just issue useradd command in your linux machine you will create a user but there will be no home directory. Th problem the added user will not be able to login in his home directory. He can login using cli but not otherwise. So here is how to create user home directory when adding a user


sudo useradd -d /home/testuser -m testuser

sudo passwd testuser

 

this is a as simple as that and another way is using the adduser command in which you can add more detail for the user like phone number and all.

User Administration in Ubuntu

To add a user use the following command

>useradd xyz

when you run the following command a bunch of config files from the /etc/skel directory on your system gets copied in the users home directory.

To set a user password we have to run the following command

passwd  <username>

The password gets stored in the /etc/shadow file and it is encrypted. In the /etc/passwd file our new user gets added in the following format

xyz:x:501:501:ZYX:/home/xyz:/bin/bash

which is

username:passsword:userid:userprivategp:comment:userhomedirectory:bashfile

adding a group

groupadd -r projectX

the -r in groupadd gives the group an id of below 500 in red hat linux as id greater than 500 is reserved for user private group

adding a user to a group

usermod -G projectX,projectY[,groups1,2,3] <username>

you will have to remember all the groups that user is already in if you dont include it the user gets removed from that group

File permissions for users

-(rwx)(rwx)(rwx) for files

user,group,other permissions

d(rwx)(rwx)rwx) for directories the starting ‘d’ indicates a directory

giving permissions to users

chmod g+w filename

or

chmod 777 filename

to give ownership of a directory or a file to the user

chown user.group <filename>

making a user admin of a directory

gpasswd -A <user> <group>

gpasswd -A bob projectX

now bob can add anyone he likes to the group without permissions from the admin

gpasswd -a alice

gpasswd -d alice to delete alice

activating the superuser in ubuntu 12.04

sudo passwd root

add  a password

then

sudo su

authenticate using the password added

ssh git@github.com Agent admitted failure to sign using the key. Permission denied (publickey)

Now this error was something that made me bang my head on the table. I had tried almost everything— looking up in google, stackover flow, adding my ssh key to the github account but nothing seem to work.

the error–

$ Permission denied (publickey).
$ fatal: The remote end hung up unexpectedly

these are some of the solutions on stackoverflow  that I had tried but none seemed to work.

http://stackoverflow.com/questions/7065257/permission-denied-publickey-fatal-the-remote-end-hung-up-unexpectedly-while

http://stackoverflow.com/questions/7065257/permission-denied-publickey-fatal-the-remote-end-hung-up-unexpectedly-while

and finally what did work was the most simplest solution of all

you just have to add these lines

$ ssh-add ~/.ssh/id_rsa

Problems While Deploying Ruby on Rails App on Heroku

Ok this was the second day and it was no less cumbersome than the previous one, tried deploying the app on Heroku and that turned out to be a big headache. so it turns out that heroku doesn’t supports sqlite3. One way of solving this problem is to put sqlite3 in development mode in your Gemfile==> bundle install(again)==> add Gemfile using git and then run git push heroku master.

so if you are facing the following error

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
--enable-local
--disable-local
Gem files will remain installed in /tmp/build_26udn5p5vbb5b/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6 for inspection.
Results logged to /tmp/build_26udn5p5vbb5b/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out
An error occurred while installing sqlite3 (1.3.6), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.6'` succeeds before bundling.
!
! Failed to install gems via Bundler.
!
! Detected sqlite3 gem which is not supported on Heroku.
! http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development
!
! Heroku push rejected, failed to compile Ruby/rails app To git@heroku.com:xxxxxxxxx-xxxxxx-4612.git! [remote rejected] master -> master (pre-receive hook declined)error: failed to push some refs to 'git@heroku.com:powerful-garden-4612.git'

 

 

 

 

source 'https://rubygems.org'

gem 'rails', '3.2.7'

group :development do
 gem 'sqlite3', '1.3.5'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
 gem 'sass-rails', '3.2.4'
 gem 'coffee-rails', '3.2.2'

gem 'uglifier', '1.2.3'
end

gem 'jquery-rails', '2.0.2'

*courtesy Ruby on Rails Tutorial Book by M. Hartl 

copy the above source code from listing 1.5 in the book and probably you will have to change your rails version and sqlite3 version to your current installed version for me it was rails-3.2.8 and sqlite3-1.3.6. After changing this do the following


$ bundle install

$ git add Gemfile

$ git commit -m "Put Sqlite3 into development in the Gemfile"

$ git push heroku master

*courtesy http://stackoverflow.com/questions/7963561/heroku-stack-cedar-cannot-run-git-push-heroku-master

And I believe this will finally solve all your problem

Problems and Fixes While Installing Ruby on Rails on Ubuntu 12.04

So yesterday I finally decided to give Ruby on Rails a try, the installation of which was a major headache and kept me up all night. Some of the major problems that one will face will installing Ruby on rails using Ruby Version Manager especially on Ubuntu are as follows.

ZLIB not installed

The dreaded zlib error

ERROR:  Loading command: update (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::UpdateCommand

It seems that there are some of the libraries that are not pre installed in Ubuntu and because of that ‘gem‘ will not install or update rails. One way to get out of this mess is to install these libraries beforehand, otherwise there will be a problem while installing rails, or while running rails server.

so the 1st thing to do is to install all these libraries with the following command

$ sudo apt-get install zlib1g-dev libssl-dev libreadline6-dev libxml2-dev libsqlite3-dev

and then install ruby if you haven’t installed it yet

rvm install 1.9.3

or reinstall it if you have already installed it

rvm reinstall 1.9.3

Javascript runtime error

Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect'
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
/home/vitalarthur/rails/316-private-pub/chatter-after/config/application.rb:7:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/vitalarthur/rails/316-private-pub/chatter-after/Rakefile:5:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19:in `<main>'

The catch here is that Windows has a builtin JavaScript engine which execjs can locate. On Linux there is not a builtin although there are several available that one can install. therubyracer is one of them. Others are listed in the execjs.

the trick here is to include

gem 'execjs'
gem 'therubyracer'

in your Gemfile which can be found in your first_app directory (the directory which is installed when you run the following command ‘rails new first_app’). So I believe this will take care of some of your problems

and here are a few links which might be useful

http://stackoverflow.com/questions/9202324/execjs-could-not-find-a-javascript-runtime-but-execjs-and-therubyracer-are-in

http://ubuntuforums.org/showthread.php?t=1494997