Showing posts with label Ruby. Show all posts
Showing posts with label Ruby. Show all posts

Thursday, July 28, 2011

The History of Programming Languages [Infographic]

Rackspace recently published a nice infographic on the evolution of programming languages. It starts with FORTRAN and COBOL and runs through Ruby on Rails (which, yes, is a framework and not a language).

Unfortunately, it omits such influential languages as Lisp, ALGOL 60 and Smalltalk. But including every important language ever would make for a pretty long infographic.

programming languages


The popularity stats at the end are apparently sourced from the oft criticized TIOBE. You can find the full sized graphic and bibliography here.

src: http://rww.to/qXzYH2

Tuesday, July 13, 2010

Attach file in rails

  • First you will need to install " paperclip " gem for ruby.
  • in your terminal write " sudo gem install paperclip -v=2.3.3 "
    • this will install the gem but won't activate it for your application.
    • To activate it you have to go to you environment.rb  file and write the following line:
      • " config.gem "paperclip", :version => '2.3.3' "
    • now your application will load the gem when he start.
Let's take an example as you want to make an avatar to your users. In this case you will need to upload image for each user when he signup or edit his/her profile.

Lets code:

  • In user model:
  • class User < ActiveRecord::Base
        has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
      end
  • Create migration to edit your user table:

ruby script/generate migration add_avatar_columns_to_user
  • Now the migration file:  




  • Update your DB:
rake db:migrate 
  • In your edit and new view:

  • In your show view:

Tuesday, June 22, 2010

Ruby On Rails environment on Ubuntu 10.04

Ruby On Rails environment on Ubuntu 10.04: "
Hi,

I think this is my first technical post in the blog, so today I faced some problems while building the Ruby on Rails environment on my machine. I just like sharing this knowledge with you.

First, in this post we will make the following:

  1. Ruby 1.9.1
  2. Rails 2.3.5
  3. Thin server.
  4. MySQL server.

1. Ruby 1.9.1

The following commands mainly download the Ruby source code and compile it and so on
Just you have to install the following libraries:
sudo apt-get install build-essential libssl-dev libreadline5-dev zlib1g-dev

move to /usr/local/src to download source code and compile it in this folder
cd /usr/local/src

Download the source code, and unpack it
sudo wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz
sudo tar xzf ruby-1.9.1-p0.tar.gz
cd ruby-1.9.1-p0


Now, you have to check the version of gcc if it is 4.4 some errors will occur
dpkg -l | grep gcc

if gcc 4.4 found then you have to edit the cont.c file to go on. Open it up, and change the lines 90, 270 and 317 from #elif to #else.
sudo gedit cont.c

then write the following commands in terminal
sudo ./configure –prefix=/usr/local/ruby-1.9.1
sudo make
sudo make install


After these steps you have finally installed Ruby 1.9.1, to check its version
cd /usr/local/ruby-1.9.1/bin
ruby -v

output like that: ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]


Now, the ruby commands such as ruby, rake, irb, … etc are accessed only from /usr/local/ruby-1.9.1/bin, and all the commands are found in /usr/local/bin so just make link for the commands in ruby-1.9.1/bin and put them in /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/ruby /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/rake /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/gem /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/irb /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/ri /usr/local/bin
sudo ln -s /usr/local/ruby-1.9.1/bin/rdoc /usr/local/bin



2. Rails 2.3.5
Now, Ruby 1.9.1 is installed successfully on your machine, just add this command to terminal to install the Rails 2.3.5 gem
sudo gem install rails -v=2.3.5

3. Thin server
Also to install Thin application server gem
sudo gem install thin

4. MySQL server
Finally to install MySQL server for DB
sudo apt-get install mysql-server
and while installing it is required to set the root password

References: http://labnotesh.wordpress.com/2009/04/28/compiling-ruby-19-with-gcc-4/

Hope that it is some how useful for you

Enjoy :)


Source : Mohammad Kotb's Blog

"