Learn Geek languages like Big data,Hadoop,Hive,Pig,Sqoop ,flume,Cassandra,Hbase,Ruby On Rails,Python,Java and many more.

Wednesday 13 July 2016


class Person < ApplicationRecord
  validates :name, presence: true
end

 OR

class Person < ApplicationRecord
  validates :name, :login, :email, presence: true
end

class Person < ApplicationRecord
  validates :terms_of_service, acceptance: true
end

class Person < ApplicationRecord
  validates :email, confirmation: true
end

class Product < ApplicationRecord
  validates :legacy_code, format: { with: /\A[a-zA-Z]+\z/,
    message: "only allows letters" }
OR a-z,A-Z,0-9
end

class Person < ApplicationRecord
  validates :name, length: { minimum: 2 }
  validates :bio, length: { maximum: 500 }
  validates :password, length: { in: 6..20 }
  validates :registration_number, length: { is: 6 }
end

class Player < ApplicationRecord
  validates :points, numericality: true
end

class Account < ApplicationRecord
  validates :email, uniqueness: true
end

Monday 4 July 2016

TAGS:

ERB tags                   <%    %>
print ERB tags          <%=  %>
print ERB comment  <%# %>
if block                      <% if %>...<% end %>
if / else                       <% if %>...<% else %>...<% end %>
else tag     else           <% else %>
elsif tag     elsif          <% elsif %>
end block     end        <% end %>
link_to helper             <%= link_to ..., ... %>
form_for helper     form      <%= form_for(@) do %>

Helpers:

   Form Component     Output Code Snippet

   f.submit                       <%= f.submit "Submit"  %>
   f.password_field          <%= f.password_field :attribute %>
   f.text_area                   <%= f.text_area :attribute %>
   f.check_box                 <%= f.check_box :attribute %>
   f.label                          <%= f.label :attribute, "Attribute" %>
   f.text_field                   <%= f.text_field :attribute %>
   f.file_field                    <%= f.file_field :attribute %>
   f.hidden_field              <%= f.hidden_field :attribute %>

Monday 27 June 2016

<html>
       
<body>
<!----heading-->
<h1> GEEK</h1>
<h1>Geek Languages</h1>
<hr />
<h2>Geek Languages</h2>
<hr />
<h3>Geek Languages</h3>
<h4>Geek Languages</h4>
<h5>This is a Heading 5</h5>
<h6>Geek Languages</h6>
<!---paragraph-->
<p>Geek Languages</p>

<p>
My Bonnie lies over the ocean.
My Bonnie lies over the sea.
My Bonnie lies over the ocean.
Oh, bring back my Bonnie to me.
</p>

<!---tags-->
<p><b>This text is bold</b></p>
<p><strong>This text is strong</strong></p>
<p><big>This text is big</big></p>
<p><em>This text is emphasized</em></p> <br />
<p><i>This text is italic</i></p><br />
<p><small>This text is small</small></p>
<p>This is<sub> subscript</sub> and <sup>superscript</sup>
</p>
<p>
a dozen is
<del>twenty</del>
<ins>twelve</ins>
pieces
</p>

<!--pre fromateed text--->
<pre>
This is
preformatted text.
It preserves
both spaces
and line breaks and shows the text in a monospace font.
</pre>

<!-- anchor tag--->
<a href="http://www.geeklanguages.blogspot.com">This is a link to my Web site.</a>

<!-- IMAGE TAG-->
<img src="aa.png" width="104" height="142" /> <br/>
<!-- ABBREVATION-->
<abbr title="United Nations">UN</abbr>
<br />
<acronym title="World Wide Web">WWW</acronym>


<!---table-->
<h4>A background image:</h4>
<table border= "3" background="aa.png">
<tr>
<td bgcolor = blue>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
<tr>
</table>

<!---table with spans-->

<h4>Cell that spans two columns:</h4>
<table border="1">
<tr>
<th>Name</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>555 77 854</td>
<td>555 77 855</td>
</tr>
</table>

<!---table with cell padding-->
<h4>With cellpadding:</h4>
<table border="1" cellpadding="10">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>

<div>
<table border = "2">
<th align="left">Money spent on....</th>
<th align="right">January</th>
<th align="right">February</th>
</tr>
</table>
</div>
<!--text color-->
<p style="color:grey" width = "150">
Color set by using color name
</p>



<!--Ordered (Numbered) List-->
<ol>
<li>First item</li>
<li>Next item</li>
</ol>

<!---  Definition List -->
<dl>
<dt>First term</dt>
<dd>Definition</dd>
<dt>Next term</dt>
<dd>Definition</dd>
</dl>


<!--Unordered list--->
<h4>A nested List:</h4>
<ul>
<li>Coffee</li>
  <li>Tea
   <ul>
<li>Black tea</li>
<li>Green tea
      <ul>
<li>China</li>
<li>Africa</li>
      </ul>
   </li>
</ul>
</li>
<li>Milk</li>
</ul>
</body>


</html>

<!---USE OF FRAMES--->
<html>
<frameset rows="50%,50%">
<frame src="frame_a.htm">
<frameset cols="25%,75%">
<frame src="frame_b.htm">
<frame src="frame_c.htm">
</frameset>
</frameset>
</html>
Ruby was created by Yukihiro Matsumoto, or "Matz", in Japan in the mid 1990's. It was designed for programmer productivity with the idea that programming should be fun for programmers. It emphasizes the necessity for software to be understood by humans first and computers second.
Ruby continues to gain popularity for its use in web application development. The Ruby on Rails framework, built with the Ruby language by David Heinemeier Hansson, introduced many people to the joys of programming in Ruby. Ruby has a vibrant community that is supportive for beginners and enthusiastic about producing high-quality code.

Ruby is "A Programmer's Best Friend".


Features of Ruby

  • Ruby is an open-source and is freely available on the Web.
  • Ruby is a general-purpose, interpreted programming language.
  • Ruby is a true object-oriented programming language.
  • Ruby is a server-side scripting language similar to Python and PERL.
  • Ruby can be embedded into Hypertext Markup Language (HTML).
  • Ruby has a clean and easy syntax that allows a new developer to learn Ruby very quickly and easily.
  • Ruby has similar syntax to that of many programming languages such as C++ and Perl.
  • Ruby is very much scalable and big programs written in Ruby are easily maintainable.
  • Ruby can be used for developing Internet applications.
  • Ruby can be installed in Linux,Windows environments.
  • Ruby can easily be connected to Sqlite, MySQL, Oracle.
  • Ruby has a rich set of built-in functions, which can be used directly into Ruby scripts.


#class with rescue and raise in ruby program

class Question
attr_accessor  :a1, :a2
def initialize(a1,a2)
@a1=rand(50)
@a2=rand(50)

end
def make_random_substraction
begin
puts 'Random Substraction of two numbers.'

puts "What is '#@a1' - '#@a2' ?"


@a3 = Integer(@a1) - Integer(@a2)
puts "#@a3"

if @a3<0
raise 'exception'
end

rescue
puts "An exception : answer is in negative value."
puts "Lets retry it in other order."
@a3 = Integer(@a2) - Integer(@a1)

puts "Here, answer is : #@a3"
 
end
end
end
obj=Question.new(@a1,@a2)
obj.make_random_substraction


OUTPUT:

Random Substraction of two numbers.
What is '18' - '1' ?
17

Friday 24 June 2016

Installation of ruby

1.tar your ruby-2.3.1.tar.gz in root
2.go to ruby-2.3.1 folder in root
3 than run these commands
>>  ./configure
>> make
>> make install

Installation of rvm

1.tar rvm-1.27.0.tar.gz
2.for set the path ,write this following command
 >> sudo gedit .bashrc
paste this line in your .bashrc file
 export PATH=$PATH:/home/ratul/ruby/rvm-1.27.0/bin
3.rvm automount
 it will ask for give the name, mention any name
4.rvm use --default
5. rvm list

Installation of Rubygem

1.unzip your rubygem-2.6.4.zip
2.move into root by
>>sudo su
3.go to rubygem directory
4. run command
>>ls
5. you can see the file setup.rb
6. now run
>>ruby setup.rb


FOR FURTHER QUERY
Contact On  :  +919814040990
# use of class in ruby program

class Abc
attr_accessor :a1, :ans
def initialize (a1,ans)
@a1 = a1
@ans = ans



def ask
   puts "Question #{a1}"
a = gets.chomp


if a == "#@ans"
puts "correct"
else
puts "wrong, answer was 8"
end
end
end
end
a=Abc.new("what is 3 + 5","8")
a.ask

OUTPUT:

Question what is 3 + 5
4
wrong, answer was 8