RUBY: Simple code to display N number of string or spaces in ruby on rails


<%= '&nbsp;' * 5 %>

Outputs:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Continue Reading

LINUX: Shortkut keys to use Konsole

Activate Menu-> Ctrl+Shift+F10
Add Bookmark -> Ctrl_Shift+B
Clear Scrollbak and Reset -> Ctrl+Shift+X
Close Active Tab -> Ctrl+Shift+S
Close Other Tabs -> Ctrl+Shift+O
Close Current Tab -> Ctrl+Shift+W
Copy -> Ctrl+Shift+C
Detach Current Tab -> Ctrl+Shift+H
Enlarge Font -> Ctrl++
Expand View -> Ctrl+Shift+]
Find Next Search-> F3
Find Previous Search -> Shift+F3
Find -> Ctrl+Shift+F
Monitor for Activity -> Cttl+Shift+A
Monitor for Silence -> Ctrl+Shift+I
Move to Left Tab -> Ctrl+Shift+Left
Move to Right Tab -> Ctrl+Shift+Right
Open New Tab -> Ctrl+Shift+T
Open New Window -> Ctrl+Shift+N
Move to Next Tab -> Shift+Right
Next View Container -> Shift+Tab
None -> Ctrl+Shift+/
Paste -> Ctrl+Shift+V or Shift+Ins
Paste Selection -> Ctrl+Shift+Ins
Previous TAb -> Shift+Left
Quit -> Ctrl+Shift+Q
Rename Tab -> Ctrl+Alt+S



Continue Reading

PostgreSQL: Handling the sequence value in psql(Reset sequence/ Get sequence next value)

PostgreSQL: Reset the sequence value of the table

Example1

select setval('students_id_seq',1706);

Result

  setval
--------
   1706
(1 row)

===============================

Example2(Recommanded)

To reset the sequence exactly to the recent primarykey id. This is the best idea to reset the sequence by avoiding usual conflicts.

select setval('students_id_seq',(select max(id) from students)) 

Result

  setval
--------
   1706
(1 row)

 

===============================

PostgreSQL: Get the next sequence value of the table

select nextval('students_id_seq');

Result

 nextval
---------
    1707
(1 row)

Continue Reading

RUBY: Easy to create first controller in ruby on rails

Create new controller in ruby on rails is the easy thing. Just follow the following process

[root]# script/generate controller <controller-name>

Sample
script/generate controller registration

this will genereate the following folders/files.

      exists  app/controllers/
      exists  app/helpers/
      create  app/views/registration
      exists  test/functional/
      create  app/controllers/registration_controller.rb
      create  test/functional/registration_controller_test.rb
      create  app/helpers/registration_helper.rb
Continue Reading