July 2009 ~ MY Thoughts & Learnings

Friday, July 24, 2009

Counter using atmega 8

Enjoyed previous videos???
I programmed atmega8 along with my friend divya alok (class mate) to display numbers (0-9) on a 7 Segment Led.

This is also based on simple I/O pin control




I Hope that you liked it.
Good Day

LED Flashing

This video shows LED Flashing and blinking to generate beautiful patterns.The kit you see in the video is the Development & Learning Kit made by Gadre sir.He is extremely qualified teacher and fortunately he is a professor in my college NSIT.I along with a friend programmed this kit to display patterns.It is extremely simple programming of setting I/O pins on or off.



5 Volt DC Supply

Hi,
watch the following video of a 5 Volt Power Supply i made along with my friend.
enjoy,




To know how this circuit works visit


http://harshtripathi.blogspot.com/2009/06/dc-power-supply-5-volts-imax-1a.html

My First Website using JAVA J2EE & Javascript

I have made a website using jsp & servlets.This was built by me only for educational purpose i.e Learning By Doing process.




Features include :

1. JavaScript for Client Side Validations.
  • This makes filling long & tedious looking forms to be filled in seconds.As you can see in the video below, using JavaScripts has made Registration & Login page page more User-friendly
  • I have used it to catch some events such as onblur, onfocus etc thrown by the form elements.
2. Ajax
  • Ajax makes everything so easy for the client/visitor.It communicates with the server in the background makes available all the data required either from a file or database and makes it available to the user.This all happens without refreshing or loading the page!!!
3. Jsp & Servlets
  • This is the backbone of whole project.These are the server pages which listen to the request from the client(actually web-browser) and accordingly is generating a response
  • For example - when the user clicks submit on Login page.It is the server page JSP that communicates to the database using an underlying bean ( a java class file).If the user is found then a session is created & attributes are set.Finally user is again moved to the main page.
4. CSS or style tag
  • These are used extensively to apply a desired design format on the entire JSP page.
  • Best part - In order to change the style/appearance of elements in a page you have two options - i) You would have to place standard html tags in each of the required places throughout the page OR ii)The better way is to set the style for the element types in one place which would effect the whole page.Futher one can have external css which makes the style format once set to be used in many pages.
5. File data Handling
  • For Post file data handling has been done which can be used to post data on the website.
6. Jsp & Html
  • This was the Best feature incorporated by SUN professionals which makes java web development extremely simple.
  • Feature is - you can mix up HTML & JAVA Scriptlets any number of times without hesitation.
  • The data you see on the home page which i call posts are actually dynamically read from the disk and presented to you in the form of a table (with border = 0)
7. Flash
  • I may not be a pro in using Macromedia flash.But i managed to make the text effects you see in the banner on the top.I have embedded these swf(s) in my blog too.They look COOL!!! Isn't it
8. Session Handling
  • It is very important to keep track information about the visitor/user visiting your blog.
  • For example - I don't wan't a person to be able to post data to my website unless and until he has registered himself to my website and has Loggined into the website.This is integral for admin management of the website.
  • can be done by session handling,cookies,url rewriting,hidden text field.I have used first two i.e Session creation & writing cookies to the client.
If you have any problems/suggestions please let me know
harshtripathi.blogspot.com

Sunday, July 19, 2009



King of music .... i was shocked at hearing the death of a great artist.I never believe that he died of pill overdose(or something like that).

check the following link giving some insights into his life.

Michael Jackson’s life cut shockingly short

He would always live in heart of his fans

Q-4 What is a "MIME Type"?




MIME (Multipurpose Internet Mail Extensions) is used to extend the format of the internet emails to send non-textual,Non-ASCII data such as pdf,image etc through a E-mail.MIME Type- in the response header we have Content-Type: text/html this is called MIME type as it describes the type of data that is sent as a response to the Client.This Content-Type can have only those formats which are also in Accept field in the request header.

Q-3 Get & Post what are they?

Both are the methods of the HTTP protocol.Whenever client wants to access a resource from the server the web browser generates a HTTP Request.This request can either be in get or post method.Get is used to pass limited and insensitive/non-personal/insecure data to the server.Data sent through this is visibleto the client.Whereas Post is much more powerful technique where large amount of data can be sent & still client is unable to see that data.Post is generally used for username,password,credit card number etc which are personal and sensitive data that needs to be hidden.

GET EXAMPLE

http://www.google.co.in/search?hl=en&q=java&meta=&aq=f&oq

http:// is the protocol used.

http://www.google.co.in is the host/server/container URL.

/search is the path to the resource on the server

?hl=en&q=java&meta=&aq=f&oq= after the ? are the parameters sent to the server in this GET Request.For example - hl=en means that language is English. & is used to separate two parameters. Along with this Request header is also sent which has details such as User-Agent,Accept,Accept-Language,Keep-Alive etc.Giving General information about the client.

Whereas in post method -
1. Is much more Powerful than get method
2. Any amount of data can be sent.
3. Client is not able to see the data sent to the request thus protecting the personal/secured data from being viewed by anybody.

Remember : doGet() is the default method of the servlet and is automatically executed when the servlet/JSP page is run for the first time.


Q-2 You need to make your Website scalable.What is meant by Scalable?

If a Website is scalable it means that even if Load increases(large no. of client are trying to access the server) it does not substantially effect the performance & speed of request-response routine.

One of the frequently used technique for this purpose is Caching.

Caching Basics

Retrieving data from the database is time-expensive whereas doing the same from a File/Memory(HashMap) is fast.Therefore it helps the server to deliver the resource quickly.

Caching is done under following conditions -

1. For the data which is frequently demanded from the clients
2. Admin of the website is making changes in the database.Therefore cached data must also be updated.
3. Caching is done for the first request.next time a client tries to access the data, it is fetched from the cached file and not from the database

Friday, July 17, 2009

Interview Questions ( One question per Post )

From now on i will be posting some very basic questions(one question per post) when it comes to Website Development or those asked in an Interview.I thought that this would be the best way to learn things quickly for a newbie.

I have given the answer as per my understanding & would not be responsible for any harm to you with this inf.

Enjoy!!!!...............................................

Q-1 What is HTTP Protocol so much talked about?

Hypertext Transfer Protocol is a Stateless protocol i.e there is no information about which client is making the request.A request is sent by the Client to the Server & Server looks for the resource through buissness logic/Data Model.Then it sends the data back as a response to the Client.It runs on top of TCP/IP protocols and uses basic request-response routine for srving the client.TCP - Transfer Control Protocol is responsible to ensure that file sent from one network node to another ends up as a complete file.Whereas IP - Internet Protocol has the responsibility for routingthe packet of data for reaching it's proper destination.

Monday, July 13, 2009

JAVA JMF IMAGE CAMERA

JMF
i have introduced with it's fundamentals in my previous .Here is the java src code of a program which captures images from the camera and process a bit before saving to the disk.
Enjoy,
Capture using JMF


If any problem in understanding the code you can mail me at harshblog.query@gmail.com i will reply asap.

ROBOTICS BOOK DOWNLOAD 150+


ROBOTICS

Ever found interest in building your own ROBOT the visit the following link.

Download this text file containing to 150+ books

I am in no way hosting links given in the text file.If it violates any norms please inform me.I don't have much inf with copyrights.Thanks for your co-operation

Saturday, July 11, 2009

INTRO TO TECHNOLOGIES FOR DEVELOPER

FOR JMF look into one of my previous post.

HI,


JSP/Servlets

It's easy on JAVA to built websites business or data logic.with JSP/Servlets built server pages to handle the client request and process as per the requirement.Yes i do agree that php,ruby,python developers would now start roaring at me to say that JAVA lacks speed both in development and processing.

But the buisness logic which Java can provide is unmatchable(as i think).If you are a beginner then first study about Servlets , as once you get acquainted with it you would find JSP very easy.

JSP offers

1.
HTML embed for Static design and Scriptlets(<% %>) for JAVA based code.

2. Concept of Implicit Object has greatly reduce the workload while working with JSP.
Ex- response,request,out etc.You can directly type <% out.println("hello") %>

3. Further JAVA has highly rich TAG Library JSTL(Java Standard Tag Library).

4. You can also add JavaScript functionality in your JSP page. JavaScript is used to enhance the working and appearance of your web pages by making it more dyanamic.It is extensively used for client side validations.The only limitation does it offer is it's inability to communicate with the server.But with Ajax & JavaScript combined this limitation is also overcomed.

To run these pages you require a Server(container).Among the most widely used are NetBeans GlassFish,Apache Tomcat etc.

Most Importantly : In Java it is very easy to built a three-tier logic.


AJAX

-> AJAX stands for Asynchronous JavaScript And XML.
-> AJAX is a type of programming made popular in 2005 by Google (with GoogleSuggest).
-> AJAX is not a new programming language, but a new way to use existing standards.
-> With AJAX you can create better, faster, and more user-friendly web applications.
-> AJAX is based on JavaScript and HTTP requests.
-> With AJAX, JavaScript can communicate directly with the server, using the JavaScript XMLHttpRequest object. With this object, JavaScript can trade data with a web server, without reloading the page.

AJAX uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages.

-> The AJAX technique makes Internet applications smaller, faster and more user-friendly.
-> AJAX is a browser technology independent of web server software.
AJAX is Based on Web Standards

AJAX is based on the following web standards:

1.
JavaScript
2. XML
3. HTML
4. CSS


XMLHttpRequest:

This class is for Firefox, Opera, Safari.
Var obj=new XMLHttpRequest()

ActiveXObject:

This class is for IE.
Var obj=new ActiveXObject("Msxml2.XMLHTTP") // for 6.0+
Var obj=new ActiveXObject("Microsoft.XMLHTTP") // for 5.0+

Properties:

1. onreadystatechange
2. readyState
3. responseText

onreadystatechange
The onreadystatechange property stores your function that will process the response from a server.

xmlHttp.onreadystatechange=function()
{
// We are going to write some code here
}

readyState

The readyState property holds the status of the server's response. Each time the readyState changes, the onreadystatechange function will be executed.


State Description
0 The request is not initialized
1 The request has been set up
2 The request has been sent
3 The request is in process
4 The request is complete


responseText
The data sent back from the server can be retrieved with the responseText property.

xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.myForm.time.value=xmlHttp.responseText;
}
}

The web standards used in AJAX are well defined, and supported by all major browsers. AJAX applications are browser and platform independent.

Remember : AJAX is not an application it is a Technique which make the appearence of the pages to look more Dyanamic and User Friendly.


3. Python

It helps in very fast development of software.It is also object oriented and introduces special data types like tulips,list & dictionary.Every program can also be thought as modules and these can also imported easily.
like

>>import Image

It also has control statements like if-else & loop statements for while statement with slight difference in syntax

>>for x in range(0,3):
... print x
...
>>0
1
2
>>x = 10
>>if(x<12):>>import Image
>>i = Image.open('c:\line.bmp')
>>i.show()

for making functions
>>def sum(x,y):
... return (x+y)
...
>>sum(4,5)
9

for writing into files
>>harsh = open("hello","w")
>>harsh.write("HARSH TRIPATHI BLOGSPOT IS BEST")

keywords : jsp,servlets,jfx,struts,jsf,hibernate,AJAX,JMF,python,vhdl,ruby,php

SOME SAMPLE JAVA SOURCE CODES

1. NOTEPAD beta - it is very basic program for the beginners to make their own notepad.I have BUILT this just for educational purpose to understand basic javax.swing.* and File I/O

2. Database - This is also for educational purpose showing use of JDBC to connect to a MS Access database(*.mdb) and perform some basic operation.

3. Using JMF to capture image from a usb camera and save it to disk after converting into jpeg.

If you are interested in any of the above

Send me mail at harshblog.query@gmail.com i will reply asap

I have made many other cool apps .... KEEP VISITING MY BLOG FOR THEM

JMF BASICS

hi,

Ever wanted to work with multimedia files,capturing data from the camera and processing encoding as per the requirement.Yes i know this looks quite interesting let's get started with basics :

Java™ Media Framework (JMF)

1. Provides a unified architecture and mes-saging protocol for managing the acquisition, processing, and delivery of time-based media data.

2. JMF is designed to support most standard media content types, such as AIFF, AU, AVI, GSM, MIDI, MPEG, QuickTime, RMF, and WAV.

I have tried to divide things in components so that it is easier to understand

Media Streams -
  • Can be media from file,network,camera.media format
  • Some have media stream containg multiple channel of data called tracks.hence Demultiplexing is required to get the data.such is called complex media stream.

To locate the source-

1. File protocol is used for files as sources
2. HTTP protocol for network
3. MediaLocator to locate media when URL can't be used

Media Streams Types:

1. Pull type - initiated and controlled by client - file and http protocol
2. Push type - from the server side initiated like RTP,SGI MediaBase used for VOD(video on demand)

CLASSES FOR SOURCES

1. Pull Data Source - Types of pull data sources:
  • PullDataSource
  • PullBufferDataSource, which uses a Buffer object as its unit of transfer.
2. Push Data Source - Types of push data sources:
  • PushDataSource
  • PushBufferDataSource, which uses a Buffer object as its unit of transfer Specialty DataSources

JMF defines two types of specialty data sources

1. Cloneable data sources

2. Merging data sources.


1. Cloneable Data Source -
  • Can be used to create clones of either a pull or push DataSource.
  • To create a Cloneable DataSource, you have to call the Manager cloneableDataSource method and pass in the DataSource you want to clone. Once a DataSource has been passed to create CloneableData-Source, you should only interact with the cloneable
  • DataSource and its clones
  1. the original DataSource should no longer be used directly.Cloneable data sources implement the SourceCloneable interface, which defines one method, createClone. By calling createClone, you can create any number of clones of the DataSource that was used to construct the Cloneable DataSource.
  2. The clones can be controlled through the cloneable DataSource used to create them.
  3. The clones don’t necessarily have the same properties as the cloneable data source used to create them or the original DataSource. For example, a cloneable data source created for a capture device might function as a master data source for its clones—in this case, unless the cloneable data source is used, the clones won’t produce any data. If you hook up both the cloneable data source and one or more clones, the clones will produce data at the same rate as the master.

2.MergingDataSource -
  • Can be used to combine the SourceStreams from several DataSources into a single DataSource.
  • This enables a set of Data-Sources to be managed from a single point of control—when connect, disconnect, start, or stop is called on the MergingDataSource, the method calls are made to the merged DataSources.To construct a MergingDataSource, you call the Manager createMerging-DataSource method and pass in an array that contains the data sources you want to merge. To be merged, all of the DataSources must be of the Understanding JMF 19 same type.For example, you cannot merge a PullDataSource and a Push-DataSource. The duration of the merged DataSource is the maximum of the merged DataSource objects’ durations.

Latency - it is the time lag between actual start of the video after clicking start button.when synchronizing multiple streams then it must check for latency of each stream.
  • For example if i want to save the video captured by a camera to a file
1. Audio and video tracks are captured
2. Each individual tracks would be encoded and then multiplexed into a single media stream.
3. Multiplexed data is saved to file.

Codecs
  • A codec performs media-data compression and decompression.
  • When a track is encoded, it is converted to a compressed format suitable for storage or transmission; when it is decoded it is converted to a non-compressed (raw) format suitable for presentation.effect filters are applied to uncompressed (raw) data if needed.

Renderer -
  • A renderer is an abstraction of a presentation device. For audio, the presentation device is typically the computer’s hardware audio card that out-puts sound to the speakers. For video, the presentation device is typically the computer monitor.

Compositing -
  • Certain specialized devices support compositing. Compositing time-based media is the process of combining multiple tracks of data onto a single presentation medium.
  • For example, overlaying text on a video presentation is one common form of compositing. Compositing can be done in either hardware or software. A device that performs compositing can be abstracted as a renderer that can receive multiple tracks of input data
General Path of Data Acquisition

Capture Device(camera) --> Data Source(video tape i.e all streams multiplexed) --> player --->Destination(HDD or Output)

TIMING IS VERY IMPORTANT

WE use Time Class object which implements Clock having functions for basic Synchronising and presentation of streams. Clock derives it's timing from the Time-base(system clock) after using a prescaler.

To keep track of the current media time, a Clock uses:

• The time-base start time that it reports when thepresentation begins.
• The Media start-time—the position in the media stream where presentation begins.
• The Playback rate—how fast the Clock is running in relation to its TimeBase. The rate is a scale factor that is applied to the TimeBase.
Foexample, a rate of 1.0 represents the normal playback rate for the media stream, while a rate of 2.0 indicates that the presentation will run at twice the normal rate. A negative rate indicates that the Clock irunning in the opposite direction from its TimeBase—for example, a negative rate might be used to play a media stream backward.


The JMF API consists mainly of interfaces that define the behavior and interaction of objects used to capture, process, and present time-based media. Implementations of these interfaces operate within the structure of the framework. By using intermediary objects called managers, JMF makes it easy to integrate new implementations of key interfaces that can be used seamlessly with existing classes.

JMF uses four managers:
  • Manager—handles the construction of Players, Processors, DataSources, and DataSinks. This level of indirection allows new implementations to be integrated seamlessly with JMF.
  • PackageManager—maintains a registry of packages that contain JMF classes, such as custom Players, Processors, DataSources, and DataSinks.
  • CaptureDeviceManager—maintains a registry of available capture devices.
  • PlugInManager—maintains a registry of available JMF plug-in processing components, such as Multiplexers, Demultiplexers, Codecs, Effects, and Renderers.

HOW TO USE MANAGERS
To write programs based on JMF, you’ll need to use the Manager create methods to construct the Players, Processors, DataSources, and DataSinks for your application. If you’re capturing media data from an input device, you’ll use the CaptureDeviceManager to find out what devices are available and access information about them. If you’re interested in controlling what processing is performed on the data, you might also query the Plug-InManager to determine what plug-ins have been registered.

Event MODEL

  • Whenever a JMF object needs to report on the current conditions, it posts a MediaEvent.
  • MediaEvent is subclassed to identify many particular types of events. These objects follow the established Java Beans patterns for events.For each type of JMF object that can post MediaEvents, JMF defines a corresponding listener interface.addListner are used to handle posted MediaEvent.
Controller objects (such as Players and Processors) and certain Control objects such as GainControl post media events.RTPSessionManager objects post RTP EVENTS

SOME BASIC PLAYER CONTROLS

1. CachingControl - enables download progress to be monitored and dis-played. If a Player or Processor can report its download progress, it implements this interface so that a progress bar can be displayed to the user.

2. GainControl enables audio volume adjustments such as setting the level and muting the output of a Player or Processor. It also supports a listener mechanism for volume changes.

3. FramePositioningControl and FrameGrabbingControl - export frame-based capabilities for Players and Processors. FramePositioningControl enables precise frame positioning within a Player or Processor object’s media stream. FrameGrabbingControl provides a mechanism for grabbing a still video frame from the video stream. The FrameGrabbingControl can also be supported at the Renderer level.

Names of few frewuently used controls : BufferControl,PortControl,MonitorControl,FormatControl,TrackControlcontrol methods -getControlComponent returns awt default of a control componentPlayer methods - getVisualComponent,getCOntrolPanelComponent

BYE HAVE A GOOD DAY