Archive for October, 2008|Monthly archive page

How to change windows Logon & Logoff sound

goto control panel -> sounds and audio devices..
select sound tab from that dialogue box…
now select windows logon or logoff from program events and browse to set ur desire sound, the format of the file can only be wave.

Creating One Click Shutdown icon:

Right-click On the desktop, and go to New, then to Shortcut. You will now see a pop-up window instructing you to enter a command line path.
Just type:-
SHUTDOWN -s -t 01
click next & then give it any name.
Now if u want to shutdown your system just click it..
your system will get shutdown..

You can also make a timer for your system from this
for example u want that your system would get shutdown in 1 hour then create a shortcut and type:-
SHUTDOWN -s -t 3600
now if you click it. your system will get shutdown in 1 hour.
Remember the time is in seconds.

How To Display your Flash files in Html:-

The easiest way to embed Flash in a website, with a single embed code. Create a Flash File named file.swf locate it in the same directory as the HTML page.

Write the following code in the html.

<html>
<body>
<center>
<object width=”300″ height=”200″>
<param name=”movie” value=”file.swf”>
<embed src=”file.swf” width=”300″ height=”200″>
</embed>
</object
</center>
</body>
</html>

U Need to Have a Flash Plugin Installed if u want to see ur flash files. A broken icon will appear on the Web page if the u don’t have the Flash plug-in installed.

In the above code i have used both an <embed> tag and an <object> tag because the <object> tag is recognized by Internet Explorer, and Netscape recognizes the <embed> tag.

The other Parameters that you can use are:-

*  bgcolor (#rrggbb): set the SWF background color using a hexadecimal value.

*  flashvars (variables): the variables placed here will be loaded in the SWF.

*  The JW Player extensively uses those. menu (true, false): set this to false to hide most of the rightclick menu.

*  The allowscriptaccess and allowfullscreen parameters tell the browser the SWF can both communicate with external scripts (and link to external pages) and use the new fullscreen mode.

HOW TO UPLOAD & DOWNLOAD A FILE IN STRUTS FRAMEWORK

Hello friends as you know i’m kunal sachdeva rite now i’m also working on creating a website for jobs seeker & jobs provider using Struts framework which requires fileuploading & downloading of Resume, so here is the code for you which allows you to upload & download any type of file.

Before I Explain you the code, let me give u brief introduction of struts framework first:-

Struts is a free open-source framework for creating Servlet/JSP based web applications based on Model-View-Controller (MVC) architecture. The Model represents the business or database code, the View represents the page design code, and the Controller represents the navigational code. The Struts framework is designed to help developers create web applications that utilize a MVC architecture.

you can use any IDE to develop your struts application like NetBeans, Eclipse or Weblogic.

First of all create a jsp named FileUpload

<html:html>
<head>
<title>Struts File Upload</title>
<html:base/>
</head>
<body>
<html:form action=”/fileupload” method=”post” enctype=”multipart/form-data”>
<font size=”5″>File Upload on Server</font>
<font color=”red”><html:errors/></font>
File Name
<html:file property=”theFile”/>
<center>
<html:submit>Upload File</html:submit>
</center>
</html:form>
</body>
</html:html>

Now since we have used html tag library so you will have to add
taglib uri of html in case of Netbeans.

This jsp will have file type property from where u can browse the file on clicking submit the action fileupload will be called.

Now create a Bean package named beans & then create a class bean named StrutsUploadAndSaveForm which will extend ActionForm class

package beans;
import org.apache.struts.action.*;
import org.apache.struts.upload.FormFile;
public class StrutsUploadAndSaveForm extends ActionForm
{
private FormFile theFile;

public FormFile getTheFile() {
return theFile;
}

public void setTheFile(FormFile theFile) {
this.theFile = theFile;
}
}

in the above code getTheFile function Returns the File &
setTheFile function set the file whose parameters are passes.

Now create action package named action and create a action class named StrutsUploadAndSaveAction which extends Action class

package action;
import bean.StrutsUploadAndSaveForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import java.io.*;
public class StrutsUploadAndSaveAction extends Action
{
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request, HttpServletResponse response) throws Exception
{
StrutsUploadAndSaveForm myForm = (StrutsUploadAndSaveForm)form;
// Process the FormFile
FormFile myFile = myForm.getTheFile();
String contentType = myFile.getContentType();
//Get the file name
String fileName = myFile.getFileName();
byte[] fileData = myFile.getFileData();
//Get the servers upload directory real path name
String filePath = getServlet().getServletContext().getRealPath(“/”) +”upload”;
/* Save file on the server */
if(!fileName.equals(“”))
{
System.out.println(“Server path:” +filePath);
//Create file
File fileToCreate = new File(filePath, fileName);
//If file does not exists create file
if(!fileToCreate.exists())
{
FileOutputStream fileOutStream = new FileOutputStream(fileToCreate);
fileOutStream.write(myFile.getFileData());
fileOutStream.flush();
fileOutStream.close();
}

}
//Set file name to the request object
request.setAttribute(“fileName”,fileName);

return mapping.findForward(“success”);
}
}

/* This action class first takes the file which is set in the bean. then its actual path is stored in the variable filepath.
then if the filepath is not empty, a new file with same name is created inside realpath of servlet or jsp/upload
if the filepath is empty than fileOutStream is flushed.
& in the end name of the file is set in the request scope such that the same file can be downloaded latter.

Now enter the Code in Struts Config such that their is right mapping of the code.

<struts-config>
<form-beans>
<form-bean name=”FileUpload” type=”beans.StrutsUploadAndSaveForm”/>


</form-beans>

<action-mappings>

<action path=”/fileUpload” type=”action.StrutsUploadAndSaveAction” name=”FileUpload” scope=”request” validate=”true” input=”/FileUploadAndSave.jsp”>

<forward name=”success” path=”/downloadfile.jsp”/>

</action>

</action-mappings>

</struts-config>

Now create a jsp named downloadfile.jsp

<html>
<head>
<title>
Success</title>
</head>
<body>
<%
String fileName=(String)request.getAttribute(“fileName”);
%>

<p align=”center”><font size=”5″ color=”#000080″>File Successfully Received</font></p>
<p align=”center”><a href=”upload/<%=fileName%>”>Click here to download</a></p>
</body>

</html>

thank u all.
Any Queries & Doubts are welcomed.

Presentation of Skid Software @ India International Center Delhi

Today we had a presentation of Skid Software which is designed for the children suffering from Autism, such that they can Learn and Communicate Easily.

Major Part of the Presentation was given by Prof Arun Mehta. he explained people about Autism & how he got idea to prepare about this software & working of the skid software.

I also got chance to explain my Email Module & Text Editor.

It was a huge opportunity for me to explain my modules in front of 100 people which includes journalist from mint, Parents whose child are suffering from Autism and other Computer Experts.

I started my presentation by Telling them in brief about the Skid Software and then i Explained them that “Being Connected is the major Requirement of Today’s world”. Since the Children Suffering from Autism cannot use keyboard, so for them we have created the mail module such that the can send mail just by using Joystick or Racing wheels.

I also Explained them that this is the First Step in this Direction. No Existing Mail System like Gmail, Yahoomail etc. Provide this Facility which Autisic child can explore, so our mail module is unique in itself & it will surely help child to communicate & Learn.

Then we showed them the Live working of our module which is running at http://www.skid.org.in ( Emailaddr & Text Editor)

We also explained them that the since the child cannot remember the email-id of the persons to whom he want to send email so we had shown him the list of emailaddress to whom he can send mail.

The Response of Audience about our Skid Software was great, They were very keen to use our software.

We told them that the Skid Software is a open source software which is freely available on net people can download it using Subversion or they can use the software from site http://www.skid.org.in

Really It was Great Experience for me to be the part of the Presentation.

How to Send Mail with Action Mailer in Ruby on Rails

Action Mailer is the Rails component that enables applications to send and receive e-mail.

Create a New Project emails.

D:\ruby\> rails emails
this requires framework i suggest you to use Instant Rails 2.0 framework.
just by writting this command all controllers, views, models & helpers etc Automatically gets created.

Action Mailer – ConfigurationFollowing

Go into config folder of your emails project and open environment.rb file and add the following lines at the bottom of this file

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {:address => “kunal.rubypython.playground.net”,
:port => 25,
:domain => “rubypython.playground.net”,
:authentication => :login,
:user_name => “username”,
:password => “password”,
}

Remember you should have account on Ruby On Rails Server.
Replace each hash value with proper settings for your Simple Mail Transfer Protocol (SMTP) server. You don’t need to change port number 25 and authentication type if you are using standard SMTP server

Now the Next step is to create mailer

Generate a mailer
D:\ruby\> cd emails
D:\ruby\emails> ruby script/generate mailer Emailer

This will create a file emailer.rb in app\models directory.Check the content of this file is as follows
class Emailer < ActionMailer::Base
end
Create One Method as follows:-
class Emailer < ActionMailer::Base
def contact(recipient, subject, message, sent_at = Time.now)
@subject = subject
@recipients = recipient
@from = ‘no-reply@yourdomain.com’
@sent_on = sent_at
@body[“title”] = ‘This is title’
@body[“email”] = ‘sender@yourdomain.com’
@body[“message”] = message
end
end

The contact method has four parameters a recipient, subject, message and a sent_at, which defines when the e-mail is sent.
@subject defines the e-mail subject.
@body is a Ruby hash that contains values with which you can populate the mail template. You created three key-value pairs: title, email, and message
@recipients is a list of the people to whom the message is being sent.
@from defines who the e-mail is from.
@sent_on takes the sent_at parameter and sets the timestamp of the e-mail

Now we will create a mailer template which is just text with standard Rails <%= %> placeholders scattered throughout

Put following code in app/views/contact.html.erb
(if you are using Instant Rails 2.0 or more)

or put the following code in app/views/contact.rhtml (if you are using Instant Rails version 1.7)

<%= @message %>

Now we had to create a controller for this application as follows
D:\ruby\emails> ruby script/generate controller Emailer

class EmailerController < ApplicationController
def sendmail
email = @params[“email”]
recipient = email[“recipient”]
subject = email[“subject”]
message = email[“message”]
Emailer.deliver_contact(recipient, subject, message)
return if request.xhr?
render :text => ‘Message sent successfully’
end
end

To deliver e-mail using the mailer’s contact method, you have to add deliver_ to the beginning of the method name. You add a return if request.xhr? so that you can escape to Rails Java Script (RJS) if the browser does not support JavaScript and then tell the method to render a text message.

Now The Task Is Almost done Except for creating the view part for the user.

Now let’s define our view in app\views\emails\index.html.erb
<html>
<head><title>Send Mail</title></head>
<body>
<h1>Send Email</h1>
<% form_tag ({:action => “sendmail”},{ :method=>”post”}) do-%>
<p>
<label for=”email_subject”>Subject</label>:
<%= text_field ’email’, ‘subject’ %>
</p>
<p>
<label for=”email_recipient”>Recipient</label>:
<%= text_field ’email’, ‘recipient’ %>
</p> <p><label for=”email_message”>Message</label><br/>
<%= text_area ’email’, ‘message’ %></p>
<%= submit_tag “Send” %>
<% end-%></body>
</html>
This will send your message and will display text message that “Message sent successfully”
The modified version of this Application is working in www.skid.org.in/emailaddr

Queries Are Welcomed

Presentation of Skid Software tomorrow

Hello,

From Past 6 months i’m Learning Ruby.

& from past 3.5 months i’m working under the guidance of Prof. Arun  Mehta, Managing Director Indata Pvt. Ltd.

The Skid software http://www.skid.org.in was started by prof. Arun Mehta.

Skid software is designed to help kids communicate and learn. Children who cannot speak properly, including many with cerebral palsy and autism, are denied access to a regular school, even though they could communicate in other ways, for instance using a computer. It is such other ways, that Skid explores

Somehow I got Chance to work with Arun Mehta sir in my Summer Training,

Their was a List of 5 to 6 Modules to be completed in that Summer Training.

I Decided to took the most challenging Mail Module latter joined by two more students.

so we group of three students had to complete this module.

Mail Module had to be designed in such a manner that child can send mail just by using 4 arrow keys or racing wheel.

This type of a project was a first step in that direction such that Child suffering from autism can send mail easily.

& Now Today We Have almost Completed this Mail Module by two ways

using Action Mailer in Ruby on Rails that is now running on site http://www.skid.org.in and second by using Outlook Express that will run on Client Machine because Action Mailer requires server and client machine cannot have server installed in their machine.

We are still working with Arun Sir Even our summer training was over in August.

We have also deveoped a module Text Editor which allows child to edit the text who can use keyboard little bittle this module is also available in the site.

We are still unable to add pictures to our mail module such that person suffering from Autism wouldn’t have to remember the email-id of the person to whom he want to send the mail, such that he can just select pictures and the mail would be send to that person, hope we would be able to this soon.

We are still working on the client part of the software.

u can go and try the software on http://www.skid.org.in and apart from this module there is wikipedia , Picture Editor, font module & nimb game etc .

I Would like to thank god & My parents who are supporting and encouraging me to create these modules.

I would also like to thank Prof Arun Mehta for giving me a chance and making me part of this noble mission to help these Autisic Children and helping us while creating these modules.

Btw tomorrow we are having a presentation of this skid software 6.30 P.M @ India International Center Lodhi Road.