How to use the Window command line (DOS)

How to use the Window command line (DOS):-
Get into the Windows command line
1. Click Start
2. In the Search or Run line type cmd and press enter.
OR
Shortcut to open command line
Window Key + R

Understanding the prompt
1. Listing the files:-
Type “dir” at the prompt to list files in the current directory.
2. To list all based on conditions are
Type “dir*” at the prompt to list files in the current directory.
3. How to create a new file
Type “start notepad filename.rb” here rb(ruby extension file)
likewise you can wordpad file also
Type “start wordpad filename.java” here rb(java extension file)
4. How to edit a file
Type “edit filename.extension” at the prompt to edit a file
5. Copy a file
Type “copy one.html c:\Ruby193\bin\two” at the prompt to copy a file from one location to another.
6. Move a file
Type “move one.html c:\Ruby193\bin\two” at the prompt to move a file from one location to another.
7. View a file
Type “type filename “at the prompt to view a content in prompt.
Type “type filename|more “at the prompt to view a content in prompt.
8. Print a file
Type “print filename”at the prompt to print a file if printer speciality available.
9. delete a file
Type “del filename”at the prompt to delete a file.
10. Rename a file or folder
Type “rename fileone.html filetwo.html”at the prompt to rename a file
11. Create a new folder
Type “mkdir folder-name”at the prompt to create a new directory.
12. Remove a directory
Type “rmdir folder-name”at the prompt to delete a directory.

Advertisements

Installing PostgreSQL & MySQL on a Cloud9 workspace

Installing PostgreSQL on a Cloud9 workspace
PostgreSQL comes preinstalled on every Cloud9 workspace, yay.
1. Start the PostgreSQL service
sudo service postgresql start
2. Set the “postgres” user password
sudo sudo -u postgres psql
psql (9.3.4, server 9.3.5)
Type “help” for help.

postgres=# \password
Enter new password:SGPP
Enter it again:SGPP
postgres=# \q
3. Connect to the service
sudo sudo -u postgres psql
4. Create a PostgreSQL database
Make sure you have logged into the PostgreSQL terminal and then you can just run:

sudo sudo -u postgres psql
postgres=# create database “groceries”;
List all databases
sudo sudo -u postgres psql
postgres=# \list

 

Installing MySQL on a Cloud9 workspace

MySQL comes preinstalled on every Cloud9 workspace, yay.
or else
1. To Install MySQL following command,
mysql-ctl install
2. start MySQL. Will create an empty database on first start
mysql-ctl start
3. stop MySQL
mysql-ctl stop
4. run the MySQL interactive shell
mysql-ctl cli

Create ROLE:-

Create a role that can log in, but don’t give it a password:

CREATE ROLE SGPP LOGIN;

Create a role with a password:

CREATE USER selvapp WITH PASSWORD 'SGPP';

Create a role that can create databases and manage roles:

CREATE ROLE admin WITH CREATEDB CREATEROLE;

 

Locator,Firebug,Xpath,CSS Selector

1. What is Locator?
Locator can be termed as an address that identifies a web element uniquely within the webpage. Locators are the HTML properties of a web element.
2. Firebug
Firebug is a Mozilla Firefox add-on. This tool helps us in identifying or to be more particular inspecting HTML, CSS and JavaScript elements on a web page. It helps us identifying the elements uniquely on a webpage. The elements can be found uniquely based on their locator.You can download the firebug through the following link,
https://addons.mozilla.org/en-US/firefox/addon/firebug/
3. Xpath
Xpath is used to locate a web element based on its XML path. XML stands for Extensible Markup Language and is used to store, organize and transport arbitrary data.You can download the firefox through the following link,
https://addons.mozilla.org/en-US/firefox/addon/xpath-checker/
4. CSS Selector
http://www.softwaretestinghelp.com/css-selector-selenium-locator-selenium-tutorial-6/

Rails: Generate Model vs. Resourse vs. Scaffold

Rails: Generate Model vs. Resourse vs. Scaffold
http://www.korenlc.com/rails-generate-model-vs-resourse-vs-scaffold/

Difference between CHAR and VARCHAR
CHAR
Used to store character string value of fixed length.
The maximum no. of characters the data type can hold is 255 characters.
It’s 50% faster than VARCHAR.
Uses static memory allocation.

VARCHAR
Used to store variable length alphanumeric data.
The maximum this data type can hold is up to 4000 characters.
It’s slower than CHAR.
Uses dynamic memory allocation.
mana madhura yennai mayakuthada sivakasi rathiye sirikindra vediye

What is the difference between VARCHAR and VARCHAR2

VARCHAR can store up to 2000 bytes of characters while VARCHAR2 can store up to 4000 bytes of characters.
If we declare datatype as VARCHAR then it will occupy space for NULL values, In case of VARCHAR2 datatype it will not occupy any space.
Name Varchar(10) – If you enter value less than 10, it utilize total 10 spaces.
Name Varchar2(10) – If you enter value less than 10 then remaining space is not utilize.
VARCHAR is ANSI standard, where VARCHAR2 is Oracle standard

Singleton Method,:: Notation,Object Method

Singleton Method,:: Notation,Object Method

To find local variables in class:-
p local_variables
Scope:-
p self
main
main is an instance of Object that’s created whenever a Ruby program is run. main is the ‘top level scope’ or ‘top level context’ of a Ruby program.

1. What does the following code print? Explain.
module Desk
COLOR = :brown
end
p Desk::COLOR

:brown
:: notation can be used to access constants in modules.

2. What does the following code print?

def blah
“blah blah”
end

class Dog
def speak
“I am #{blah}”
end
end
p Dog.new.speak

“I am blah blah”

The blah() method is a method of the Object class. It is tempting to think the blah() method is not associated with any class, but all methods in Ruby are bound to some class, even if the class definition is not visible. The Dog class inherits from the Object class and has access to the blah() method.

3. Singleton Method
1. What does the following code print? Explain.
my_object = Object.new
def my_object.blah
“blah blah blah”
end
p my_object.blah

“blah blah blah”
blah() is a singleton method added to the my_object object. Singleton methods are methods defined for a particular instance of a class, not all instances of the class. In this example, my_object responds to the :blah message, but other instances of the Object class will not respond to the blah message.

2. What does the following code print? Explain.
class Dog; end
dog = Dog.new
def dog.bark
“ruff ruff”
end
p dog.bark

“ruff ruff”
dog is an instance of the Dog class and is given a singleton method bark(). The bark() method can be called on the dog instance of the Dog class, but is not available for other instances of the Dog class. The following code raises an error.
fido = Dog.new
fido.bark

dog.singleton_methods # [:clan]
The singleton_methods() method lists all the singleton methods that are defined for an object.
3. What does the following code print? Explain.
class Human
def Human.about; end
def self.generation; end
def hi; end
instance_eval do
def bye; end
end
end

p Human.singleton_methods
[:about, :generation, :bye]
There are several ways to define singleton methods. Notice that the Human#hi method is a regular instance method and is not a singleton method.
4. Passing Arguments in ruby

class Person
def initialize(args)
@name = args.fetch(:name)
@age = args.fetch(:age)
end
end
class Yankees
def captain
Person.new({ name: “Jeter”, age: 39 })
end
end

5. Yield Keyword
Code blocks are chunks of code that can be added as the last argument of a method. Code blocks can be delimited by
1. { } or
2. do / end
What does the following code print?
def cool
return yield
end
puts cool {“yes!”}

“yes!”
The yield keyword instructs Ruby to execute the code in the block. In this example, the block returns the string “yes!”. An explicit return statement was used in the cool() method, but this could have been implicit as well.

def nice
yield(“captain”, “planet”)
end
nice do |first_name, last_name|
“#{first_name} #{last_name}”
end

Send method and Object method in ruby

Send method and Object method in ruby
Describe the message and receiver in the following example.
class Calculator
def add(x, y)
x + y
end
end
my_calculator = Calculator.new
my_calculator.send(:add, 3, 4)
my_calculator is the calculator object that is the receiver of the “add” message (and the two arguments that are sent with the add message). When the my_calculator object receives the “add” message, it invokes the add() method. Dot notation is a more common way to send messages (i..e my_calculator.add(3, 4)), but the send() method can also be used to send messages.

What does the following code print?
def blah
“blah blah”
end
class Dog
def speak
“I am #{blah}”
end
end
p Dog.new.speak

“I am blah blah”
The blah() method is a method of the Object class. It is tempting to think the blah() method is not associated with any class, but all methods in Ruby are bound to some class, even if the class definition is not visible. The Dog class inherits from the Object class and has access to the blah() method.