Simple CSS3 Transformations – transitions , translations and rotation

 W3C consortium was setup to standardize different browser interpreted languages , but different browser vendors wanted to provide support for experimental css3 features till they are standardized by W3C , such experimental and browser specific css3 features are to used with the prefix provided the vendor , -webkit-(chrome and safari),-o-(opera),-moz-(firefox),-ms-(IE), in the following code snippet i’ve just used -webkit- prefixes , so the code just works in Google chrome browser , to make it work in other browsers , just repeat the attributes with the vendor specific prefixes 

Image

<!DOCTYPE html>
<html>
<head>
<title>First Transform </title>
<style>
h1 {
text-align : center ;
font-family : Futura ;

}
h1:hover {

-webkit-transition :6s all steps(6,end);
-webkit-transform : translateX(600px);
/* the header (h1 ) moves on X-axis (translates) 600px to the right , but the transition(webkit-transition) effect in place
makes sure that this transition takes place over a time of 6 seconds and 6 steps on mouse hover */
}
img.tilt:hover {
-webkit-transform : rotate(9.0deg); /*Rotates the image by 9 degrees on mouse hover and transition makes the effect take place smoothly over a period of 5 seconds */
-webkit-transition : 5s all;
}
</style>
</head>
<body>
<h1>CSS3 Testing</h1>
<p><img src = “deb.jpg” style= “width:300px;height:200px; margin: 0 2em 2em 0;”class=”tilt” >Hi , this is Debian , Debian is a free Operating system , the kernel used by debian is the kernel written Linux torwals .Debian is a free and universal operating system where everything , i repeat , everything in the operating system is free , the source for every binary in DEBIAN is available, All the softwares for debian comes packaged in .deb(.debian) files where these are hosted in their official repositories </p>

</body>
</html>

Advertisements

Writing A Simple WebServer using NODEJS

Well , we should consider ourselves lucky to be in this age of computing where a programmers job is made very easy with usage of modern languages . Writing a Web Server using C was and is a herculian task . With issues like limited buffer size , spawing threads or new processes to cater new clients and bulky system calls with complex structures to pass as parameters everthing has to be explicitly managed . One of the easiest way which i’ve found out to write webservers is by using NODEJS . Concurrency handling mechanisms are taken care of implicitly and programming becomes easy since Java Script is used .Here is a simple webserver written using NODEJS

var http=require('http'),
	url = require('url'),
	mime = require('mime'),//npm install mime
	fs = require('fs'),
	search_path='/home/karthic/mydata/codes';
http.createServer(function(req,res) { 
	 pathname = search_path + req.url;
	 console.log(pathname);

	fs.stat(pathname , function(err,stats){
	  if(err) { 
		res.writeHead(404);
		res.write('Bad Request , Request cannot be accepted');
		res.end()
		}
	else if(stats.isFile()) {
		//content-type
		var type = mime.lookup(pathname);
		console.log(type);
		res.setHeader('Content-Type',type);

		// 200 status - found , no errors 
		res.statusCode = 200;
	
		//create a readable stream and pipe to the http response 
		var file = fs.createReadStream(pathname);
		file.on("open",function() { 
			file.pipe(res);
		});
		file.on("error",function(err) {
			cosole.log(err);
		});
	     }
	else {
		res.writeHead(403);
		res.write('Cannot Access Directory');
		res.end();
		}
	});
}).listen(8324);//listen to port 8324
console.log('Server running at 8324');
		

NODE.JS:Introduction……Writing servers at will…

Have you ever come across a language which is mostly dedicated for writing servers?? we’ll here is one using which you can write servers at will and in a very efficient way too.Node brings in a easy bridge between the system and the web.Node is based on Java Script and google;s V8 Javascript engine

Comparative Advantages of writing servers using node

  • First , the language used for writing Node programs , The Java Sript,this itself makes programmers life very much easier
  • Writing servers using any other programming language is tedious task since multiple access and concurrency mechanisms are to be explicitly taken care of .Spawning a new process or a thread for servicing every new request have to be explicitly code in any programming language , but these things are implicitly taken of by the node since the language itself is particularly dedicated for writing servers.
  • The client gets access to the services of the Node server using their browser
  • Easily write servers for any purpose:From displaying content of a text to the clients to chatting over web page , any resources from the system can be easily utilized to provide services to the clients over the browser
  • The asynchronous programming model:This is a new efficient approach in handling client requests , Node doesnt spawn new processes or threads for catering every clients request , it handles everything in a single thread instance with a new asynchronous approach.

  • Its all about using a module and writing a callback function:Writing codes in NODE is all about loading a module , calling their functions and setting up an callback function on occurance of an event.here is the link of documentation for all node modules Node modules documentation
  • This is how a simple hello world server in nodeJs looks like

    //load http module 
    var http=require('http');
    //create http server 
    http.createServer(function(req,res) {
      	//content header
    	res.writeHead(200,{'content-type':'text/plain'});
    	//write message and signal communication is complete
    	res.write("hello,world!\n");
    }).listen(8124);
    console.log('Server running on 8124');
    

    Here is a node server which reads a file from the disk and displays it for any client who access “serverip:8124” from their browser.The code uses the fs and http modules of the node

    //load http module 
    var http=require('http');
    var fs=require('fs');
    //create http server 
    http.createServer( function(req,res)  {
    fs.readFile('firstnodeserver.js','utf8',function(err,data) {
    	res.writeHead(200,{'Content-type':'text/plain'});
    	if(err)
    		res.write('Could not open the file\n');
    	else
    		//if no error write the file to cilent 
    		res.write(data);
    	res.end();
    	});
    }).listen(8124,function() { console.log('bound to port 8124');});
    console.log('Server running on 8124');
    

Alternalte for /proc/devices/bus/usb in ubuntu

Many Devices programmers who use Ubuntu face a problem while writing USB device drivers ,that is the proc window /proc/devices/bus/usb/devices which is part of usbfs doesnt exist in ubuntu.But there exists a alternate window file to know the list of detected USB devices .The file /sys/kernel/debug/usb/devices gives the same information as one would get from the /proc window .

 

 

XHTML and CSS-3:Table and List styling using basic CSS

<!DOCTYPE html>
<html>
<head>
	<title>CSS TABLES</title>
	<style type="text/css">
	table {border:4px solid blue;}       <!-- CSS and XHTML for styling tables> 
	tr    {background-color:red}
	td    {border:2px dashed yellow} 

	</style>
</head>

<body>
<table>
	<tr>   
		<td>CONTENT1</td>
		<td>CONTENT2</td>
		<td>CONTENT3</td>
	</tr>
	<tr>   
		<td>CONTENT4</td>
		<td>CONTENT5</td>
		<td>CONTENT6</td>
	</tr>
</table>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
	<title>CSS TABLES</title>
	<style type="text/css">
	ul {list-style-type:circle;
	    border:1px dotted blue;}			
	ol {list-style-image:url(linux.png);}    
	<!-- This sets the bullets of ordered list to the image linux.jpg -->
	</style>
</head>

<body>
 	<ul>
		<li>Linux Device Drivers</li>
		<li>JAVA SCRIPT</li>
		<li>LINUX SYSTEM PROGRAMMING</li>
	</ul>
	<ol>
		<li>Linux Device Drivers</li>
		<li>JAVA SCRIPT</li>
		<li>LINUX SYSTEM PROGRAMMING</li>
	</ol>
</body>
</html>

XHTML and CSS-2:BASIC HTML AND CSS

<!doctype html>
<html>
<head>
<title>LISTS</title>
<style type="text/css">
	
        
        h2 {text-align:center;}           <!-- TO align h2 header to centre of the page -->
	p  {text-indent:30px;}            <!-- To indent starting of each paragraph by 30 pixels -->
	ul {color:red;font-style:italic;} <!-- CSS snippet to make all elements in unordered list as red and italic--> 
	ol {color:blue;font-weight:bold;} <!-- To change the ordered list section to blue -->
</style>

</head>
<body>
<h2>MISS YOU</h2>
<p>Here is the unordered Lists</p>
<ul>                                      <!--<ul> is the tag for the unordered list --> 
	<li>karthic</li>
	<li>Suresh</li>
	<li>sun</li>
	<li>RAO</li>
</ul>
<p>Here is the ordered list</p>           <!--<ol> is the tag for the ordered list -->  
<ol>
	<li>Karthic Rao</li>
	<li>Suna</li>
	<li>suresh</li>
</ol>
<p>HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
HHHHHHHHHHHHHHHHHH
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH,</p>	
	
</body>

</html>

Linux Device Drivers-2:My first driver

The headers used to write a Device driver code or a kernel program are not found in /usr/include , they are found in /usr/src/linux-headers-$(uname -r)

Here is a small Device driver code which registers itself .When A device driver is registered using alloc_chrdev_region() , its entry is made in the file /proc/devices with the name mentioned in the same function call .The messages printed using printk() function will not appear on standard output , instead the message can be viewed in the last few lines of dmesg command.

#include<linux/types.h>
#include<linux/kdev_t.h>
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/fs.h>
dev_t devno;
/*first 12 Bits of this 32-bit data type is used to store the MAJOR number of the device and i
  remaining 20 bits for the minor number*/
static int __init constructor(void)/*initialization function,this runs when the module is loaded on top of kernel*/
{
 
 int ret;

 if((ret=alloc_chrdev_region(&devno,0,3,”RAO’s DRIVER”))<0) /*Used to dynamically allocate the major number for the device ,defined in <linux/fs.h>,The device is       
                                                             registered and A device by name “RAO’s DRIVER ” will be seen inside the file /proc/devices*/        
  return ret;
 printk(KERN_INFO “\nMajor NO=%d,MINOR NUMBER=%d\n”,MAJOR(devno),MINOR(devno));/*Kernel’s equivalent of printf,the output can be viewed by using dmesg command*/
 return 0;
}

static void __exit destructor(void)/*Kernel automatically loads this function when the module removed from top of kernel*/
{

 unregister_chrdev_region(devno,3); /*To unregister the registered device */
 printk(KERN_INFO “\nRAO’s module removed”);
}

module_init(constructor);/*Tells the kernel the name of the function to be called when the module is loaded*/
module_exit(destructor);/*Tells the kernel the name of the function to be called when the module is removed*/

MODULE_LICENSE(“GPL”);
MODULE_AUTHOR(“karthic RAO”);
/*More information about hte code is given to the kernel using MODULE_ macros*/
MODULE_DESCRIPTION(“FIRST CHAR DRIVER:D”);

[/sourcecode]

The source code of the Makefile

# If called directly from the command line, invoke the kernel build system.
ifeq ($(KERNELRELEASE),)

    KERNEL_SOURCE := /usr/src/linux-headers-$(shell uname -r)
    PWD := $(shell pwd)
default:
    $(MAKE) -C $(KERNEL_SOURCE) SUBDIRS=$(PWD) modules

clean:
    $(MAKE) -C $(KERNEL_SOURCE) SUBDIRS=$(PWD) clean

# Otherwise KERNELRELEASE is defined; we’ve been invoked from the
# kernel build system and can use its language.
else

    obj-m := test.o

endif

[/sourcecode]

Steps to compile and run the code:Name the source code as test.c and place the Makefile in the same directory.The steps are depicted in the image below

ImageImage