The pics we take with a digital camera are usually around 1.5-3 MB based on the resolution. I often waste time and bandwidth to upload such big images in websites like snapfish, orkut, facebook, flickr. I always wanted a simple utility that could be used to compress images in a folder. I wrote one software during my BE but did not carry it with me to US so I always had to use some Paint.NET or other Image Processing tools.
I started my new year coding with Image Processing tool - trueBuddi Image Compressor.
I would upload it on my website. It is very easy to use and is available
here
It requires .NET Framework 2.0 to run. Right now it compresses images within a specified folder and that too only those with .JPG extension.
Future revisions:
1. Individual File Compression
2. Image Processing Operations - Contrast enhancement, Brightness, Noise Reduction, Sharpening, etc.
3. Support for conversion among JPG, TIFF, PNG and other such types.
Ideas welcome. The tool is free to use and is not restricted with any kind of license. You can do a Reflector and anything that you want. Just do not change the title of the Frame.
Friday, December 28, 2007
Upcoming Screencasts
UPDATE: In case I am the Tutor for Java Programming, I would record these screencasts when I am teaching my students, otherwise this project is almost shelved until February!
I plan to release my screencasts on the following topics.
1. Object Oriented Programming in Java
2. Design Patterns in Java
3. Java EE Development
Disclaimer: I am not a guru in any of the above mentioned topics but I love programming and these are for my friends who are the only few visitors to my blog. So if there are any mistakes by me, please bring it to my notice so that I will learn better and I am not responsible for what so ever happens because of these screencasts.
Originally, I wanted to host my screencasts on truebuddi.wikidot.com but it does not allow me to attach video uploads. I am looking for Google Jotspot and I hope it would allow me to post videos. In the worst case, you would have to download the files from the link I give.
If you have more suggestions, let me know.
For now, here is one video that I would upload TurboGears-Getting started.
I plan to release my screencasts on the following topics.
1. Object Oriented Programming in Java
2. Design Patterns in Java
3. Java EE Development
Disclaimer: I am not a guru in any of the above mentioned topics but I love programming and these are for my friends who are the only few visitors to my blog. So if there are any mistakes by me, please bring it to my notice so that I will learn better and I am not responsible for what so ever happens because of these screencasts.
Originally, I wanted to host my screencasts on truebuddi.wikidot.com but it does not allow me to attach video uploads. I am looking for Google Jotspot and I hope it would allow me to post videos. In the worst case, you would have to download the files from the link I give.
If you have more suggestions, let me know.
For now, here is one video that I would upload TurboGears-Getting started.
Free Screen Recording Tools
I have been searching a lot for free Camtasia alternatives that would allow me to prepare screencasts. Till date I have found three good tools
1. Free Screen Recorder
http://www.nbxsoft.com/screen-recorder.php
Pretty decent tool, allows you to save screencast as AVI files. Best option is to download Vista Codec Package from http://www.free-codecs.com/download/Vista_Codec_Package.htm and in the settings choose XVID compression with as least quality as you want. You can record voice too.
2. DebugMode Wink
http://www.debugmode.com/wink/
A much more complicated software, allows you to store captures as SWF files. Lots of options but little bit uneasy to use.
3. CamStudio
http://camstudio.org/
Free and open source. But resource intensive. Good for high end systems.
Another good tool is ZoomIt by SysInternals. It helps you zoom particular portion of screen, would be useful when u want to show something more clearly, during presentations or screencasts. Free download from
http://technet.microsoft.com/en-us/sysinternals/bb897434.aspx
More on sysinternals tools, you get awesome little tools at http://technet.microsoft.com/en-us/sysinternals/0e18b180-9b7a-4c49-8120-c47c5a693683.aspx and they are all free. Amazing tools, trust me.
1. Free Screen Recorder
http://www.nbxsoft.com/screen-recorder.php
Pretty decent tool, allows you to save screencast as AVI files. Best option is to download Vista Codec Package from http://www.free-codecs.com/download/Vista_Codec_Package.htm and in the settings choose XVID compression with as least quality as you want. You can record voice too.
2. DebugMode Wink
http://www.debugmode.com/wink/
A much more complicated software, allows you to store captures as SWF files. Lots of options but little bit uneasy to use.
3. CamStudio
http://camstudio.org/
Free and open source. But resource intensive. Good for high end systems.
Another good tool is ZoomIt by SysInternals. It helps you zoom particular portion of screen, would be useful when u want to show something more clearly, during presentations or screencasts. Free download from
http://technet.microsoft.com/en-us/sysinternals/bb897434.aspx
More on sysinternals tools, you get awesome little tools at http://technet.microsoft.com/en-us/sysinternals/0e18b180-9b7a-4c49-8120-c47c5a693683.aspx and they are all free. Amazing tools, trust me.
Saturday, December 08, 2007
What next?
The semester is almost over. Two more exams and I will be done with the Fall 2008 semester at UGA. Looking back, one question that every student should probably ask himself is "Was I a good student?" By that I just mean what did I learn this semester? Well, I should say it was not the most inspiring semester I had in my student life, but definitely one of the hectic semester. I did learn a lot about simulation, especially parallel, distributed simulation, worked on my thesis to a great extent, participated in international capture the flag competition, attended an unsuccessful interview, realized that I am good but not good enough to become one of the best developers for a company. I developed a bad game, developed a great soccer simulator, developed a good library that can be used to develop P2P-ized applications, worked a lot on web crawling, evaluated a lot of "browser" frameworks, worked on SWT, worked on Silverlight, worked on VS 2008 Beta 2, taught a thing or two to my friends about .NET, read a lot about web security, read a lot of papers on simulation. Keeping all this in view I should say that it has been a very eventful semester. Things have been pretty bad on the personal front, but I guess thats the way I become more strong and better.
I really am looking forward for the next year. I hope it would be a totally different year and I hope it would be the way I want it to be. As a new year resolution, I plan to quit smoking right from the 31st. I know it is bad and I should not smoke.
Coming to the technical front, I have few holidays coming this month and I hope to work on the following.
You should see this presentation and would know why I chose these...
http://static.raibledesigns.com/repository/presentations/ComparingJavaWebFrameworks.pdf
1. Java Server Faces
2. Struts 2
3. Spring
4. Tapestry
5. Wicket, Stripes
6. Tiles, SiteMesh
I feel my resume is more of .NET and I really am not that bad at Java and neither am I that good at .NET. I really was good at .NET till 1.1 I used to know quite a lot of 1.1, be it asynchronous calls or anything else that complex, I was good at it. But not any more. .NET is now an ocean and my knowledge is really now very little. But the job front on Java Web looks more promising and it would probably add more value to my resume if i can develop applications on both JAva and .NET platforms. Let me see where my learning would go!
I really am looking forward for the next year. I hope it would be a totally different year and I hope it would be the way I want it to be. As a new year resolution, I plan to quit smoking right from the 31st. I know it is bad and I should not smoke.
Coming to the technical front, I have few holidays coming this month and I hope to work on the following.
You should see this presentation and would know why I chose these...
http://static.raibledesigns.com/repository/presentations/ComparingJavaWebFrameworks.pdf
1. Java Server Faces
2. Struts 2
3. Spring
4. Tapestry
5. Wicket, Stripes
6. Tiles, SiteMesh
I feel my resume is more of .NET and I really am not that bad at Java and neither am I that good at .NET. I really was good at .NET till 1.1 I used to know quite a lot of 1.1, be it asynchronous calls or anything else that complex, I was good at it. But not any more. .NET is now an ocean and my knowledge is really now very little. But the job front on Java Web looks more promising and it would probably add more value to my resume if i can develop applications on both JAva and .NET platforms. Let me see where my learning would go!
Wednesday, November 28, 2007
Code to worry!
In this post, I intend to post something that we discussed in our Advanced Computer Network and Security.
1. fork() - too many forks could halt the system, if the malicious code has enough privileges to launch that many forks. This is probably not a great problem to worry about but could be given a thought!
2. The talk was interesting. We were shown a simple echo server code that when run and well exploited can give you a shell to own! Through which you can list files and do everything that you can do from a Bash shell. So what did the program have?
The problem was that the array size was fixed and then the exploit was to copy large buffer onto a smaller buffer causing a buffer overflow attack. The exploit data has to be carefully crafted. Anyway, StackGuard is a simple fix that works for most of the buffer overflows. The other fix is to have a pointer declared in the first line of the function and save its current reference and at every exit, you are going to check if the saved value did not change. I know this does not make sense unless you see the code, but unfortunately I do not have that. The overall summary is to say that when you copy buffers, you should be careful to see that the copy is going to be safe. Few commands that i came to know. You have a port x open and then see what service uses that, you could do a
/usr/sbin/lsof | grep x
3. Using netstat to check the open ports
netstat -lt
Anyway class over so more on this later,hopefully.
1. fork() - too many forks could halt the system, if the malicious code has enough privileges to launch that many forks. This is probably not a great problem to worry about but could be given a thought!
2. The talk was interesting. We were shown a simple echo server code that when run and well exploited can give you a shell to own! Through which you can list files and do everything that you can do from a Bash shell. So what did the program have?
The problem was that the array size was fixed and then the exploit was to copy large buffer onto a smaller buffer causing a buffer overflow attack. The exploit data has to be carefully crafted. Anyway, StackGuard is a simple fix that works for most of the buffer overflows. The other fix is to have a pointer declared in the first line of the function and save its current reference and at every exit, you are going to check if the saved value did not change. I know this does not make sense unless you see the code, but unfortunately I do not have that. The overall summary is to say that when you copy buffers, you should be careful to see that the copy is going to be safe. Few commands that i came to know. You have a port x open and then see what service uses that, you could do a
/usr/sbin/lsof | grep x
3. Using netstat to check the open ports
netstat -lt
Anyway class over so more on this later,hopefully.
Wednesday, November 07, 2007
Java Game Programming using JGame
I came across this wonderful 2D Game Engine called JGame. This is a very good engine to write simple games and with just 100 odd lines of code, you can write wonderful games! I would post a series of tutorials shortly, but meanwhile it is a good point to start
http://www.13thmonkey.org/~boris/jgame/JGame/tutorial/
Great work Boris Van Schooten!! Really amazing!
http://www.13thmonkey.org/~boris/jgame/JGame/tutorial/
Great work Boris Van Schooten!! Really amazing!
Sunday, November 04, 2007
Getting Started with OpenSocial API
On Thursday, Google announced their new API called the OpenSocial which can be used by developers to develop Google Gadgets like applications for their favorite Social Networking websites like the Orkut, Hi5 and a lot more. More information about this could be found at:
http://code.google.com/apis/opensocial/partners.html
One could take it a new revolution, a combined war against the most popular social website - the Facebook. Around 14 social networking websites have partnered Google with their Social API.
Coming to the development of such Gadgets for Orkut like websites, you are required to have a basic but fundamental understanding of developing Google Gadgets. You are required to know Html, JavaScript and XML. I have just followed the Google's sample application and one thing that puts off Google to a lower standard is the way they document their API. Compare Microsoft and Google, I bet Microsoft's documentation is by far the best that is available on the internet. The Google documentation, I think is more above standard. I think the technical writers team consider the audience to be as talented as those who work at Google but unfortunately we are not! right?
I always think a hello world application should be very basic and should include everything that one needs to know. The tutorial at http://code.google.com/apis/opensocial/articles/firstgadget.html assumes that you have basic understanding of Google Gadgets and not about OpenSocial API. It does a great job to explain how to proceed with development of OpenSocial Applications but then it does not tell you how to add that gadget you developed to your Orkut account and so forth.
Well this is what I did!
1. Go to http://code.google.com/apis/gadgets/docs/gs.html#GGE
2. Go to File->New and Select Hello World Gadget. You get the basic code for Hello World gadget
3. Copy and paste the following code into the editor you see in the following link.
http://hosting.gmodules.com/ig/gadgets/file/104220043972318336267/buddiKut.xml
I apologize for not being able to show the code here. But it is my fault and I am lazy not to work around pasting HTML code in the blogger. The best thing you could do is paste the xml you see in some XML editor or refer to the actual source (firstgadget.html)
4. Now click on File->Save and give it a name. Once the file is saved, on the top right corner of the editor you get a Hyperlink with the filename you just gave. Right click on the link and copy the link to your gadget.
5. Now assuming that you have signed up for SandBox Orkut account ( you need to do that by going here http://code.google.com/support/opensocialsignup and you should already have an orkut account) sign into your orkut account with this link 'http://sandbox.orkut.com'
6. Then you see a "applications" menu item just where you see lists,testimonials and other such items ( left side of the page) (as shown in the figure)
7. Now click on that applications link and you see a page with a textbox asking for application URL. Paste the copied URL on to the textbox and click on "Add Application".
6. Once you add the gadget, you see a People API How too item added to your menu just above the applications (See figure). Click on that and you would be taken to a new applications page and you can see your application in Action!!!
Isn't it great?? You have complete access to your friends data and a lot more programatically and imagine all the possible applications that you could develop!
I hope we will be given a profile KEY which is unique for a profile and which can be used within the application and make the Gadget run outside these social networking websites!!! That would be very great ! There might be a better tutorial by someone with more knowledge about this but just that I wanted to be one of the early adopters! Who knows whats waiting for one!
Sunday, October 28, 2007
Project P2P Library
A good library for developing Peer-To-Peer applications is being developed by me and a friend. The aim is to enable ease of development of a Peer to Peer System. For now, you can write a peer as
public class MyOwnPeer extends Peer
{
//implement few methods!
}
The peers identify each other through IP Multicasting. In a day or two, I hope to write a short tutorial on how to develop a P2P chat application using our library. For now, it runs within private networks only. And does not run across internet!
Also the library at its current stage enables very easy development of Server application! you can write your echo server without having to worry about threading or anything else!
It is as simple as
public class EchoServer extends ServerComponent
{
//implement few methods!
}
We hope to release the library as early as possible.
The echo server sample is shown below!
Isnt' that easy! This is just the very initial stages of development and hopefully the library grows to something really big. The library relies heavily on Object-Oriented Concepts !
// SAMPLE SERVER CODE!!
class EchoServer extends ServerComponent {
public EchoServer(int port) {
super(port);
}
@Override
public void beforeServerStarts() {
System.out.println("Server about to start");
}
@Override
public void onIncomingConnection(Socket socket) {
try {
BufferedReader buff = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
PrintWriter pw = new PrintWriter(socket.getOutputStream());
String temp = "";
while ((temp = buff.readLine()) != null) {
pw.println(temp);
pw.flush();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void onServerStarted() {
System.out.println("Server Started!");
}
public static void main(String[] args) {
EchoServer my = new EchoServer(1233);
}
}
public class MyOwnPeer extends Peer
{
//implement few methods!
}
The peers identify each other through IP Multicasting. In a day or two, I hope to write a short tutorial on how to develop a P2P chat application using our library. For now, it runs within private networks only. And does not run across internet!
Also the library at its current stage enables very easy development of Server application! you can write your echo server without having to worry about threading or anything else!
It is as simple as
public class EchoServer extends ServerComponent
{
//implement few methods!
}
We hope to release the library as early as possible.
The echo server sample is shown below!
Isnt' that easy! This is just the very initial stages of development and hopefully the library grows to something really big. The library relies heavily on Object-Oriented Concepts !
// SAMPLE SERVER CODE!!
class EchoServer extends ServerComponent {
public EchoServer(int port) {
super(port);
}
@Override
public void beforeServerStarts() {
System.out.println("Server about to start");
}
@Override
public void onIncomingConnection(Socket socket) {
try {
BufferedReader buff = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
PrintWriter pw = new PrintWriter(socket.getOutputStream());
String temp = "";
while ((temp = buff.readLine()) != null) {
pw.println(temp);
pw.flush();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void onServerStarted() {
System.out.println("Server Started!");
}
public static void main(String[] args) {
EchoServer my = new EchoServer(1233);
}
}
Saturday, October 27, 2007
Good .NET Reflector
Download this good tool called "lutz roeder's .net reflector" from the link below
http://www.aisto.com/roeder/dotnet/
Using this one could load a .NET assembly and decompile it to see the source code and do something more. I saw this tool being used in one of the C#3.0 Nuggets (I think it was in Object Initializers video). This could be used to understand how compiler takes in our source code and modifies it well!
I knew unused variables in your source code would not be included but it was something really fun to check it out.
I gave two unused variables and a used variable and when I decompiled the code, I found the two unused variables not mentioned at all! there is the proof!
http://www.aisto.com/roeder/dotnet/
Using this one could load a .NET assembly and decompile it to see the source code and do something more. I saw this tool being used in one of the C#3.0 Nuggets (I think it was in Object Initializers video). This could be used to understand how compiler takes in our source code and modifies it well!
I knew unused variables in your source code would not be included but it was something really fun to check it out.
I gave two unused variables and a used variable and when I decompiled the code, I found the two unused variables not mentioned at all! there is the proof!
C# 3.0 - Changes ! Learn them Quick!
Thanks to Mike Taulty, famous for MSDN Nuggets, that I started to learn LINQ. Will post the exact link sometime later.
But these are the various LINQ techs coming up:
1. LINQ to SQL
2. LINQ to XML
3. LINQ to Entities
4. DLinq
5. BLinq
and much more.
Before that I would recommend to learn the new changes in C# 3.0. The nuggets could be found here
http://www.microsoft.com/uk/msdn/nuggets/tags/C%23%20Version%203.0/default.aspx?pg=1
I am yet to watch these videos and once done! I would post some hello world! kind of programs that can help people like me to learn easily. Most of these videos usually use a very complex kind of examples and sometimes it is good while sometimes it is not so good!
More later...
But these are the various LINQ techs coming up:
1. LINQ to SQL
2. LINQ to XML
3. LINQ to Entities
4. DLinq
5. BLinq
and much more.
Before that I would recommend to learn the new changes in C# 3.0. The nuggets could be found here
http://www.microsoft.com/uk/msdn/nuggets/tags/C%23%20Version%203.0/default.aspx?pg=1
I am yet to watch these videos and once done! I would post some hello world! kind of programs that can help people like me to learn easily. Most of these videos usually use a very complex kind of examples and sometimes it is good while sometimes it is not so good!
More later...
Saturday, October 20, 2007
CapGemini Second Round of Interview
I had my second round of interview at CapGemini TME Office at Atlanta. It was a great office, looking very much like my old office at Kanbay, but the difference being everyone had their own private cubicles unlike at Kanbay. The interviewer Mr. Micheal talked to me about the pros and cons of having a common space for everyone. Anyway coming to the interview aspects, it was everything about behavioral aspects of a consultant. I was kind of under-prepared for this kind of an interview and add to that the candidates whom I met during my wait time, most of them from GaTech! That kind of put me off to a defensive stand, come on everyone would be afraid to meet top notch engineers, consultants from a top-notch College. And it took me quite a long time to get into the "good" mode that is needed to do an interview well.
Well coming to the experiences part, I really think that it depends at least 50% on the interviewer that impacts your performance during an interview. The first round was not all that great, the interviewer had my resume, he had a list of questions, almost four pages long and I was all done in 20 mins! isn't that too long and it was kind of mechanical, routine nothing that exciting to make me talk a lot about my experiences. I think I did well on that. I was asked a series of questions and all of these were behavioral. They tested you as a team leader, as a motivator as a problem solver. They test your team leadership skills more than what they talk about your academics. questions like tell me a situation when you had too little time to a lot of things, tell me a time when you went through a lot of stress and how did you cope it. I think I did fairly well.
The second round was the one I liked the most. It was one of the best interviews I had and I have had interviews with almost 10 different people and it was a really great interview. Again, I was tested on the very same things - leadership, motivation skills, commitment, learning ability.
I think I did well. I am not sure if it is often the case, but this is the first time I have been walked out of the interview till the exit door by the interviewer himself and he appeared to be very impressed.
Irrespective of the result, I think I had a terrific experience of getting interviewed at CapGemini, especially my first round of interview with Spencer Lentz and the final interview with Micheal. Both were amazing people with great interviewing skills. I hope everyone of my friends would get such a great interviewers for their interview.
If anyone reading these posts need some light on CapGemini interviews please leave me a message at krishnabhargav@yahoo.com!
Well coming to the experiences part, I really think that it depends at least 50% on the interviewer that impacts your performance during an interview. The first round was not all that great, the interviewer had my resume, he had a list of questions, almost four pages long and I was all done in 20 mins! isn't that too long and it was kind of mechanical, routine nothing that exciting to make me talk a lot about my experiences. I think I did well on that. I was asked a series of questions and all of these were behavioral. They tested you as a team leader, as a motivator as a problem solver. They test your team leadership skills more than what they talk about your academics. questions like tell me a situation when you had too little time to a lot of things, tell me a time when you went through a lot of stress and how did you cope it. I think I did fairly well.
The second round was the one I liked the most. It was one of the best interviews I had and I have had interviews with almost 10 different people and it was a really great interview. Again, I was tested on the very same things - leadership, motivation skills, commitment, learning ability.
I think I did well. I am not sure if it is often the case, but this is the first time I have been walked out of the interview till the exit door by the interviewer himself and he appeared to be very impressed.
Irrespective of the result, I think I had a terrific experience of getting interviewed at CapGemini, especially my first round of interview with Spencer Lentz and the final interview with Micheal. Both were amazing people with great interviewing skills. I hope everyone of my friends would get such a great interviewers for their interview.
If anyone reading these posts need some light on CapGemini interviews please leave me a message at krishnabhargav@yahoo.com!
Monday, October 08, 2007
Interview with CapGemini
I have tried to search for some links which would give me some information on interviewing with CapGemini U.S but could not find any thing that was free. Well, I thought I would share some of my experiences. I had an interview with CapGemini today at UGA with a Senior Manager and I guess I cannot mention his name without his consent.
Anyway the interview was for "Staff Technical Consulting". It was more about conversational interview and we did not talk much about technical aspects. The interviewer, I guess was looking for more on the behavioral aspects of me, as a prospective consultant. The questions were more on the lines of "describe a situation where you motivated a team", "describe a situation where you had a lot of work to do and less time", etc.
I think I did a good job, I answered the questions and let us see if i can make it.
For those who would attend a similar interview, in case you need some more information feel free to mail me at krishnabhargav@yahoo.com
Anyway the interview was for "Staff Technical Consulting". It was more about conversational interview and we did not talk much about technical aspects. The interviewer, I guess was looking for more on the behavioral aspects of me, as a prospective consultant. The questions were more on the lines of "describe a situation where you motivated a team", "describe a situation where you had a lot of work to do and less time", etc.
I think I did a good job, I answered the questions and let us see if i can make it.
For those who would attend a similar interview, in case you need some more information feel free to mail me at krishnabhargav@yahoo.com
Project SoccerBots - Soccer Simulator in C#/.NET
I started the work to port Soccer Simulator which I wrote in Java on to .NET. I am using C# and making heavy use of User Controls to render efficient animation. So far, things are going on well and I hope in the next two weeks, I would be able to upload the project and release it as an Open Source Software at http://www.codeplex.com/soccersim
The basic idea is to simulate soccer game where two teams compete against each other. A user can write his own team and then make the Simulator play that team. In my Java version, which has some bugs and does not run that great, teams are written in Java. As an extension I am planning to support XML teams in my new simulator so that any one who loves games and who know little XML can use the software. I guess it would be more acceptable. The current simulator is inspired from both my original Java version as well as some ideas taken from the Ascii soccer developed by Prof. Tucker Balch and Dr. Maria Hybinette. The details are in this link
http://www.cs.uga.edu/~maria/classes/8220-Fall-2007/project1soccer.html
By the way I am in one of the pictures in that class website.
Dr. Tucker also has this TEAMBOTS which is a more advanced and a great Soccer Simulator written in Java. Though, I am not refering the code from that simulator, might be I would try it out to see if I can add a feature or two.
A friend of mine is helping me on this project and this would be released as a collective effort. The deadline is November 4th and before that we plan to release the SoccerBots 0.5 BETA!
The basic idea is to simulate soccer game where two teams compete against each other. A user can write his own team and then make the Simulator play that team. In my Java version, which has some bugs and does not run that great, teams are written in Java. As an extension I am planning to support XML teams in my new simulator so that any one who loves games and who know little XML can use the software. I guess it would be more acceptable. The current simulator is inspired from both my original Java version as well as some ideas taken from the Ascii soccer developed by Prof. Tucker Balch and Dr. Maria Hybinette. The details are in this link
http://www.cs.uga.edu/~maria/classes/8220-Fall-2007/project1soccer.html
By the way I am in one of the pictures in that class website.
Dr. Tucker also has this TEAMBOTS which is a more advanced and a great Soccer Simulator written in Java. Though, I am not refering the code from that simulator, might be I would try it out to see if I can add a feature or two.
A friend of mine is helping me on this project and this would be released as a collective effort. The deadline is November 4th and before that we plan to release the SoccerBots 0.5 BETA!
Wednesday, September 19, 2007
Send Keys in Java or automate repetitive tasks programmatically.
If you have ever programmed in VB, you will definitely know what SendKeys are. You can use send keys function in vb to send in keystrokes to other applications, to be specific to that application which has focus. You can do similar work in Java.
You have send keys like functionality in java.awt.Robot class. You can instantiate a Robot class and then use methods like keyPress(KeyEvent.ENTER), keyRelease, mouseMove, mouseClick, etc.
This is very useful. Like I mentioned in the previous posts, I am running certain tests using Browser Widget. And I am not always infront of the system. And I do get a lot of dialog pop-ups which require a user to manually click OK. I mentioned about wmctrl in the previous posts but I did not get to send keys from wmctrl, so here is what I did.
I used wmctrl to get a list of open windows and specifying -x option to wmctrl would give you even the WM_CLASS and based on this, I use -a option to bring the particular window on top. Then once when the window is on top, I use Robot class to send keys.
There are other good tools like Expect scripts, Devilspie which can automate tasks but I did not have enough time to learn them from scratch. EXPECT is more prominent out there but Devilspie too looked promising.
You have send keys like functionality in java.awt.Robot class. You can instantiate a Robot class and then use methods like keyPress(KeyEvent.ENTER), keyRelease, mouseMove, mouseClick, etc.
This is very useful. Like I mentioned in the previous posts, I am running certain tests using Browser Widget. And I am not always infront of the system. And I do get a lot of dialog pop-ups which require a user to manually click OK. I mentioned about wmctrl in the previous posts but I did not get to send keys from wmctrl, so here is what I did.
I used wmctrl to get a list of open windows and specifying -x option to wmctrl would give you even the WM_CLASS and based on this, I use -a option to bring the particular window on top. Then once when the window is on top, I use Robot class to send keys.
There are other good tools like Expect scripts, Devilspie which can automate tasks but I did not have enough time to learn them from scratch. EXPECT is more prominent out there but Devilspie too looked promising.
Saturday, September 15, 2007
Configuring SWT Browser Widget Preferences!
This technique I discovered works on Linux, ie. when SWT Browser uses Mozilla as its underlying browser. It uses JavaXPCOM to connect with Mozilla and does great job doing so. But then the Browser class do not have any options to configure the preferences of the browser. But you can still configure the preferences of the browser!!
Mozilla preferences are stored in a .mozilla directory for each user, in their home directory. Thanks to Dr. Li, that I could find this out. Now if you run a program that uses SWT Browser, you can see a a folder "Eclipse" inside this .mozilla directory.
[Note I am talking about running a Java Program which has SWT Browser, from ECLIPSE, thus the folder name is eclipse. If you run from console, you might have a different foldername(I guess as that of the program name)]
It is in the /home//.mozilla/eclipse directory that the SWT Browser used Mozilla preferences are stored. It is stored in the prefs.js javascript file. You can specify a user prefernces by using user_pref() function. For example, you want a network boosted SWT Browser widget, then may be you can add the following line to prefs.js
user_pref("networking.http.pipelining",true);
Close Eclipse and start again. Now when you launch the program, the browser would use this preference.
Another way is to use "about:config" within your program do the configuration!
For this you can just write a configure() function and use it when you want. The function can be something like
Class ConfigurationWindow
{
public void configure()
{
Display display = new Display();
Shell shell = new Shell(display);
Browser browser = new Browser(shell,SWT.CENTER);
shell.setLayout(new GridLayout());
browser.setUrl("about:config");
shell.open();
while(!shell.isDisposed())
if(!display.readAndDispatch()) display.sleep();
shell.dispose();
display.dispose();
browser.dispose();
}
}
Now you can create new instance of ConfigurationWindow and call configure() which shows the user preferences window, just like the one you get when you type about:config in Mozilla Firefox.
This way one can configure preferences for Swt Browser Widget!
Mozilla preferences are stored in a .mozilla directory for each user, in their home directory. Thanks to Dr. Li, that I could find this out. Now if you run a program that uses SWT Browser, you can see a a folder "Eclipse" inside this .mozilla directory.
[Note I am talking about running a Java Program which has SWT Browser, from ECLIPSE, thus the folder name is eclipse. If you run from console, you might have a different foldername(I guess as that of the program name)]
It is in the /home/
user_pref("networking.http.pipelining",true);
Close Eclipse and start again. Now when you launch the program, the browser would use this preference.
Another way is to use "about:config" within your program do the configuration!
For this you can just write a configure() function and use it when you want. The function can be something like
Class ConfigurationWindow
{
public void configure()
{
Display display = new Display();
Shell shell = new Shell(display);
Browser browser = new Browser(shell,SWT.CENTER);
shell.setLayout(new GridLayout());
browser.setUrl("about:config");
shell.open();
while(!shell.isDisposed())
if(!display.readAndDispatch()) display.sleep();
shell.dispose();
display.dispose();
browser.dispose();
}
}
Now you can create new instance of ConfigurationWindow and call configure() which shows the user preferences window, just like the one you get when you type about:config in Mozilla Firefox.
This way one can configure preferences for Swt Browser Widget!
Linux Window Management - When you are away from the PC
Like I mentioned in the previous posts, I have this requirement where I run tests using SWT Browser Widget on thousands of URLs. And I am start the test and leave the lab. But then for some URL, the SWT Browser just pops up a dialog either asking for password or warning about a bad certificate. This has been my biggest problem off late and has delayed my tests because unless you close the dialogs the program, the execution cannot move forward.(Like the one shown in the image)
I tried out various options like configuring the settings of Mozilla which is used by SWT Browser when the widget runs on Linux (It uses IE when is running on Windows). But this hasnt worked out.
Then I thought, in Linux if a window is created, there is some way that we can be notified about this. Like some kind of GNOME or a X window Events. So initially I thought I would write some program in C to capture these global events and then for those windows I want, I would close them as I get notified. But then unlike getting this idea, implementing it is not that simple. Even now I have no clue if I ever want to write such a program, then what should I start.
Anyways I browsed for a long time and found out about this wonderful new tool called "wmctrl" which does exactly what I want. With wmctrl I can get a list of open windows, their X Window ID, their title, their process IDs. And not only that we can manage a specific window using its ID or title and this includes opening, closing, resize, move, change title, etc. Isnt that great?
You can download it from "http://www.sweb.cz/tripie/utils/wmctrl/". Just install the tool on your machine using ./configure, make, make install and you are good to go.
Getting a list of open windows on Linux
In the command line, type in wmctrl -l to get a list of all open windows and their information. Example shown in the image.
The other options are also shown. You can close a window by passing its ID (-i option) and a -c option.
You can close a window by just passing the title along with -c option.
But then the next problem is how am I going to execute this from a Java Program!
Executing Linux Commands from Java Program
You can run a Unix command from a Java Program, as shown below
try {
Process p = Runtime.getRuntime().exec("wmctrl -l -p");
int i = p.waitFor(); // very important. You wait for the command to be executed.
// i would be the return value of the process you are running.
if(i==0) //if successfully terminated
{
BufferedReader buff = new BufferedReader(new InputStreamReader(p.getInputStream()));
String temp;
while((temp=buff.readLine())!=null)
{
System.out.println(temp);
}
}
else //wmctrl returns 1 if no options passed
System.out.println("error : "+i);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
The above program executes wmctrl and displays the listing on the console. Isn't Java interesting to work and great?
I am just left with implementing this idea on my lab test machine and collect great results!!!!
Friday, September 14, 2007
BUG in SWT Browser Widget
I have just discovered a bug in SWT Browser Widget which is used by Eclipse for its internal browser. Just type in http://www.friendster.com/ anyway inside eclipse (some editor inside eclipse). Hold CTRL and click on that link to open Eclipse internal browser. As the page is about to finish loading, Eclipse closes!!
The version I am using is SWT 3.3, the latest, so called stable release.
No idea as of now why this is happening. I guess there is some component inside friendster.com homepage that SWT Browser widget does not like much, and infact it is a VM error!
By the way I am running Fedora Core 7.
The version I am using is SWT 3.3, the latest, so called stable release.
No idea as of now why this is happening. I guess there is some component inside friendster.com homepage that SWT Browser widget does not like much, and infact it is a VM error!
By the way I am running Fedora Core 7.
Thursday, September 13, 2007
Small Read from file, write to file utility
A Java Class that I wrote for my own use. Just to have ease of access.....
--------------------------------------------------------------------------------------------------
package buddi.thesis;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
public class DataStore {
private PrintWriter writer=null;
private BufferedReader reader=null;
public DataStore(String input, String output)
{
try {
reader = new BufferedReader(new FileReader(input));
writer = new PrintWriter(new File(output));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public String getNextItem()
{
if(reader==null)
return null;
String temp;
try {
temp = reader.readLine();
if(temp!=null)
return temp;
} catch (IOException e) { }
return null;
}
public void writeToOutput(String text)
{
if(writer==null)
{
System.out.println("ERROR : COULD NOT WRITE TO OUTPUT!");
return;
}
writer.println(text);
writer.flush();
}
public void close()
{
try {
reader.close();
writer.close();
reader=null;
writer=null;
} catch (IOException e) {
}
}
}
--------------------------------------------------------------------------------------------------
package buddi.thesis;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
public class DataStore {
private PrintWriter writer=null;
private BufferedReader reader=null;
public DataStore(String input, String output)
{
try {
reader = new BufferedReader(new FileReader(input));
writer = new PrintWriter(new File(output));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public String getNextItem()
{
if(reader==null)
return null;
String temp;
try {
temp = reader.readLine();
if(temp!=null)
return temp;
} catch (IOException e) { }
return null;
}
public void writeToOutput(String text)
{
if(writer==null)
{
System.out.println("ERROR : COULD NOT WRITE TO OUTPUT!");
return;
}
writer.println(text);
writer.flush();
}
public void close()
{
try {
reader.close();
writer.close();
reader=null;
writer=null;
} catch (IOException e) {
}
}
}
Wednesday, September 12, 2007
Java Program to detect Server side redirections!
As a part of my research work, I wrote this small function in Java which gives you HTTP Response Code and with which we can actually detect server side redirects. The server side redirects have a response code as 302. Well here is the program,
public class NetworkTool {
public static int getResponseCode(String url) {
try {
URL urlItem = new URL(url);
HttpURLConnection con = (HttpURLConnection) urlItem.openConnection();
con.setReadTimeout(1000);
con.setConnectTimeout(5000);
//System.out.println(con.getConnectTimeout());
con.setInstanceFollowRedirects(false);
int res = con.getResponseCode();
return res;
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
catch(Exception ex){//System.out.println("hehe");
}
return -1;
}
public static void main(String[] args)
{
System.out.println(getResponseCode("http://cs.uga.edu/index.htmx"));
System.out.println(getResponseCode("http://buddibuddibuddi.com"));
System.out.println(getResponseCode("http://128.192.1.21"));
}
}
The statements highlighted in bold are important. Otherwise, there are some url for which you get connected to the server but you keep waiting for infinite time for the data to come on the connection. So if we set time-out on read, we don't wait for long and this is especially helpful when you run the tests on huge data.
It took me quite a long time to get the actual code fixed, and then to find out the two statements. So I hope this post would be useful for others too.
public class NetworkTool {
public static int getResponseCode(String url) {
try {
URL urlItem = new URL(url);
HttpURLConnection con = (HttpURLConnection) urlItem.openConnection();
con.setReadTimeout(1000);
con.setConnectTimeout(5000);
//System.out.println(con.getConnectTimeout());
con.setInstanceFollowRedirects(false);
int res = con.getResponseCode();
return res;
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
catch(Exception ex){//System.out.println("hehe");
}
return -1;
}
public static void main(String[] args)
{
System.out.println(getResponseCode("http://cs.uga.edu/index.htmx"));
System.out.println(getResponseCode("http://buddibuddibuddi.com"));
System.out.println(getResponseCode("http://128.192.1.21"));
}
}
The statements highlighted in bold are important. Otherwise, there are some url for which you get connected to the server but you keep waiting for infinite time for the data to come on the connection. So if we set time-out on read, we don't wait for long and this is especially helpful when you run the tests on huge data.
It took me quite a long time to get the actual code fixed, and then to find out the two statements. So I hope this post would be useful for others too.
Tuesday, September 11, 2007
Some interesting figures...
I was wondering how many elements of a type can you store in a
1. HashMap
2. Vector
3. ArrayList
4. Stack
and other Collections.
This is what i found. With the default Heap space intact,
ArrayList can store 33,07,499 Long or Integers and around 1222441 Strings(I am not sure how long)
Stack and Vector, including HashMap can store upto 1236653 Strings. While around 26,21,441 integral types could be stored.
I am not sure if this is same across all machines. Well this atleast gives me an idea to what extent i can go without facing OutOfMemoryError.
1. HashMap
2. Vector
3. ArrayList
4. Stack
and other Collections.
This is what i found. With the default Heap space intact,
ArrayList can store 33,07,499 Long or Integers and around 1222441 Strings(I am not sure how long)
Stack and Vector, including HashMap
I am not sure if this is same across all machines. Well this atleast gives me an idea to what extent i can go without facing OutOfMemoryError.
How do you construct absolute URL for links in the web page?
Suppose you crawl a page at http://cs.uga.edu/~krishna and one of the HREF links to contact.html, then how do you get the absolute URL for the contact.html ? We can say simply concatenate the original HREF to contact.html, but then it is not that simple. There might be cases where the href was "../../../../contact.html", we need to take into account those cases too. So the simplest way that I found was to use URL class in the java.net package. And the following code does the trick for us.
URL start = new URL("http://cs.uga.edu/~krishna");
URL newUrl = new URL(start,"contact.html"); //construct the absolute URL
Thats the way you construct absolute URL. Very simple, isn't it?
URL start = new URL("http://cs.uga.edu/~krishna");
URL newUrl = new URL(start,"contact.html"); //construct the absolute URL
Thats the way you construct absolute URL. Very simple, isn't it?
Thursday, September 06, 2007
File URIs
URI - Uniform Resource Identifier
A URI for a web resource might be http://krishnabhargav.blogspot.com
Most of the api might require you to specify URI for local files instead of having a local path. Suppose you want to pass a local system file as a parameter and it should be in the form of an URI then you can do this:
Let us say the file is D:/Development/MyResource.txt
Then the fileUri would be something like
file:///D:/Development/MyResource.txt
One most common mistake is to use file:// instead of file:///. We go by the notion that http has "//" and so does ftp. So even this "file" would have "//" in its Uri. But it is "///" instead of "//".
One good and more detailed explanation is given here.
http://blogs.msdn.com/ie/archive/2006/12/06/file-uris-in-windows.aspx
I really appreciate his post.
A URI for a web resource might be http://krishnabhargav.blogspot.com
Most of the api might require you to specify URI for local files instead of having a local path. Suppose you want to pass a local system file as a parameter and it should be in the form of an URI then you can do this:
Let us say the file is D:/Development/MyResource.txt
Then the fileUri would be something like
file:///D:/Development/MyResource.txt
One most common mistake is to use file:// instead of file:///. We go by the notion that http has "//" and so does ftp. So even this "file" would have "//" in its Uri. But it is "///" instead of "//".
One good and more detailed explanation is given here.
http://blogs.msdn.com/ie/archive/2006/12/06/file-uris-in-windows.aspx
I really appreciate his post.
Wednesday, September 05, 2007
Using JAva 6 New Scripting Capabilities
I was working on my thesis work where I had a requirement to execute certain code snippets of JavaScript and see if they make calls or modify a specific set of objects. For example, I wanted to see if the code I wish to run sets "location" property. So I wanted to use the Rhino Engine to execute the Javascript and the major problem with that is that Rhino is just an engine for JavaScript and does not provide any DOM API. So any DOM calls made in the JavaScript would terminate the execution. So we have to expose a set of objects by ourselves to the engine. Anyway in the mean time I came across an article which used Java 6 Scripting Engines! I knew Java 6 had some scripting facilities but never gave it a hard thought. It is a really simple API and works really well. In the past I have tried to use Rhino to run javascript but it is really a tedious process. anyway here is how it is done using javax.script package.
import java.io.FileNotFoundException;
import java.io.FileReader;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import com.sun.script.javascript.RhinoScriptEngine;
public class TestScripting {
public static void main(String[] args)
{
ScriptEngineManager mgr = new ScriptEngineManager();
RhinoScriptEngine js = (RhinoScriptEngine)mgr.getEngineByName("js");
try {
js.put("location",new TestScripting()); // tell the script engine to use the object passed when it encounters "location"
js.eval("function alert(x) { print(x);}"); // implement your own global alert function
try {
js.eval(new FileReader("/home/krishna/workspace/SuriLearning/bin/test.js"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ScriptException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void write(Object mesg)
{
System.out.println(mesg);
}
public void replace(String mesg)
{
System.out.println("Called location.replace to go to : "+mesg);
}
}
Then I have updated the test.js file with some statement like "location.replace("http://google.com")". This is a basic idea on how we can use Rhino to detect redirections, which is portion of my work.
import java.io.FileNotFoundException;
import java.io.FileReader;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import com.sun.script.javascript.RhinoScriptEngine;
public class TestScripting {
public static void main(String[] args)
{
ScriptEngineManager mgr = new ScriptEngineManager();
RhinoScriptEngine js = (RhinoScriptEngine)mgr.getEngineByName("js");
try {
js.put("location",new TestScripting()); // tell the script engine to use the object passed when it encounters "location"
js.eval("function alert(x) { print(x);}"); // implement your own global alert function
try {
js.eval(new FileReader("/home/krishna/workspace/SuriLearning/bin/test.js"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ScriptException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void write(Object mesg)
{
System.out.println(mesg);
}
public void replace(String mesg)
{
System.out.println("Called location.replace to go to : "+mesg);
}
}
Then I have updated the test.js file with some statement like "location.replace("http://google.com")". This is a basic idea on how we can use Rhino to detect redirections, which is portion of my work.
Monday, August 13, 2007
my views on destiny
Life goes on with or without a person being happy. There is nothing that one can do in particular about being happy. I have tried my best to lead a disciplined life, the life that one who loves me feels proud about. But it is all trash, that i got to know after a few years of toil and few months of severe pain. You will have to face what it comes towards you even if you are principled or would want to lead a normal life. Doing good to others would take you no where and if you think your doing good to others would ensure you a peaceful life, then you are mistaken. It is these very principles that would make you suffer the most. If you had been not so principled then you would not give a damn about others and then when a person deserts you, you would not have to worry much because you dont give a damn.
What do you want in life?
Well this is one question that you should never ask yourself, the moment you ask the question, you tend to think on what you dont have in life that you want the most and that makes you extremely unhappy. I know that, I have experienced that. And trust me in most of the cases I am better because I did not ask for something that no one could get. It was just that I was craving for a thing that I dont deserve, I guess. Make sure you dont ask that question to yourself. Trust me, by default its always happiness that you want. Had I got what I wished for the most, then I would definitely be happy. But some lives are that way, they dont get what they want right from the time they get their senses. My life has never been normal, I have seen all types of unhappiness that a normal middle class person can see. Thank to anyone who is responsible that I never had a problem to eat or to live. But then I have seen all kinds of problems - I have seen poverty, I have seen break-ups, I have seen much more complicated things and hell with God, I have seen everything that no one would probably wish to see. Live for your parents and do what they want you to do, then you would be the most happiest person on earth. Do not love any one, because it leaves you with pain and gives you nothing but unhappiness. Anyway unless someone dies, they doesnt know the pain of death.
What do you want in life?
Well this is one question that you should never ask yourself, the moment you ask the question, you tend to think on what you dont have in life that you want the most and that makes you extremely unhappy. I know that, I have experienced that. And trust me in most of the cases I am better because I did not ask for something that no one could get. It was just that I was craving for a thing that I dont deserve, I guess. Make sure you dont ask that question to yourself. Trust me, by default its always happiness that you want. Had I got what I wished for the most, then I would definitely be happy. But some lives are that way, they dont get what they want right from the time they get their senses. My life has never been normal, I have seen all types of unhappiness that a normal middle class person can see. Thank to anyone who is responsible that I never had a problem to eat or to live. But then I have seen all kinds of problems - I have seen poverty, I have seen break-ups, I have seen much more complicated things and hell with God, I have seen everything that no one would probably wish to see. Live for your parents and do what they want you to do, then you would be the most happiest person on earth. Do not love any one, because it leaves you with pain and gives you nothing but unhappiness. Anyway unless someone dies, they doesnt know the pain of death.
Friday, July 27, 2007
Installing Toshiba L35-1054 Audio Drivers on Fedora Core 7
The Toshiba L35-1054 Laptop comes with a RealTek Audio Card. In order to install the drivers on Linux (I use Fedora Core 7 which rocks!), first download the driver pack from realtek.com. Given is the straight link for the pack ..
ftp://202.65.194.211/pc/audio/realtek-linux-audiopack-4.06a.tar.bz2
Extract the archive using the tar command passing -xvf options.
tar -xvf realtek-linux-audiopack-4.06a.tar.bz2
Go into the directory that was created during the extraction. You can see a Readme.txt which explains how to install manually or automatically. Since I am a novice I prefer to do it automatically. So I type in
./install
It takes around 10 mins for the drivers to be installed. I had all the needed compilers like the cc,g++ and fortran stuff installed on my box so I did not face any errors. Anyway after installation, restart the system. You might get an error saying device not found. Just check the box asking it not to show the message again. Now you can go to the Sound Card Detection Tool ( I run KDE, it rocks too! - Start -> Administration -> Sound Card Detection). Test the card and you should be able to hear the sound!
Well all the best!
Keywords:
RealTek Audio Drivers
Toshiba Satellite L35-S1054 Audio Drivers
Audio Drivers Linux Fedora Core 7
Installing Audio Drivers on Linux 2.6
ftp://202.65.194.211/pc/audio/realtek-linux-audiopack-4.06a.tar.bz2
Extract the archive using the tar command passing -xvf options.
tar -xvf realtek-linux-audiopack-4.06a.tar.bz2
Go into the directory that was created during the extraction. You can see a Readme.txt which explains how to install manually or automatically. Since I am a novice I prefer to do it automatically. So I type in
./install
It takes around 10 mins for the drivers to be installed. I had all the needed compilers like the cc,g++ and fortran stuff installed on my box so I did not face any errors. Anyway after installation, restart the system. You might get an error saying device not found. Just check the box asking it not to show the message again. Now you can go to the Sound Card Detection Tool ( I run KDE, it rocks too! - Start -> Administration -> Sound Card Detection). Test the card and you should be able to hear the sound!
Well all the best!
Keywords:
RealTek Audio Drivers
Toshiba Satellite L35-S1054 Audio Drivers
Audio Drivers Linux Fedora Core 7
Installing Audio Drivers on Linux 2.6
Monday, July 16, 2007
How to resolve StackOverflowException in Java?
Well, not only when you use deep recursion that you encounter a StackOverflowException but also when you serialize objects you might see this exception.
Well you can always avoid this error by setting a VM option to java, either from eclipse or when you run it from command line, as an argument.
If it is in Eclipse, go to the Run dialog of the current Java program that you wish to run and go to the second tab (arguments I guess) and then in the VM Options you can set "-Xss1024K" which means that any thread that runs on Java VM will be allotted a Stack size of 1 MB which is quite enough for most of the cases.
If you wish to serialize data that has a lot of interlinked references then you might want to keep it something really high, just to be on safer side.
Interesting stuff is going on in the DBMS class at my university and we are learning really good stuff especially the performance oriented nature of DB algorithms! I enjoy the programming assignments, its fun to learn and code!
Well you can always avoid this error by setting a VM option to java, either from eclipse or when you run it from command line, as an argument.
If it is in Eclipse, go to the Run dialog of the current Java program that you wish to run and go to the second tab (arguments I guess) and then in the VM Options you can set "-Xss1024K" which means that any thread that runs on Java VM will be allotted a Stack size of 1 MB which is quite enough for most of the cases.
If you wish to serialize data that has a lot of interlinked references then you might want to keep it something really high, just to be on safer side.
Interesting stuff is going on in the DBMS class at my university and we are learning really good stuff especially the performance oriented nature of DB algorithms! I enjoy the programming assignments, its fun to learn and code!
Thursday, June 07, 2007
Groovy Programming with Eclipse - 3
Let's continue our talk on Numbers and operations.
Arithmetic Operators
1. Addition (+) Operator
2. Subtraction (-) Operator
3. Multiplication (*) Operator
4. Division (/) Operator ( always returns a floating value )
5. Modulus (%) Operator
Example for each of this is shown below.
def num1 = 22;
def num2 = 11;
def add = 22+11; // alternative: 22.plus(11);
def sub = 22-11; // alternative: 22.minus(11);
def mul = 22*11; // alternative: 22.multiply(11);
def div = 22/11; //alternative: 22.div(11);
def rem = 22 % 11; //alternative: 22.mod(11);
Note that div holds 2.0 but not 2 as you expect. If you want integral division, then you should do it as "22.intdiv(11)". intdiv() returns an Integer while a div or / returns a BigDecimal.
The same set of operators holds good for all types of numeric values - integral and non-integral.
Try this : 22.2 % 11; what do you expect would be returned. Well, this is an illegal operation. Since numbers are also objects, the operators +,-,*,etc work because they are "overloaded". Note that multiplicative operators have higher precedence over additive operators(+,-). Also, boolean operators(the comparison operators) have lower precendence over any arithmetic operators.
Other operators of interest are increment and decrement operators. Unary operators are available to increment/decrement a number by 1. For example,
def two = 3-1;
The above statement is perfectly valid. But most of us are already used to do the same using ++ unary operator, which I prefer over anything else if the increment/decrement is by 1. Most of us already know how ++ and -- works. To test if you know, try to guess the output of the simple program shown below:
def v = 10;
def op1 = v++;
def op2 = ++v;
println(op1);
println(op2);
Answers: 10 and 12.
As mentioned earlier, types are assigned at run-time! This is referred to as "dynamic-typing" and this is what makes Groovy a loosely-typed language.
As I mentioned earlier, numbers are objects too! So we have to deal with references. Consider the following snippet.
def num = 12;
def num2 = num;
num++; //will this reflect on num2 too???
println num;
println num2; //guess the output.
it prints 12 and 13. But why?? Both the identifiers refer to the same object. So if one object is modified then the other should be effected too. Isn't it? But the output tells something different The output infact makes sense. When you perform changes on the object itself, then a new object would be created and referred by that identifier. To understand my bad english, try the following code:
def num=12;
def num2 = num;
num2.value++;
println num;
println num2;
Now you can expect the value to be 13 in both the cases! Well justified uh?? by using the "value" property, we are working on the same object! Sharing still maintained!
Boolean/Relational/Comparison Operators
Well as usual <,>,<=,>=,==,!=are comparison or relational operators(also includes the equality operators). Alternative way to do the above said operators is to use compareTo() and equals() methods. For example,
def v1 = 22;
def v2 = 21;
v1.compareTo(v2); //is > 0 in this case.(v1-v2 is ofcourse returned ;)
v1.equals(v2); // returns false.
Note: since the language is loosely typed, i prefer to use .class operator to test what functions/operators bind to what class especially when I try out some new methods. And one last thing to remember is that Garbage collector is always active even when working with plain simple numbers.(ofcourse they are objects !).
In the next post, let us talk about Strings in specific.
I hope atleast one in the world other than me will find this tutorial useful. If so, I appreciate your comments.
Arithmetic Operators
1. Addition (+) Operator
2. Subtraction (-) Operator
3. Multiplication (*) Operator
4. Division (/) Operator ( always returns a floating value )
5. Modulus (%) Operator
Example for each of this is shown below.
def num1 = 22;
def num2 = 11;
def add = 22+11; // alternative: 22.plus(11);
def sub = 22-11; // alternative: 22.minus(11);
def mul = 22*11; // alternative: 22.multiply(11);
def div = 22/11; //alternative: 22.div(11);
def rem = 22 % 11; //alternative: 22.mod(11);
Note that div holds 2.0 but not 2 as you expect. If you want integral division, then you should do it as "22.intdiv(11)". intdiv() returns an Integer while a div or / returns a BigDecimal.
The same set of operators holds good for all types of numeric values - integral and non-integral.
Try this : 22.2 % 11; what do you expect would be returned. Well, this is an illegal operation. Since numbers are also objects, the operators +,-,*,etc work because they are "overloaded". Note that multiplicative operators have higher precedence over additive operators(+,-). Also, boolean operators(the comparison operators) have lower precendence over any arithmetic operators.
Other operators of interest are increment and decrement operators. Unary operators are available to increment/decrement a number by 1. For example,
def two = 3-1;
The above statement is perfectly valid. But most of us are already used to do the same using ++ unary operator, which I prefer over anything else if the increment/decrement is by 1. Most of us already know how ++ and -- works. To test if you know, try to guess the output of the simple program shown below:
def v = 10;
def op1 = v++;
def op2 = ++v;
println(op1);
println(op2);
Answers: 10 and 12.
As mentioned earlier, types are assigned at run-time! This is referred to as "dynamic-typing" and this is what makes Groovy a loosely-typed language.
As I mentioned earlier, numbers are objects too! So we have to deal with references. Consider the following snippet.
def num = 12;
def num2 = num;
num++; //will this reflect on num2 too???
println num;
println num2; //guess the output.
it prints 12 and 13. But why?? Both the identifiers refer to the same object. So if one object is modified then the other should be effected too. Isn't it? But the output tells something different The output infact makes sense. When you perform changes on the object itself, then a new object would be created and referred by that identifier. To understand my bad english, try the following code:
def num=12;
def num2 = num;
num2.value++;
println num;
println num2;
Now you can expect the value to be 13 in both the cases! Well justified uh?? by using the "value" property, we are working on the same object! Sharing still maintained!
Boolean/Relational/Comparison Operators
Well as usual <,>,<=,>=,==,!=are comparison or relational operators(also includes the equality operators). Alternative way to do the above said operators is to use compareTo() and equals() methods. For example,
def v1 = 22;
def v2 = 21;
v1.compareTo(v2); //is > 0 in this case.(v1-v2 is ofcourse returned ;)
v1.equals(v2); // returns false.
Note: since the language is loosely typed, i prefer to use .class operator to test what functions/operators bind to what class especially when I try out some new methods. And one last thing to remember is that Garbage collector is always active even when working with plain simple numbers.(ofcourse they are objects !).
In the next post, let us talk about Strings in specific.
I hope atleast one in the world other than me will find this tutorial useful. If so, I appreciate your comments.
Groovy Programming with Eclipse - 2
In the current post, I would present how to work with Numbers and variables in Groovy. Before we move into the program, some Groovy fundas.
1. Groovy classes are binary-compatible with Java classes - the Groovy compiler generates the same byte codes as that of javac.
2. Groovy brings uniformity to Java language. Everything in Groovy is an object - including fundamental data-types.
3. Groovy is dynamically typed. For example, having the following statements in the same block would work in Groovy while fails in Java
def x = 10; // integer
x = "bhargav"; // string
Based on the value assigned to the variable, the type of the variable is determined.
4. Groovy provides "Properties" which are already present in C# and VB.NET. They are kind of mixture of both instance fields and methods.
5. Other interesting feature is the presence of data structures like Maps, List as native language constructs. In java we use ArrayList or LinkedList, while in Groovy, its just []. For example,
def names = []; //creates an empty names list.
Well as you have already seen, to create a variable we use the keyword "def" and if the variable name already exists then we can assign the value we wish to straight-away. Its just that simple.
Use the earlier post and create a new Groovy class in Eclipse. Then try to create a variable using "def" as shown.
def name = "Krishna";
Now since the RHS is a string, internally Groovy compiler picks java.lang.String. We can know what class an object belongs to using the ".class" property.
println name.class;
The above statement would now print "java.lang.String". Now try assigning a different value, now lets assign an integer and look at the class.
name = 100;
println name.class;
This would now print "Integer" on the console. Similary, let us create a list and then see what class internally it uses.
def names = ["Bhargava", " loves ", " Programming."];
println names.class;
Guess what this would print? This prints java.util.ArrayList !! So lists of Groovy internally uses "ArrayList". As we can see everything here is a class and its basically appears as top-layer on Java to make programmers lazy. So other language rules/regulations are still applicable to Groovy. For example, you cannot call non-static methods from a static method directly. Now that we are talking about methods, let us write a simple method. This method should now return us what class the argument passed belongs to. Well, for not-so-experienced but good programmers, one question raises. What should be the return type? Well the class property is of type "Class".
So is name.class.class a valid one?? Definitely! it would be java.lang.Class. Now let us get back to a simple program showing methods in Groovy.
class VariablesAndMethods
{
static main(args) //notice with groovy even the main args is not specified as String[]
{
println className(5);
println className("Bhargava");
println className(100.00);
println className(true);
println className(true.class);
}
static Class className(object)
{
object.class;
}
Wait! where is the "return" statement? Well in groovy, there is no need to specify return explictly. Kind of bad! Well atleast for me. Now the output looks like this:
class java.lang.Integer
class java.lang.String
class java.math.BigDecimal
class java.lang.Boolean
class java.lang.Class
Well let me confuse you more. Shown below is a small method. Tell me what it prints.
static increment(value)
{
value++;
}
Well this returns "value" itself. ( Post Increment operator ).
How about this?
static increment(value)
{
value++;
value;
}
If we notice the return value of this method, we can notice that if there are multiple statements which are like "value;"(equi to return value;) then only the last statement would be equivalent to "return value;".
If you already know, in Java 0 is not False and 1 or more is not true. But in Groovy, the old ways are back. Try this statement ( well for simple statements you can use Groovy console. (From rt click on project->Groovy->Groovy Console. Type in a statement and press CTRL + R ).
println 0==false;
When you run the above statement you would end up getting ClassCastException. But try this:
println someFunction();
where someFunction is defined as
Boolean someFunction()
{
return 0; //return zero.
}
This would print "false" and for any +ve number returned, this prints "true". Kind of confusing, isnt it??
Well enough of methods, in the next post I would continue my talk on numbers and we will see how to perform operations on numbers and stuff.
1. Groovy classes are binary-compatible with Java classes - the Groovy compiler generates the same byte codes as that of javac.
2. Groovy brings uniformity to Java language. Everything in Groovy is an object - including fundamental data-types.
3. Groovy is dynamically typed. For example, having the following statements in the same block would work in Groovy while fails in Java
def x = 10; // integer
x = "bhargav"; // string
Based on the value assigned to the variable, the type of the variable is determined.
4. Groovy provides "Properties" which are already present in C# and VB.NET. They are kind of mixture of both instance fields and methods.
5. Other interesting feature is the presence of data structures like Maps, List as native language constructs. In java we use ArrayList or LinkedList, while in Groovy, its just []. For example,
def names = []; //creates an empty names list.
Well as you have already seen, to create a variable we use the keyword "def" and if the variable name already exists then we can assign the value we wish to straight-away. Its just that simple.
Use the earlier post and create a new Groovy class in Eclipse. Then try to create a variable using "def" as shown.
def name = "Krishna";
Now since the RHS is a string, internally Groovy compiler picks java.lang.String. We can know what class an object belongs to using the ".class" property.
println name.class;
The above statement would now print "java.lang.String". Now try assigning a different value, now lets assign an integer and look at the class.
name = 100;
println name.class;
This would now print "Integer" on the console. Similary, let us create a list and then see what class internally it uses.
def names = ["Bhargava", " loves ", " Programming."];
println names.class;
Guess what this would print? This prints java.util.ArrayList !! So lists of Groovy internally uses "ArrayList". As we can see everything here is a class and its basically appears as top-layer on Java to make programmers lazy. So other language rules/regulations are still applicable to Groovy. For example, you cannot call non-static methods from a static method directly. Now that we are talking about methods, let us write a simple method. This method should now return us what class the argument passed belongs to. Well, for not-so-experienced but good programmers, one question raises. What should be the return type? Well the class property is of type "Class".
So is name.class.class a valid one?? Definitely! it would be java.lang.Class. Now let us get back to a simple program showing methods in Groovy.
class VariablesAndMethods
{
static main(args) //notice with groovy even the main args is not specified as String[]
{
println className(5);
println className("Bhargava");
println className(100.00);
println className(true);
println className(true.class);
}
static Class className(object)
{
object.class;
}
Wait! where is the "return" statement? Well in groovy, there is no need to specify return explictly. Kind of bad! Well atleast for me. Now the output looks like this:
class java.lang.Integer
class java.lang.String
class java.math.BigDecimal
class java.lang.Boolean
class java.lang.Class
Well let me confuse you more. Shown below is a small method. Tell me what it prints.
static increment(value)
{
value++;
}
Well this returns "value" itself. ( Post Increment operator ).
How about this?
static increment(value)
{
value++;
value;
}
If we notice the return value of this method, we can notice that if there are multiple statements which are like "value;"(equi to return value;) then only the last statement would be equivalent to "return value;".
If you already know, in Java 0 is not False and 1 or more is not true. But in Groovy, the old ways are back. Try this statement ( well for simple statements you can use Groovy console. (From rt click on project->Groovy->Groovy Console. Type in a statement and press CTRL + R ).
println 0==false;
When you run the above statement you would end up getting ClassCastException. But try this:
println someFunction();
where someFunction is defined as
Boolean someFunction()
{
return 0; //return zero.
}
This would print "false" and for any +ve number returned, this prints "true". Kind of confusing, isnt it??
Well enough of methods, in the next post I would continue my talk on numbers and we will see how to perform operations on numbers and stuff.
Groovy Programming with Eclipse - 1
In this short series of Groovy posts, I intend to cover some Groovy fundas and at the same time myself learn the platform. I will work on Eclipse and would not work at console level and instead use Groovy plugin on Eclipse.
1. Installing Groovy Plugin for Eclipse.
1. Installing Groovy Plugin for Eclipse.
- Start Eclipse. Go to Help->Software Updates->Find and Install.
- Select "Search for new features to install" and click Next.
- Click on "New Remote Site"
- Give a name say "Groovy Plugin" and in the URL put "http://dist.codehaus.org/groovy/distributions/update/"
- Click Ok. Now select the newly added remote site and then click Finish. Follow the on-screen instructions and majorly you need to click "Install All" and then restart Eclipse for the changes to be effected.
2. Testing your Groovy installation on Eclipse.
- Create a new project in Java.
- Now in the Package Explorer right click on the project. You should see a "Groovy" item in the context menu.
- So go to the Groovy item in the context menu and go to "Groovy->Add Groovy Nature".
- Doing this would kind of convert our Java project to Groovy project. We can now run and test our Groovy programs.
- Now right click on the project and create a new package. Say "groovy.learning.samples".
- Then right click on the project and click on "New->Other". Type Groovy in the "type filter text" textbox. Now select "Groovy Class" and give it a name.(Tutorial1).
- Type the following line inside the code block already generated. Essentially you see a main already inserted.
"println("Welcome to Groovy World"); - Save the file. Now go to the menu "Run->Run As->Groovy Application". You should be able to see the message printed in the console. If so , you have successfully installed Groovy plugin on eclipse and good to write your Groovy programs.
This post, I hope, gives a quickstart to get started working with Groovy on Eclipse. In the subsequent posts, I hope to cover other basic programming constructs in Groovy.
Monday, June 04, 2007
Changing default editor for GreaseMonkey
[Using GreaseMonkey with Visual Studio Web Developer - Orcas Express Edition]
Currently, I am working on GreaseMonkey. I intend to use it as a platform my research on web script anomaly detection. And when we create a new user script, it opens in the dirtiest text editor on earth - the Notepad. And I was wondering on how to change the Default text editor for GreaseMonkey. I wanted to set it to Visual Studio Web Developer Express - Orcas, since it has intellisense for Javascript and that would speed up my job. After searching here and there, I could not find any information on where to change. But I just figured it out on how to change the default editor. Just type "about:config" in firefox address bar to go Firefox preferences. Then, filter for the key "greasemonkey.editor" and change the value to that of the editor you like !!
All set to go.
Currently, I am working on GreaseMonkey. I intend to use it as a platform my research on web script anomaly detection. And when we create a new user script, it opens in the dirtiest text editor on earth - the Notepad. And I was wondering on how to change the Default text editor for GreaseMonkey. I wanted to set it to Visual Studio Web Developer Express - Orcas, since it has intellisense for Javascript and that would speed up my job. After searching here and there, I could not find any information on where to change. But I just figured it out on how to change the default editor. Just type "about:config" in firefox address bar to go Firefox preferences. Then, filter for the key "greasemonkey.editor" and change the value to that of the editor you like !!
All set to go.
Thursday, May 24, 2007
I learnt AJAX!!!
I just updated my Graduate Web Page at http://cs.uga.edu/~krishna
It was a good learning experience to come up with some decent color combinations. I used online color picker tools, well I dont have the link for the tools I used, but here is one good article that gives interesting insights on color-combinations.
http://www.limov.com/colour/schemes.lml
I developed a similar tool in ASP.NET, first using non-AJAX approach and then made the application an AJAX one. It was a great feeling to develop an AJAX application and trust me, with ASP.NET AJAX, we can develop AJAXify any web application in no time and absolutely zero coding.
Here is what I did!
1. First I created a User Control, which had the pallette selection. Then drag and drop ScriptManager control and UpdatePanel on a new ASPX page.
2. Drag and drop the User Control you just created into the Update Panel.
3. Compile and run! all the changes in the page are ajaxified!!!
Absolutely no coding!!!!
I always felt that I lacked good color scheme selection ability, but now with my own tool, I can select a variety of themes!!!
I hope I have some online ASPX Web Hosting service. I intend to buy an ASPX portal very soon and then I can upload the tools I make once a while!
It was a good learning experience to come up with some decent color combinations. I used online color picker tools, well I dont have the link for the tools I used, but here is one good article that gives interesting insights on color-combinations.
http://www.limov.com/colour/schemes.lml
I developed a similar tool in ASP.NET, first using non-AJAX approach and then made the application an AJAX one. It was a great feeling to develop an AJAX application and trust me, with ASP.NET AJAX, we can develop AJAXify any web application in no time and absolutely zero coding.
Here is what I did!
1. First I created a User Control, which had the pallette selection. Then drag and drop ScriptManager control and UpdatePanel on a new ASPX page.
2. Drag and drop the User Control you just created into the Update Panel.
3. Compile and run! all the changes in the page are ajaxified!!!
Absolutely no coding!!!!
I always felt that I lacked good color scheme selection ability, but now with my own tool, I can select a variety of themes!!!
I hope I have some online ASPX Web Hosting service. I intend to buy an ASPX portal very soon and then I can upload the tools I make once a while!
Saturday, April 07, 2007
Research for Summer
With may 10th 2006, the first term with UGA will come to an end. Then I am planning to move on and work on GWT and ASP.NET. And as for my thesis, I am planning to work on P2p Media Streaming - especially I would like to study and enhance the current p2p media streaming networks and come up with something really good enough for my thesis. Hopefully I would stand on this and work further to bring up something good.
Just got few books on p2p computing in java and .NET, also the core technology book to study the underlying systems. Have to wait and see if this plan of mine will work!
Just got few books on p2p computing in java and .NET, also the core technology book to study the underlying systems. Have to wait and see if this plan of mine will work!
Thursday, March 29, 2007
Mean Shift Tracking in Java
After long long attempts to learn - understand the Mean Shift tracking, I have finally implemented the Kernel Based Object Tracking in Java. First I have tried to implement the tracker in openCV but I had some problems with the rectangle selection(the bounding box) so I moved back to Java and implemented the code offline using Java Media FrameWork. I have written a nice small class using JMF which we can use to extract frames out of a given Video file. There is no support for WMV format - it says NoPlayerException and some DivX formats, but then most of the files were played successfully.
My tracking results are shown below. Shown are the first, 19th and the 10th frame of a striker - video courtesy "WEB".
My tracking results are shown below. Shown are the first, 19th and the 10th frame of a striker - video courtesy "WEB".
Monday, March 12, 2007
asp.net 2.0 - fun to learn
I have just started working on ASP.NET 2.0 again after a long long time. Its been almost an year since I did some serious coding and I want to get myself updated with the latest - asp.net 2.0.
I decided to use the Core ASP.NET reference book from MS Press and have been going through fundas like the IIS 6.0 Process model, HttpRuntime queue and so on.
How to detect the browser programatically in ASP.NET?
---------------------------------------------------------
You have the Request object with you. You can access the Request object either directly or from the HttpContext object. To detect the browser you are running ....
Dim browser as String = HttpContext.Current.Browser.Browser
For IE, browser would be "IE" and for firefox, its Firefox.
More about the HttpContext....
Actually, ProcessRequest method is called on the HttpRuntime object when a request arrives. Just before it serves a page to the request, a "context" is created which could be accessed through the HttpContext object. The HttpRuntime object uses the HttpContext object to locate or create a Web App object that is capable of handling a request it gets. There is an internal object that will be used to do the search - HttpApplicationFactory which maintains a pool of HttpApplication objects to serve incoming http requests. The HttpApplication is the base class that represents a running ASP.NET application. It is this object that determines what kind of a handler is needed - basically it decides what kind of resource is being requested - whether its a web page being asked for or a web server or a server control, etc.
Page Class and important members
-----------------------------------
The following is the list of important members of the Page class.
From my past experience coding ASP.NET web apps, one most important thing that a newbie should always learn is the Page life cycle. By Life cycle in an application programming model, we basically mean what events are fired at what time. The ordering of events become very essential especially when the application grows. Knowing where to put initialization code, where to add controls dynamically, etc will help us code better applications.
The ASP.NET Web Page life cycle is given below.
ASP.NET 2.0 Page Life cycle
http://www.robincurry.org/blog/content/binary/o_aspNet_Page_LifeCycle.jpg
I will post more as I get deep into the subject. I plan to devote an hour a day once the spring break is over.
This is what I think I will/should be doing
1. Core ASP.NET 2.0
2. Data binding with ASP.NET 2.0 and ofcourse ADO.NET
3. ATLAS / ASP.NET AJAX.
Then may be I can get hands-on with XAML,WPF,WCF,Windows Workflow...Gosh there is a lot to learn....
I decided to use the Core ASP.NET reference book from MS Press and have been going through fundas like the IIS 6.0 Process model, HttpRuntime queue and so on.
How to detect the browser programatically in ASP.NET?
---------------------------------------------------------
You have the Request object with you. You can access the Request object either directly or from the HttpContext object. To detect the browser you are running ....
Dim browser as String = HttpContext.Current.Browser.Browser
For IE, browser would be "IE" and for firefox, its Firefox.
More about the HttpContext....
Actually, ProcessRequest method is called on the HttpRuntime object when a request arrives. Just before it serves a page to the request, a "context" is created which could be accessed through the HttpContext object. The HttpRuntime object uses the HttpContext object to locate or create a Web App object that is capable of handling a request it gets. There is an internal object that will be used to do the search - HttpApplicationFactory which maintains a pool of HttpApplication objects to serve incoming http requests. The HttpApplication is the base class that represents a running ASP.NET application. It is this object that determines what kind of a handler is needed - basically it decides what kind of resource is being requested - whether its a web page being asked for or a web server or a server control, etc.
Page Class and important members
-----------------------------------
The following is the list of important members of the Page class.
- Application - instance of HttpApplicationState
- Cache - instance of Cache class, implements cache for an asp.net application
- Request - instance of HttpRequest
- Response - instance of HttpResponse
- Server - instance of HttpServerUtility, helper method for processing web requests.
- Session - instance of HttpSession.
- Trace - instance of TraceContext, used for tracing.
- User - represents the current user whose request is being processed.
From my past experience coding ASP.NET web apps, one most important thing that a newbie should always learn is the Page life cycle. By Life cycle in an application programming model, we basically mean what events are fired at what time. The ordering of events become very essential especially when the application grows. Knowing where to put initialization code, where to add controls dynamically, etc will help us code better applications.
The ASP.NET Web Page life cycle is given below.
- PreInit
- Init
- InitComplete
- View State is now restored
- Posted data is processed
- PreLoad event is fired
- Load event is raised
- LoadComplete (in between few events for handling postback is taken care of)
- PreRender
- PreRenderComplete
- SaveStateComplete
ASP.NET 2.0 Page Life cycle
http://www.robincurry.org/blog/content/binary/o_aspNet_Page_LifeCycle.jpg
I will post more as I get deep into the subject. I plan to devote an hour a day once the spring break is over.
This is what I think I will/should be doing
1. Core ASP.NET 2.0
2. Data binding with ASP.NET 2.0 and ofcourse ADO.NET
3. ATLAS / ASP.NET AJAX.
Then may be I can get hands-on with XAML,WPF,WCF,Windows Workflow...Gosh there is a lot to learn....
Sunday, February 04, 2007
Makefile to compile java programs
The following is the makefile to compile java programs:
all: | remove_classes ProxyServer.class
remove_classes:
rm -f *.class
ProxyServer.class: ProxyServer.java
javac ProxyServer.java -nowarn
The order of execution of jobs within the makefile can be normal or we can specify the order. The jobs listed after the pipe (|) are all orderly, as mentioned above.
all: | first second third
Makefile can be executed as:
> make
If target-name is omitted, then the first job is run. So in the first job, we name it as "all" and then there we specified the jobs it should run, along with the order. It is simple to understand that the current make file removes all old class files and then compiles the java program to get the latest class files. Though this is not needed, as javac would update the class files, this simple example helps us to understand "make".
Have fun!
all: | remove_classes ProxyServer.class
remove_classes:
rm -f *.class
ProxyServer.class: ProxyServer.java
javac ProxyServer.java -nowarn
The order of execution of jobs within the makefile can be normal or we can specify the order. The jobs listed after the pipe (|) are all orderly, as mentioned above.
all: | first second third
Makefile can be executed as:
> make
If target-name is omitted, then the first job is run. So in the first job, we name it as "all" and then there we specified the jobs it should run, along with the order. It is simple to understand that the current make file removes all old class files and then compiles the java program to get the latest class files. Though this is not needed, as javac would update the class files, this simple example helps us to understand "make".
Have fun!
Setting path variables in Linux permanently
Recently I have installed Linux Ubuntu on my laptop on top of Virtual PC. There is a very good post on how to do this at this link:
http://arcanecode.wordpress.com/2006/12/19/installing-ubuntu-on-virtualpc-step-by-step/
Then I had installed Eclipse and JAVA 1.5 on the new linux workstation! I wanted to work out a few programs on the linux platform.
When you start the terminal in Ubuntu and type "java -version", it displays the version but as you notice down it is not the Sun HotSpot VM that is running but is the GCJ, a free java compiler which doesnt actually interpret. So you would like to change the system to use the Java VM you installed. For that the obvious way is to change the Path variables for JAVA_HOME and PATH.
You can set a path variable using "export" command as :
export JAVA_HOME=/opt/jdk1.5.0_11
export PATH=$JAVA_HOME/bin:$PATH
When we set PATH variable, we should not forget to append already existing path variables( using :$PATH).
Now when you type "java -version", you can see your Java VM as HotSpot one. But then close the terminal and open it again.
Again try the "java -version", you will find your settings to be gone! What happens is that your settings were temporary and effective only for the terminal window that was launched and path set. In order for the variables to be effective for the user throughout the sessions, you should edit the bashrc script.
You can set environment variables permanently for a given user by changing the bashrc:
>pico ~/.bashrc
This opens the bashrc for you. Paste the two lines of "export" i mentioned earlier. Make sure you give the path of your JDK properly.
Save the changes and exit.
Now type
>source ~/.bashrc
This updates the changes made the new variables have been set. To test your settings you can now type:
"which java" and it should display the path of the java compiler that is being use( the one you set in the bashrc).
I am trying to find out how to set variables to reflect on all the user accounts !!! Let me know in case you guys know how to!
http://arcanecode.wordpress.com/2006/12/19/installing-ubuntu-on-virtualpc-step-by-step/
Then I had installed Eclipse and JAVA 1.5 on the new linux workstation! I wanted to work out a few programs on the linux platform.
When you start the terminal in Ubuntu and type "java -version", it displays the version but as you notice down it is not the Sun HotSpot VM that is running but is the GCJ, a free java compiler which doesnt actually interpret. So you would like to change the system to use the Java VM you installed. For that the obvious way is to change the Path variables for JAVA_HOME and PATH.
You can set a path variable using "export" command as :
export JAVA_HOME=/opt/jdk1.5.0_11
export PATH=$JAVA_HOME/bin:$PATH
When we set PATH variable, we should not forget to append already existing path variables( using :$PATH).
Now when you type "java -version", you can see your Java VM as HotSpot one. But then close the terminal and open it again.
Again try the "java -version", you will find your settings to be gone! What happens is that your settings were temporary and effective only for the terminal window that was launched and path set. In order for the variables to be effective for the user throughout the sessions, you should edit the bashrc script.
You can set environment variables permanently for a given user by changing the bashrc:
>pico ~/.bashrc
This opens the bashrc for you. Paste the two lines of "export" i mentioned earlier. Make sure you give the path of your JDK properly.
Save the changes and exit.
Now type
>source ~/.bashrc
This updates the changes made the new variables have been set. To test your settings you can now type:
"which java" and it should display the path of the java compiler that is being use( the one you set in the bashrc).
I am trying to find out how to set variables to reflect on all the user accounts !!! Let me know in case you guys know how to!
Subscribe to:
Posts (Atom)