/today time at 5.30 interview with Ram sir bhea technologies (M.D) in our office
http://slashprog.com/
slashprog ..its such a nice experience he talking about the various technologies
and office timings and working culture finally they selected me yogesh and satya
also selected. we are decided to move bangalore they called to join and report
on monday ..
hi to all am kiran today our chandrashekar sir told the project details and start the session how the software software development life cycle SDLC concepts and how to implement agile development
Thursday, December 30, 2010
Wednesday, December 29, 2010
PHP array functions
today myblog
date 29/12/2010
today i learning array functions in php
array_change_key_case
-----------------------
<?php
$x=array('name'=>'john','age'=>25,'city'=>'mumbai');
print_r(array_change_key_case($x,CASE_UPPER));
?>
the output for the above programme is ---->
Array ( [NAME] => john [AGE] => 25 [CITY] => mumbai )
array_combine
----------------------
this array function will taking this arguments as first array treating as array keys and the second array treated as values
so automatically the output will get an associative array
<?php
$a=array('name','age','city');
$b=array('john',25,'chennai');
$c=array_combine($a,$b);
print_r($c);
?>
the output for the above code is
Array ( [name] => john [age] => 25 [city] => chennai )
array_merge
------------
this function will combine and merge the two arrays
<?php
$x=array('name'=>'john','city'=>'chennai');
$y=array('age'=>25,'class'=>'students');
$z=array_merge($x,$y);
print_r($z);
?>
output for the above code is
Array ( [name] => john [city] => chennai [age] => 25 [class] => students )
array_count_values
--------------------
this function returns the same values how many times appeared in that array
<?php
$x=array('city','chennai','welcome','resource','gandhi','freedom','chennai','welcome','chennai','resource','city');
print_r(array_count_values($x));
?>
output for the above program is
Array ( [city] => 2 [chennai] => 3 [welcome] => 2 [resource] => 2 [gandhi] => 1 [freedom] => 1 )
array_diff_assoc
-------------------
this array function comparises two arrays and it eliminates the same values in both array and prints the odd values
<?php
$x=array('chennai','city','welcome','source');
$y=array('chennai','city','welcome');
$z=array_diff_assoc($x,$y);
print_r($z);
?>
output for the above programme is
Array ( [3] => source )
array_diff_key
-----------------
in this array function it will intersect the both array keys and eliminates them and print the odd keys first argument array key values
<?php
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
print_r(array_diff_key($array2, $array1));
?>
o/p
Array ( [yellow] => 7 [cyan] => 8 )
array_fill_key
---------------
this function will fills the key values to the array keys
<?php
$keys=array('name','school','welcome');
$y=array_fill_keys($keys,'oniorns');
print_r($y);
?>
output:-
--------------
Array ( [name] => onions [school] => onions [welcome] => onions )
array_fill
--------------
this function fills insert values into the arrays
array_flip
-------------
this function returns the values as keys and keys as values funny interesting thing to change the keys and values
<?php
$x=array('name'=>'kiran','age'=>25,'city'=>'chennai');
$y=array_flip($x);
print_r($y);
?>
output:--
------------
Array ( [kiran] => name [25] => age [chennai] => city )
array_intersect_assoc
----------------------
this function intersects both the arrays and it will print the common elements in both the arrays
<?php
$x=array('x'=>45,'y'=>25,'z'=>65);
$y=array('x'=>42,'z'=>65);
$z=array_intersect_assoc($x,$y,);
print_r($z);
?>
output of the code
Array ( [z] => 65 )
array_intersect_key
------------------------
<?php
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
print_r(array_intersect_key($array1, $array2));
?>
output for the code is
---------------------------
Array ( [blue] => 1 [green] => 3 )
array_intersect
this function returns the intersection of both the arrays
array_key_exists
----------------
this code will check whether the key exists or not in the programme
<?php
$x=array('name'=>'kiran','city'=>'chennai');
if(array_key_exists('city',$x))
{
echo "find in the array";
}
else
echo "not found in the array";
?>
output := find in the array
array_keys
------------
it will print the array keys
array_map
-------------
<?php
function scope($x)
{
return($x*$x*$x);
}
$a=array(4,5,8,9);
$b=array_map("scope",$a);
print_r($b);
?>
the above code represents the array_map it getting the value from the array and pass it to another array for calucalting the function
output is
Array ( [0] => 64 [1] => 125 [2] => 512 [3] => 729 )
date 29/12/2010
today i learning array functions in php
array_change_key_case
-----------------------
<?php
$x=array('name'=>'john','age'=>25,'city'=>'mumbai');
print_r(array_change_key_case($x,CASE_UPPER));
?>
the output for the above programme is ---->
Array ( [NAME] => john [AGE] => 25 [CITY] => mumbai )
array_combine
----------------------
this array function will taking this arguments as first array treating as array keys and the second array treated as values
so automatically the output will get an associative array
<?php
$a=array('name','age','city');
$b=array('john',25,'chennai');
$c=array_combine($a,$b);
print_r($c);
?>
the output for the above code is
Array ( [name] => john [age] => 25 [city] => chennai )
array_merge
------------
this function will combine and merge the two arrays
<?php
$x=array('name'=>'john','city'=>'chennai');
$y=array('age'=>25,'class'=>'students');
$z=array_merge($x,$y);
print_r($z);
?>
output for the above code is
Array ( [name] => john [city] => chennai [age] => 25 [class] => students )
array_count_values
--------------------
this function returns the same values how many times appeared in that array
<?php
$x=array('city','chennai','welcome','resource','gandhi','freedom','chennai','welcome','chennai','resource','city');
print_r(array_count_values($x));
?>
output for the above program is
Array ( [city] => 2 [chennai] => 3 [welcome] => 2 [resource] => 2 [gandhi] => 1 [freedom] => 1 )
array_diff_assoc
-------------------
this array function comparises two arrays and it eliminates the same values in both array and prints the odd values
<?php
$x=array('chennai','city','welcome','source');
$y=array('chennai','city','welcome');
$z=array_diff_assoc($x,$y);
print_r($z);
?>
output for the above programme is
Array ( [3] => source )
array_diff_key
-----------------
in this array function it will intersect the both array keys and eliminates them and print the odd keys first argument array key values
<?php
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
print_r(array_diff_key($array2, $array1));
?>
o/p
Array ( [yellow] => 7 [cyan] => 8 )
array_fill_key
---------------
this function will fills the key values to the array keys
<?php
$keys=array('name','school','welcome');
$y=array_fill_keys($keys,'oniorns');
print_r($y);
?>
output:-
--------------
Array ( [name] => onions [school] => onions [welcome] => onions )
array_fill
--------------
this function fills insert values into the arrays
array_flip
-------------
this function returns the values as keys and keys as values funny interesting thing to change the keys and values
<?php
$x=array('name'=>'kiran','age'=>25,'city'=>'chennai');
$y=array_flip($x);
print_r($y);
?>
output:--
------------
Array ( [kiran] => name [25] => age [chennai] => city )
array_intersect_assoc
----------------------
this function intersects both the arrays and it will print the common elements in both the arrays
<?php
$x=array('x'=>45,'y'=>25,'z'=>65);
$y=array('x'=>42,'z'=>65);
$z=array_intersect_assoc($x,$y,);
print_r($z);
?>
output of the code
Array ( [z] => 65 )
array_intersect_key
------------------------
<?php
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
print_r(array_intersect_key($array1, $array2));
?>
output for the code is
---------------------------
Array ( [blue] => 1 [green] => 3 )
array_intersect
this function returns the intersection of both the arrays
array_key_exists
----------------
this code will check whether the key exists or not in the programme
<?php
$x=array('name'=>'kiran','city'=>'chennai');
if(array_key_exists('city',$x))
{
echo "find in the array";
}
else
echo "not found in the array";
?>
output := find in the array
array_keys
------------
it will print the array keys
array_map
-------------
<?php
function scope($x)
{
return($x*$x*$x);
}
$a=array(4,5,8,9);
$b=array_map("scope",$a);
print_r($b);
?>
the above code represents the array_map it getting the value from the array and pass it to another array for calucalting the function
output is
Array ( [0] => 64 [1] => 125 [2] => 512 [3] => 729 )
Tuesday, December 28, 2010
PHP
Tuesday PHP
28/12/2010
Intro to php
Php is a server side scripting language most of the websites nowadays developing using php because it is free and open source it is major tough competition to asp.net and java it has lot of inbuilt features for creating dynamic web applications it will be very helpful now maximum share of the websites in the world using php scripting and apache webserver because of its simplicity of code and extraordinary features of having it .acronym for php is “hypertext-preprocessor”
It is compatibility with all database servers mysql,sqlite,postgresql ,oracle and more
Syntax of php
There are 4 ways of syntax declaring php are
<?php ?>
<% %>
<script language=”php”>
<? ?>
Installation of php on windows
For developing web applications we need one server side scripting language and one database server and the operating system whatever it may be and the webserver is apache or IIS whatever it may be
If you go through the xampp pack we get a bundled pack of compenents:
Apache+Mysql+PHP
So the developers need not worry about the installation of xampp pack in windows
Just download the xampp pack in apachefriends.org and select for windows and just save it in which drive you want
C:/ and then change directory to xampp
After installing the xampp stack in windows u get a control panel of xampp stack just open and click the mysql and apache u enable and click start button to enable mysql and apache server
And then later
Open the firefox type this http://localhost
You get the xampp stack web appearance in your firefox desktop
Open the notepad and type the small snippet of code save it your own filename and .php with extension
<?php
Phpinfo();
?>
Save the php files in C:/xampp/htdocs/(“filename.php”)
And later check in the firefox of output of our programme just type the url location http://localhost/(“yourfilename.php”)
Above programme shows the output of php version and php information in the server
Php in Ubuntu
Download the lamp stack from apachefriends.org and extract the tar file in
tar –xvzf (latest version of lamp stack.gz file) –C /opt
u get a folder called lampp and as usual normal u go and type the code in normal note pad and save it in filesystem/var/www with .php extension
if u not have permission to write any files to that folder
sudo chmod 777 –R /var/www
it will give write permission to that particular folder in /var file system
run the code in browser http://localhost/(filename.php)
Getting started with php
php has 4 data types of variables they are
1) scalar
2) compound type
3)special data type
Scalar data types are
Integer,float,string,double
Compound date types
Array,Object
Special data types
Resource,Null
First exercise in php
<?php
echo $_SERVER[‘HTTP_USER_AGENT’];
?>
Normally php variables started with $symbol the above code output wil displays the browser information of which browser we using currently
Arrays in php
Php have 3 types of arrays they are
1)Numeric array
2)Associative array
3)Multidimensional array
1)Numeric array
1)Numeric array
It is ordinary array just we declaring the array values as usual in other languages example
<?php
$myarr = array(‘chennai’,’mumbai’,’calcutta’,’delhi’);
echo $myarr[0]
echo $myarr[1];
echo $myarr[2];
?>
The above code represents we declaring the variable $myarr and assigning the values of city names chennai,mumbai,calcutta and delhi
And printing the values of the variable $myarr[] and the position of the array
The output for the above programe is Chennai,Mumbai,calcutta
2)Associative array
In this array we assign the key values to them
Example
<?php
$myarr=array(‘sachin’=>45,’sehwag’=>75,’talent’=>’ap’);
echo $myarr[‘sachin’] ;
echo $myarr[‘sehwag’];
echo $myarr[‘talent’];
?>
We assign the key values to the above variable in $myarr we will get the output 45,75 and ap
3)Multidimensional Array
We declare array within array is called multidimensional array php has nice feature of this
Example
<?php
$myarr=array(“john”=>array(‘family’=>’chennai’,’age’=>32,’code’=>45),
‘smith’=>array(‘name’=>’school’,’age’=>42,’code’=>23));
echo $myarr[‘john’][‘family’];
echo $myarr[‘john’][‘age’];
echo $myarr[‘john’][‘code’];
echo $myarr[‘smith’][‘code’];
echo $myarr[‘smith’][‘name’];
?>
The above programme output is Chennai,32 ,45,23,school
Saturday, December 25, 2010
Rails session
25/12/2010 --saturday
today we celebrate christmas in our office and we cut the cake and celebrate lots of fun in our office
today our guru chandrashekar sir told the introduction to rails
rails features
today our sir told class responsibilites colloborators
crc (vs) data flow diagram
sir told the difference between them
to generate a model in rails
--------------------------------
rails generate model user
name:string email:string password:string
to check the db
---------------
less config | database.yml
rake db:migrate
to check db exists (or) not
---------------------------
rails dbconsole
rails 3 has an inbuilt nice feature of "sqlite" light weighted database
sqlite> .tables this command will show the list of all tables
sqlite>.schema users to see the users structure
sqlite>.quit --------> to quit the sqlite
to start a server
------------------
rails server
another terminal
---------------------------
cd rails again cd tu
like Irb rails console
-----------------------
u= user.new
u.name="john"
u.password="john123"
u.email="john@doe.com"
u
u.save!
the above lines stating that creating a new user and assigning a password and email id
and save the rails application
another terminal
-----------------------
to show rails console
SELECT *from users
sqlite>
u=user.new:name=>'smith':password=>'smith123':email=>'smith@yahoo.com'
u.save
SELECT *from users
u=user.find-by-name("john")
users=users.find:all //it will find all records
users[0].name
users[1].name
users=user.find:all,:conditions=>{:name=>'john'}
users=user.find:first,:conditions=>{:name=>'john'}
-----------------------------------------------------------------
vi app/models/user.rb
class User<activeRecord ::Base
.validates:name,:presence=>true
.validates:name,:uniqueness=>true
.validates:name,:length=>{:maximum=>32}
end
and sir also told ....best guides to ruby on rails
www.api.rubyonrails.org
today we celebrate christmas in our office and we cut the cake and celebrate lots of fun in our office
today our guru chandrashekar sir told the introduction to rails
rails features
today our sir told class responsibilites colloborators
crc (vs) data flow diagram
sir told the difference between them
to generate a model in rails
--------------------------------
rails generate model user
name:string email:string password:string
to check the db
---------------
less config | database.yml
rake db:migrate
to check db exists (or) not
---------------------------
rails dbconsole
rails 3 has an inbuilt nice feature of "sqlite" light weighted database
sqlite> .tables this command will show the list of all tables
sqlite>.schema users to see the users structure
sqlite>.quit --------> to quit the sqlite
to start a server
------------------
rails server
another terminal
---------------------------
cd rails again cd tu
like Irb rails console
-----------------------
u= user.new
u.name="john"
u.password="john123"
u.email="john@doe.com"
u
u.save!
the above lines stating that creating a new user and assigning a password and email id
and save the rails application
another terminal
-----------------------
to show rails console
SELECT *from users
sqlite>
u=user.new:name=>'smith':password=>'smith123':email=>'smith@yahoo.com'
u.save
SELECT *from users
u=user.find-by-name("john")
users=users.find:all //it will find all records
users[0].name
users[1].name
users=user.find:all,:conditions=>{:name=>'john'}
users=user.find:first,:conditions=>{:name=>'john'}
-----------------------------------------------------------------
vi app/models/user.rb
class User<activeRecord ::Base
.validates:name,:presence=>true
.validates:name,:uniqueness=>true
.validates:name,:length=>{:maximum=>32}
end
and sir also told ....best guides to ruby on rails
www.api.rubyonrails.org
Tuesday, December 21, 2010
jQuery
jQuery
today i getting started with jQuery ..it is an javascript library ..it is simple light weight and more elegant ...we can do more customization becuase its is fully open source we can animate and navigate the objects and play
around with them
Steps to install jQuery
download the latest version of the jquery from jquery website
http://jquery.com/
just click the download button u will get a javascript huge code just
right the mouse and save the page as jquery.js for our convenience we can save it anywhere the file in desktop or file system where it may be
Getting started with jQuery
just open the notepad or vi editor or gedit declare html tags
head,body,and all
in the script tag you specify the source "jquery.js"
jQuery is easy to learn just knowing of Html and javascript and css basics is enough
<script type ="text/javscript" src="jquery.js">
</script>
My First programme in jQuery
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>If you click this sentence this will disappear </p>
</body>
</html>
today i getting started with jQuery ..it is an javascript library ..it is simple light weight and more elegant ...we can do more customization becuase its is fully open source we can animate and navigate the objects and play
around with them
Steps to install jQuery
download the latest version of the jquery from jquery website
http://jquery.com/
just click the download button u will get a javascript huge code just
right the mouse and save the page as jquery.js for our convenience we can save it anywhere the file in desktop or file system where it may be
Getting started with jQuery
just open the notepad or vi editor or gedit declare html tags
head,body,and all
in the script tag you specify the source "jquery.js"
jQuery is easy to learn just knowing of Html and javascript and css basics is enough
<script type ="text/javscript" src="jquery.js">
</script>
My First programme in jQuery
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>If you click this sentence this will disappear </p>
</body>
</html>
Thursday, December 16, 2010
RAILS 3
Rails is a web based framework it running on the top of the ruby....the developer need not worry about the code its simple and easy to create
the web based applications
Rails components
1) Action pack
a)Action Controller
b)Action Dispatch
c)Action View
2)Action Mailer
3)Active Model
4) Active Record
5)Active Resource
6)Active Support
7)Railties
MVC:---Model , View and Controller
what it does ?
M----> the part of the application it interacts with DBMS(oracle,mysql,postgresql,sqlite,sybase,informix,etc..)
persistent data is accessed
V---->view is the part of the application it paints and designs the screen it shows the output of how we look and feel
of the design
C---->controller it acts as an interface between the model and view it acts as a bridge between by controlling the model
and viewing the application
REST based architecture
REST means Representational State Transfer architecture it is the new method of the architecture we accesing the elements
through the URI(Uniform Resource Identifier) or URL(Uniform Resource Locator) through this method we can access the files
through direct URL
FOR example http://localhost:3000/posts.xml it displays the xml format of our data
http://localhost:3000/posts.html it displays the html format of our data
To create a new project in Rails
rails new myblog
we telling this command to rails starting new project using the keyword new the project name is myblog
it creates the directory called myblog
we can see all the switches using the rails-h command
cd myblog --change directory to myblog
student@student:~$ cd myblog
student@student:~/myblog$ ls
app config.ru doc lib public README test vendor
config db Gemfile log Rakefile script tmp
in the README file it contains the basic documentaion file
student@student:~/myblog/app$ ls
controllers helpers mailers models views
controllers:The program files making up the application itself
Where you store all controllers
Models:Where you store all models
Views:Where you store all views
Layouts:Where you store layouts to make "look and feel" uniform
Where Rails configuration is stored
student@student:~/myblog$ cd config
student@student:~/myblog/config$ ls
application.rb database.yml environments locales
boot.rb environment.rb initializers routes.rb
Config: Info to connect to the database.
student@student:~/myblog/config$ ls
application.rb database.yml environments locales
boot.rb environment.rb initializers routes.rb
student@student:~/myblog/config$ cat routes.rb
routes.rb :Determines the URL to access the application
the web based applications
Rails components
1) Action pack
a)Action Controller
b)Action Dispatch
c)Action View
2)Action Mailer
3)Active Model
4) Active Record
5)Active Resource
6)Active Support
7)Railties
MVC:---Model , View and Controller
what it does ?
M----> the part of the application it interacts with DBMS(oracle,mysql,postgresql,sqlite,sybase,informix,etc..)
persistent data is accessed
V---->view is the part of the application it paints and designs the screen it shows the output of how we look and feel
of the design
C---->controller it acts as an interface between the model and view it acts as a bridge between by controlling the model
and viewing the application
REST based architecture
REST means Representational State Transfer architecture it is the new method of the architecture we accesing the elements
through the URI(Uniform Resource Identifier) or URL(Uniform Resource Locator) through this method we can access the files
through direct URL
FOR example http://localhost:3000/posts.xml it displays the xml format of our data
http://localhost:3000/posts.html it displays the html format of our data
To create a new project in Rails
rails new myblog
we telling this command to rails starting new project using the keyword new the project name is myblog
it creates the directory called myblog
we can see all the switches using the rails-h command
cd myblog --change directory to myblog
student@student:~$ cd myblog
student@student:~/myblog$ ls
app config.ru doc lib public README test vendor
config db Gemfile log Rakefile script tmp
in the README file it contains the basic documentaion file
student@student:~/myblog/app$ ls
controllers helpers mailers models views
controllers:The program files making up the application itself
Where you store all controllers
Models:Where you store all models
Views:Where you store all views
Layouts:Where you store layouts to make "look and feel" uniform
Where Rails configuration is stored
student@student:~/myblog$ cd config
student@student:~/myblog/config$ ls
application.rb database.yml environments locales
boot.rb environment.rb initializers routes.rb
Config: Info to connect to the database.
student@student:~/myblog/config$ ls
application.rb database.yml environments locales
boot.rb environment.rb initializers routes.rb
student@student:~/myblog/config$ cat routes.rb
routes.rb :Determines the URL to access the application
Sunday, December 12, 2010
Essentials of Mysql
Essentials of MYSQL
MySQL is a relational database management system it runs as a server providing multi-user access to a number of databases. MySQL is officially pronounced mai es que el ("My S-Q-L"), but is often also pronounced mai sequel ("My Sequel"). It is named after developer Michael Widenius' daughter, My. The SQL phrase stands for Structured Query Language.
Uses of Mysql
MySQL is a relational database management system it runs as a server providing multi-user access to a number of databases. MySQL is officially pronounced mai es que el ("My S-Q-L"), but is often also pronounced mai sequel ("My Sequel"). It is named after developer Michael Widenius' daughter, My. The SQL phrase stands for Structured Query Language.
Uses of Mysql
It is lightweight than other databases
It can perform more flexibility depend on their requirements
We can configure the settings mysql to our own specifications
Installation of mysql
Three things we have to do install mysql
Thursday, December 9, 2010
Practicing Ruby simple Exercise
//today i wrote the sample code of shopping details in ruby
sum=0
for i in 1..2
puts "enter the item name"
name=gets
puts "enter the no.of quantity"
qty=gets.to_i
puts "enter the price details $"
price=gets.to_i
total=qty*price
x=puts "the total price for the #{name} is #{price} and total billed today is #{total} thanks for nice day"
end
puts x
///sample code for railway reservation counter
class RailwayReservation
def enquiry
puts "Welcome to the chennai railway station"
puts "enter ur pnr number"
@x=gets.chomp
end
def reservation
puts "enter the source and destination"
@y=gets.chomp
puts "enter the number of persons to travel"
@z=gets.chomp.to_i
end
def calculation
puts "your Pnr number is #{@x}"
@total= @z * 250
puts "the total fare for #{@z} persons is #{@total}"
end
obj =RailwayReservation.new()
obj.enquiry
obj.reservation
obj.calculation
end
sum=0
for i in 1..2
puts "enter the item name"
name=gets
puts "enter the no.of quantity"
qty=gets.to_i
puts "enter the price details $"
price=gets.to_i
total=qty*price
x=puts "the total price for the #{name} is #{price} and total billed today is #{total} thanks for nice day"
end
puts x
///sample code for railway reservation counter
class RailwayReservation
def enquiry
puts "Welcome to the chennai railway station"
puts "enter ur pnr number"
@x=gets.chomp
end
def reservation
puts "enter the source and destination"
@y=gets.chomp
puts "enter the number of persons to travel"
@z=gets.chomp.to_i
end
def calculation
puts "your Pnr number is #{@x}"
@total= @z * 250
puts "the total fare for #{@z} persons is #{@total}"
end
obj =RailwayReservation.new()
obj.enquiry
obj.reservation
obj.calculation
end
Wednesday, December 1, 2010
Learning Basic Mysql from scratch
today i learning the basics of mysql
just i creating the database
to creating the database in mysql
create database slashprog;
to see the databases after creating the database
show databases;
later we using this command:--- use slashprog;
create a table
like wise we can create "n" number of maximum tables in a database
to see what are all the tables inside our database
syntax:- show tables;
syntax:--- create table (tablename)
create table students(name varchar(32),age int,address varchar(32));
insert values in table
syntax:--- insert into (tablename) values(xxx,25,yyyy);
to see the table structure command is
desc (tablename)
To see all the values in table
select * from (tablename)
To see all the values in the table
select * from students;
+----------+------+--------+
| name | age | salary |
+----------+------+--------+
| kiran | 25 | 25000 |
| sathia | 26 | 10000 |
| john | 28 | 14545 |
| jenefier | 26 | 12454 |
| smith | 29 | 14564 |
| sachin | 30 | 12456 |
+----------+------+--------+
select only names to see the syntax below as follows :---
select name from students;
+----------+
| name |
+----------+
| kiran |
| sathia |
| john |
| jenefier |
| smith |
| sachin |
+----------+
to see the ages of above 26 in the database the command
select age from students where age >26;
+------+
| age |
+------+
| 28 |
| 29 |
| 30 |
+------+
to show the maximum age of of the students
select MAX(age) from students;
+----------+
| MAX(age) |
+----------+
| 30 |
+----------+
to sumup the fields of the salary of the table
select SUM(salary) from students;
+-------------+
| SUM(salary) |
+-------------+
| 89019 |
+-------------+
to see the only few rows in the tables we can set limit to them
select name,age,salary from students LIMIT 3;
+--------+------+--------+
| name | age | salary |
+--------+------+--------+
| kiran | 25 | 25000 |
| sathia | 26 | 10000 |
| john | 28 | 14545 |
+--------+------+--------+
to know the average of the ages
select AVG(age) from students;
+----------+
| AVG(age) |
+----------+
| 27.3333 |
+----------+
to count the number of entries in mysql
elect COUNT(age) from students;
+------------+
| COUNT(age) |
+------------+
| 6 |
+------------+
to see the version of the mysql
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.1.41 |
+-----------+
to see the time and date
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2010-12-02 14:37:02 |
+---------------------+
1 row in set (0.00 sec)
Update command in mysql
update students SET salary=5000,age=26 WHERE name="smith";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> select * from students;
+----------+------+--------+
| name | age | salary |
+----------+------+--------+
| kiran | 25 | 25000 |
| sathia | 26 | 10000 |
| john | 28 | 14545 |
| jenefier | 26 | 12454 |
| smith | 26 | 5000 |
| sachin | 30 | 12456 |
+----------+------+--------+
mysql> delete from students where name="smith";
Query OK, 1 row affected (0.00 sec)
mysql> select * from students;
+----------+------+--------+
| name | age | salary |
+----------+------+--------+
| kiran | 25 | 25000 |
| sathia | 26 | 10000 |
| john | 28 | 14545 |
| jenefier | 26 | 12454 |
| sachin | 30 | 12456 |
+----------+------+--------+
just i creating the database
to creating the database in mysql
create database slashprog;
to see the databases after creating the database
show databases;
later we using this command:--- use slashprog;
create a table
like wise we can create "n" number of maximum tables in a database
to see what are all the tables inside our database
syntax:- show tables;
syntax:--- create table (tablename)
create table students(name varchar(32),age int,address varchar(32));
insert values in table
syntax:--- insert into (tablename) values(xxx,25,yyyy);
to see the table structure command is
desc (tablename)
To see all the values in table
select * from (tablename)
To see all the values in the table
select * from students;
+----------+------+--------+
| name | age | salary |
+----------+------+--------+
| kiran | 25 | 25000 |
| sathia | 26 | 10000 |
| john | 28 | 14545 |
| jenefier | 26 | 12454 |
| smith | 29 | 14564 |
| sachin | 30 | 12456 |
+----------+------+--------+
select only names to see the syntax below as follows :---
select name from students;
+----------+
| name |
+----------+
| kiran |
| sathia |
| john |
| jenefier |
| smith |
| sachin |
+----------+
to see the ages of above 26 in the database the command
select age from students where age >26;
+------+
| age |
+------+
| 28 |
| 29 |
| 30 |
+------+
to show the maximum age of of the students
select MAX(age) from students;
+----------+
| MAX(age) |
+----------+
| 30 |
+----------+
to sumup the fields of the salary of the table
select SUM(salary) from students;
+-------------+
| SUM(salary) |
+-------------+
| 89019 |
+-------------+
to see the only few rows in the tables we can set limit to them
select name,age,salary from students LIMIT 3;
+--------+------+--------+
| name | age | salary |
+--------+------+--------+
| kiran | 25 | 25000 |
| sathia | 26 | 10000 |
| john | 28 | 14545 |
+--------+------+--------+
to know the average of the ages
select AVG(age) from students;
+----------+
| AVG(age) |
+----------+
| 27.3333 |
+----------+
to count the number of entries in mysql
elect COUNT(age) from students;
+------------+
| COUNT(age) |
+------------+
| 6 |
+------------+
to see the version of the mysql
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.1.41 |
+-----------+
to see the time and date
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2010-12-02 14:37:02 |
+---------------------+
1 row in set (0.00 sec)
Update command in mysql
update students SET salary=5000,age=26 WHERE name="smith";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> select * from students;
+----------+------+--------+
| name | age | salary |
+----------+------+--------+
| kiran | 25 | 25000 |
| sathia | 26 | 10000 |
| john | 28 | 14545 |
| jenefier | 26 | 12454 |
| smith | 26 | 5000 |
| sachin | 30 | 12456 |
+----------+------+--------+
mysql> delete from students where name="smith";
Query OK, 1 row affected (0.00 sec)
mysql> select * from students;
+----------+------+--------+
| name | age | salary |
+----------+------+--------+
| kiran | 25 | 25000 |
| sathia | 26 | 10000 |
| john | 28 | 14545 |
| jenefier | 26 | 12454 |
| sachin | 30 | 12456 |
+----------+------+--------+
Monday, November 29, 2010
Ruby
Ruby
-----------------------------
to check the path of the ruby
which ruby
/usr/bin/ruby
-------------------------------
If you executing ruby from shell script
go to vi mode ......and then type the programme and save it in .rb The file name should have extension of .rb and save it any where in !
vi trial.rb
#!/usr/bin/ruby
./trial.rb
--------------------------------
If you executing ruby from normal mode
vi trial.rb (assume that we save in desktop or file system )
ruby trial.rb (to compile the ruby code)
---------------------------------
comments in ruby
single line comment
#This is the single line comment in ruby
multiple line comment
==begin
to start with multiple line comment we have to start ==begin from beggining and ==end from ending
==end
----------------------------------
declaring variables in ruby
a=10
b=10
c=10
parallel way of assigning variables in ruby
a,b,c,d=10,20,30,45
------------------------------------
to know the what type of variables in ruby
a=25
b=45.0
c="welcome"
a.class()
b.class()
c.class()
to check whether it is integer/float/string
a.kind_of? Integer
b.kind_of? String
----------------------------------------
converting variables values
y=20
y.to_s #it converts to string
y.to_f #it converts to float
to convert the integer binary
y.to_s(2) #converts to binary base 2
y.to_s(8) #converts to base 8 (octal)
y.to_s(16) #converts to base 16(Hexa decimal)
--------------------------------
variable scope in ruby
ruby has 5 types of variable scope in ruby
$ --global variable
@-- instance variable
a-z--local variable
A-Z-- constant variable
@@---class variable
to know the type of the variable in ruby
defined? ($x or @x or x or @@x)
-----------------------------
to check the path of the ruby
which ruby
/usr/bin/ruby
-------------------------------
If you executing ruby from shell script
go to vi mode ......and then type the programme and save it in .rb The file name should have extension of .rb and save it any where in !
vi trial.rb
#!/usr/bin/ruby
./trial.rb
--------------------------------
If you executing ruby from normal mode
vi trial.rb (assume that we save in desktop or file system )
ruby trial.rb (to compile the ruby code)
---------------------------------
comments in ruby
single line comment
#This is the single line comment in ruby
multiple line comment
==begin
to start with multiple line comment we have to start ==begin from beggining and ==end from ending
==end
----------------------------------
declaring variables in ruby
a=10
b=10
c=10
parallel way of assigning variables in ruby
a,b,c,d=10,20,30,45
------------------------------------
to know the what type of variables in ruby
a=25
b=45.0
c="welcome"
a.class()
b.class()
c.class()
to check whether it is integer/float/string
a.kind_of? Integer
b.kind_of? String
----------------------------------------
converting variables values
y=20
y.to_s #it converts to string
y.to_f #it converts to float
to convert the integer binary
y.to_s(2) #converts to binary base 2
y.to_s(8) #converts to base 8 (octal)
y.to_s(16) #converts to base 16(Hexa decimal)
--------------------------------
variable scope in ruby
ruby has 5 types of variable scope in ruby
$ --global variable
@-- instance variable
a-z--local variable
A-Z-- constant variable
@@---class variable
to know the type of the variable in ruby
defined? ($x or @x or x or @@x)
Friday, November 26, 2010
Ruby with mysql
today
thiyagu
sir told the difference between ruby using ordinary mysql
and Ruby using ORM(object Relational Mapping)
create a database called student
Ruby code to access the table rubyists (ORM using Ruby)
i wondered here sql function not using anywhere in this programme
Let's write a Ruby program and name it as db_connect.rb
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:database => "students"
class Rubyist < ActiveRecord::Base
end
Rubyist.create(:name => 'Luc Juggery', :city => "Nashville, Tenessee")
Rubyist.create(:name => 'Sunil Kelkar', :city => "Pune, India")
Rubyist.create(:name => 'Adam Smith', :city => "San Fransisco, USA")
Then sir also told the ordinary way of connecting this programme through mysql
thiyagu
sir told the difference between ruby using ordinary mysql
and Ruby using ORM(object Relational Mapping)
create a database called student
Ruby code to access the table rubyists (ORM using Ruby)
i wondered here sql function not using anywhere in this programme
Let's write a Ruby program and name it as db_connect.rb
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:database => "students"
class Rubyist < ActiveRecord::Base
end
Rubyist.create(:name => 'Luc Juggery', :city => "Nashville, Tenessee")
Rubyist.create(:name => 'Sunil Kelkar', :city => "Pune, India")
Rubyist.create(:name => 'Adam Smith', :city => "San Fransisco, USA")
Then sir also told the ordinary way of connecting this programme through mysql
SLASHPROG TECHNOLOGIES
//started project in slashprog technologies //
monday---------------our sir introduces what are all the modules can be coming in our website
we started our ideas about our website details
who we are ...what we doing for website
in three ways we focus on our site
1) trainers side
2) client side
3) vendors side
tuesday-----------------we discussed what technology we going to be use a little argument whether we use jquery and Dojo
finally we decided with Dojo ...its an powerful opensource tool to develop javascript ajax based
applications Dojo advantage is it is compatible with all modern browsers it even work if javascript
not enabled in client side browsers...as a developer we knowing of just html and javascript is enough
not to know new language ...
wednesday -------------
Our team members are
Rajeswari
Yogesh kannan
rakesh
suresh
Rama chandran
and me
we started learning little about ..Dojo just to create a button and checkbox .....we need to install Dojo
and extract zip/tar file and untar it .....we get the files as dojo,digit,dojox,util these 4 files we save it in
js files so the path will be like this
under that js/digit
js/dojo
js/dojox
js/util
writing an application is easy its simple and straight forward ......
just load the dojo library in javascript
-------------------------------------------------------------------------------------
Thursday
we go through and play around some snippets of code in Dojo ..its fun and interesting we and our team members create some small small applications integrate and
finally created a login page and registration page for trainers module ..
we included the library stackcontainer in dojo to get the diaogue box and we created nearly 6 steps to register the trainers form
------------
Friday
our Sir gave introduction about UI flow diagram we discusses what are all the tools to implement whether code ignitor or CakePHP !
sir said how to play with www.960gs.com
and www.balsamiq.com
www.oswd.org
we discussed how the home page of our website look like the features were we include and disable we discussed
-------------------
saturday
saturday sir told what is mysql and how we connect mysql to php and how to create simple database and
to start mysql
just type mysql; it will start mysql in any
------------------------------------------------------
//****Trainers Home Page ***//
1) client requirements matching his skill
2) calendar
3) Update Profile
4)(client/vendor rate )--confidential
5) visitors
6) news ---< 1) location
2) whether
7)Training Statistics
8) Last minute update
9) Payment History *(Only trainer can view )
10)Share his experience
11)Articles/blog
12)How to colloborate with other trainers ?
13) Approve Client request ---------< 1) through vendor
2) Direct Client
14) Interact with Client/Vendor
----> Invoice
----> Training Prerequisites/resources
----> Feedback
Today we learning some basic exercises in ruby
#programme to find vowels in a file
vowels =%w[a e i o u]
count =0
open("a.txt","r").each do |line|
line.split(//).each do |character|
if vowels.include?character
count +=1
end
end
end
print "no of words #{count}"
------------------------------------------------------------
26/11/2010
[Friday]
Today i learning ruby myself practicing small exercises like how to declaring an array in ruby
x=["john","smith","joe","adam"]
x.each{ |i| puts i }
--------------------------------------------
pop it deletes the last element in array
x=["john","smith","joe","adam"]
x.pop
-----------------------------------------
to insert the elements from the beginning of the array
x=["array","range","rahul","sonia"]
x.pop
x.unshift("nickson")
puts x
---------------------------------------------
push to insert the elements in the end of the array
x=["array","range","rahul","sonia"]
x.push("nickson")
puts x
------------------
Deletes the first element of the array
x=["array","range","rahul","sonia"]
x.shift()
puts x
monday---------------our sir introduces what are all the modules can be coming in our website
we started our ideas about our website details
who we are ...what we doing for website
in three ways we focus on our site
1) trainers side
2) client side
3) vendors side
tuesday-----------------we discussed what technology we going to be use a little argument whether we use jquery and Dojo
finally we decided with Dojo ...its an powerful opensource tool to develop javascript ajax based
applications Dojo advantage is it is compatible with all modern browsers it even work if javascript
not enabled in client side browsers...as a developer we knowing of just html and javascript is enough
not to know new language ...
wednesday -------------
Our team members are
Rajeswari
Yogesh kannan
rakesh
suresh
Rama chandran
and me
we started learning little about ..Dojo just to create a button and checkbox .....we need to install Dojo
and extract zip/tar file and untar it .....we get the files as dojo,digit,dojox,util these 4 files we save it in
js files so the path will be like this
under that js/digit
js/dojo
js/dojox
js/util
writing an application is easy its simple and straight forward ......
just load the dojo library in javascript
-------------------------------------------------------------------------------------
Thursday
we go through and play around some snippets of code in Dojo ..its fun and interesting we and our team members create some small small applications integrate and
finally created a login page and registration page for trainers module ..
we included the library stackcontainer in dojo to get the diaogue box and we created nearly 6 steps to register the trainers form
------------
Friday
our Sir gave introduction about UI flow diagram we discusses what are all the tools to implement whether code ignitor or CakePHP !
sir said how to play with www.960gs.com
and www.balsamiq.com
www.oswd.org
we discussed how the home page of our website look like the features were we include and disable we discussed
-------------------
saturday
saturday sir told what is mysql and how we connect mysql to php and how to create simple database and
to start mysql
just type mysql; it will start mysql in any
------------------------------------------------------
//****Trainers Home Page ***//
1) client requirements matching his skill
2) calendar
3) Update Profile
4)(client/vendor rate )--confidential
5) visitors
6) news ---< 1) location
2) whether
7)Training Statistics
8) Last minute update
9) Payment History *(Only trainer can view )
10)Share his experience
11)Articles/blog
12)How to colloborate with other trainers ?
13) Approve Client request ---------< 1) through vendor
2) Direct Client
14) Interact with Client/Vendor
----> Invoice
----> Training Prerequisites/resources
----> Feedback
Today we learning some basic exercises in ruby
#programme to find vowels in a file
vowels =%w[a e i o u]
count =0
open("a.txt","r").each do |line|
line.split(//).each do |character|
if vowels.include?character
count +=1
end
end
end
print "no of words #{count}"
------------------------------------------------------------
26/11/2010
[Friday]
Today i learning ruby myself practicing small exercises like how to declaring an array in ruby
x=["john","smith","joe","adam"]
x.each{ |i| puts i }
--------------------------------------------
pop it deletes the last element in array
x=["john","smith","joe","adam"]
x.pop
-----------------------------------------
to insert the elements from the beginning of the array
x=["array","range","rahul","sonia"]
x.pop
x.unshift("nickson")
puts x
---------------------------------------------
push to insert the elements in the end of the array
x=["array","range","rahul","sonia"]
x.push("nickson")
puts x
------------------
Deletes the first element of the array
x=["array","range","rahul","sonia"]
x.shift()
puts x
Tuesday, November 23, 2010
Subscribe to:
Posts (Atom)