Skip to main content

Posts

Showing posts from May, 2014

My First Applicaiton in Rails

Here is my gpa calculator app in rails.   cgpacalc.herokuapp.com with some bootstrap. It calculates the gpa and allow users to signup and save their marksheets for their future references. some vim tips: I used vim editor for this development.  There is a plugin called vim-rails  it can make the development much easier. vi editor should be on your box. need to install vim-pathogen  before installing vim-rails mkdir -p ~/.vim/autoload ~/.vim/bundle; \ curl -LSso ~/.vim/autoload/pathogen.vim \ https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim then add this on .vimrc file execute pathogen#infect() after that we can install vim-rails by cd ~/.vim/bundle git clone git://github.com/tpope/vim-rails.git git clone git://github.com/tpope/vim-bundler.git open vim and type :Rails Baisc commands: :Rmodel user :Rcontroller application :Rhelper navigation :Rview sessions/new :Rfunctionaltest sessions :Runittest user

GPA calculator in RUBY

#!/usr/bin/env ruby =begin Prgram : CGPA calculator Date : May 16, 2014 Author : ManiG License : GPL2.0 Version : 1.0 =end sum=0.0 grade = {"S"=>10,"A"=>9,"B"=>8,"C"=>7,"D"=>6,"E"=>5,"U"=>0} tot_credits = 0 tot_egrades = 0 print "enter no. of subjects : " sub_count = gets().to_i sub_count.times do |c| print "enter subject#{c+1}'s credit : " credit = gets().to_i tot_credits += credit print "enter subject#{c+1}'s earned grade :(only 'S','A','B','C','D','E','U') : " e_grade = gets().chomp.upcase tot_egrades += grade[e_grade] sum += grade[e_grade]*credit end gpa = sum/tot_credits puts puts "Credits Earned #{tot_credits}" puts "Grade points earned #{tot_egrades}" puts "GPA #{format("%.4f",gpa)}" puts "CGPA #{format("%.4f",g