Thursday, October 23, 2008

Art of mathematics or mathematics of art!



my friend sopan posted this awesome link on facebook. its about the art work, mathematical art actually, of Maurits Cornelis Escher who explored many cool mathematical ideas through his works.

Monday, September 29, 2008

Interesting CS project

These projects a really interesting.
1. swarm-bots project. watch the video. paper about swarm-bots
2. head tracking for VR displays using WiiRemote. watch the video.

Saturday, September 27, 2008

Wednesday, June 25, 2008

Happiness


Happiness, originally uploaded by medieval panda.

The art of being happy lies in the power of extracting happiness from common things.

~Henry Ward Beecher

Thursday, May 22, 2008

Grad Student Comic Strip

Your friend (sheetal) sent the following message to you:



(no image? copy and paste the link below)
http://www.phdcomics.com/comics/archive.php?comicid=562


signed by sheetal

'Piled Higher and Deeper' by Jorge Cham is the popular comic strip about life, or the lack thereof, in grad school. Check it out by going to www.phdcomics.com


drop all constraints

To drop all constraints on a table "sampleTable", use the following commands:


CREATE TABLE temp AS SELECT * FROM sampleTable;
DROP TABLE sampleTable;
CREATE TABLE sampleTable AS SELECT * FROM temp;
DROP TABLE temp;


source
reference

Thursday, April 17, 2008

osgi tutorial

Installation:
If you have eclipse 3.3, you don't need any extra plugin.

OSGi tutorial

after building your bundle do the following to make jar:

* Right click on your bundle and select Export. Choose “Plug-in Development->Deployable Plugins and Fragments”.
* Select destination folder (for example /home/pc/Desktop)
* Click “Finish”

complete your plug-in:

somedir/
configuration/
config.ini
eclipse.exe
plugins/
org.eclipse.equinox.common_3.3.0.jar
org.eclipse.equinox.launcher.win32.win32.x86_1.0.0/
eclipse_1017a.dll
[other launcher fragment content]
org.eclipse.equinox.launcher_1.0.0.jar
org.eclipse.osgi_3.3.0.jar
org.eclipse.update.configurator_3.2.100.jar
< your_bundle1 >.jar
< your_bundle2 >.jar

write config.ini->>

osgi.bundles=< your_bundle1 >.jar@start,< your_bundle2 >.jar@start
osgi.bundles=org.eclipse.equinox.common@2:start, org.eclipse.update.configurator@3:start
eclipse.ignoreApp=true
osgi.noShutdown=true


for linux, set up is same, just change the eclipse.exe, org.eclipse.equinox.launcher,org.eclipse.equinox.launcher.win32 with their linux version.

Now, execute the following command:


eclipse -console


A new console will appear.
do the following:
osgi>
osgi>ss


all the bundle will appear.

write

start < bundle id >

this will start your plugin.

example 1
example 2

Tuesday, April 15, 2008

Monday, March 24, 2008

Two Days We Should Not Worry

(Author Unknown)

There are two days in every week about which we should not worry, two days which should be kept free from fear and apprehension.

One of these days is Yesterday with all its mistakes and cares,
its faults and blunders, its aches and pains.

Yesterday has passed forever beyond our control.
All the money in the world cannot bring back Yesterday.

We cannot undo a single act we performed;
we cannot erase a single word we said.
Yesterday is gone forever.

The other day we should not worry about is Tomorrow
with all its possible adversities, its burdens,
its large promise and its poor performance;
Tomorrow is also beyond our immediate control.

Tomorrow's sun will rise,
either in splendor or behind a mask of clouds, but it will rise.
Until it does, we have no stake in Tomorrow,
for it is yet to be born.

This leaves only one day, Today.
Any person can fight the battle of just one day.
It is when you and I add the burdens of those two awful eternities Yesterday and Tomorrow that we break down.

It is not the experience of Today that drives a person mad,
it is the remorse or bitterness of something which happened Yesterday and the dread of what Tomorrow may bring.

Let us, therefore, Live but one day at a time.

Happy Clown


Happy Clown, originally uploaded by technicolortype_a.

Wednesday, March 12, 2008

Doc Edgerton: the man who made time stand still



It was the title of an National Geographic Magazine article in October 1987 that featured Edgerton's work. While seeking for high speed photography technique I found out about Harold Eugene "Doc" Edgerton who invented ultra-high-speed and stop-action photography.

Edgerton, an electrical engineer and professor at MIT, was a pioneer in the field of high-speed photography, exploring the effects of the stroboscope and electronic flash when directed at moving objects. His subjects ranged from birds in flight to the first millionth of a second of an atomic blast. Some of his more famous images include the compression of a tennis ball against a racquet, the multiple movements of a golfer's swing, a speeding bullet as it passes through an apple, and the coronet formed by a milk drop as it splashes into a saucer. The exhibition contains many of these stop-motion images, which, in addition to being scientific evidence, are considered objects of art.

Milkdrop Coronet, 1957
Find more about his life and work at MIT museum website

Some of his interesting quotes i found in internet:

"Don't make me out to be an artist. I am an engineer. I am after the facts, only the facts."
"In many ways, unexpected results are what have most inspired my photography."

By the way, 1st image is "milk meets coffee" by Irene Müller.

More awesome photos are available here.

Monday, March 10, 2008

Ruby crown


Ruby crown, originally uploaded by Luis Eduardo.

Thursday, March 06, 2008

Ghost ship


Ghost ship, originally uploaded by Creative.i.

Wednesday, March 05, 2008

admission er tension e otishto hoye ki korbo bujhte na pere amar oti favorite kaaj shuru korlam- google search. ekta lekha pore monta bhalo hoye gelo bi-deshir deshi wedding.
mon bhalo korte asholei karon lage na :)

Tuesday, February 26, 2008

Ugly duckling


A mother duck hatches her eggs and, while most of her ducklings are normal, one is grey, too large, and too clumsy to fit in among the others. Though she tries to accept him, the entire barnyard realizes that he simply does not belong and after a period of harassment he leaves to fend for himself. He is sheltered by an old woman in her poor cottage, but her cat and her hen will not accept him and he is forced to set off once again on his own. He wanders for the entire summer and fall, for no one will take him in, and he nearly freezes to death in an icy pond. Though he is rescued by a human, he cannot live in captivity, and he returns to the wild.

By the end of winter, he is miraculously still alive. He comes to a pond in a park or garden, where beautiful white swans are swimming. He is drawn to their beauty, though he has no reason to think that they will treat him better than anyone else has. Still, he thinks, even if they kill him, he must approach them. To his surprise, the beautiful creatures welcome and accept him; gazing at his reflection, he sees that he too is a swan. The children declare that he is the most beautiful swan of them all, yet he is not proud, for a good heart is never proud. Because of all that he suffered he now appreciates his happiness so much more.

Sunday, February 24, 2008

Struts2: dynamic file download

(there is a better method for this at the end of this post)

In struts2, file is downloaded as stream using StreamResult class.
To download file of dynamic name, size or type we need to extend this StreamResult class.

StreamResult result type takes the following parameters:

* contentType - the stream mime-type as sent to the web browser (default = text/plain).
* contentLength - the stream length in bytes (the browser displays a progress bar).
* contentDispostion - the content disposition header value for specifing the file name (default = inline, values are typically filename="document.pdf".
* inputName - the name of the InputStream property from the chained action (default = inputStream).
* bufferSize - the size of the buffer to copy from input to output (default = 1024).

Example:

<result name="success" type="stream">
<param name="contentType">image/jpeg</param>
<param name="inputName">imageStream</param>
<param name="contentDisposition">filename="document.pdf"</param>

<param name="bufferSize">1024</param>
</result>


So in the extended StreamResult class we need to set these parameters dynamically.
You could download source code from here, its same as following:

package downloadexample;
import org.apache.struts2.dispatcher.StreamResult;

import com.opensymphony.xwork2.ActionInvocation;

/**
* This class for result-type="myStream"

*
* <result-types> <result-type name="myStream" default="false"
* class="downloadexample.DynamicStreamResult"/>
*
* </result-types>

*
* It extends StreamResult Used to download file as a stream.
*
* @author sheetal
*
*/


public class DynamicStreamResult extends StreamResult{
@Override

protected void doExecute(String finalLocation,
ActionInvocation invocation)
throws Exception {

//get name of downloaded file
String downloadedFileName = invocation.getStack().
findValue(conditionalParse
("name", invocation));

contentDisposition = "filename=\""

+downloadedFileName + "\"";

//get file size
contentLength = ""+ invocation.getStack().findValue(
conditionalParse("size", invocation));
// get type of file
contentType = ""+ invocation.getStack().
findValue(
conditionalParse("description", invocation));
/*
Executes the result given a final location
(jsp page, action, etc) and
the action invocation (the state in which
the action was executed).
*/

super.doExecute(finalLocation, invocation);

}

}



Let, our site is a search site where user inputs name of a file. our system searches the file in server's local directory and lets the user download it if found.

To do this, .jsp file should be include the following:


<s:form action="downloadFile" validate="true">

<s:textfield label="Search file"

name="name" required="true"/>

<s:textfield label="Define file type (image/jpeg, text/plain, application/pdf)"
name="description" required="true"/>

<s:submit value="Find file"/>

</s:form>


where downloadFile is the action for downloading file.

In your action class, add the following lines:

private String name;
//holds name of downloaded file

private InputStream inputStream;
//holds stream of downloaded file
private String description;
//holds the content type of the downloaded file

private long size;
//holds the content size of the downloaded file


//method for downloading file
public String downloadFile()
{

/*
let, method searchFile(String fileName)
does the searching for us
& returns InputStream of the file if found
and null otherwise.
*/

this.inputStream = searchFile(name);

if(inputStream !=null)
{

return Action.SUCCESS;

}
else
{
//handle error
return Action.ERROR;

}


}

//write setter getter methods
public InputStream getInputStream() throws Exception

{
return inputStream;

}

public String getName()

{
return name;
}
public void setName(String name)

{
this.name = name;
}
public String getDescription()

{
return this.description;
}
public void setDescription(String description)

{
this.description = description;
}
// write getter setter for attribute size


Now, edit your struts.xml file:


<!-- custom result type for file download -->
<result-types>
<result-type name="myStream"

default="false"
class="downloadexample.DynamicStreamResult"/>

</result-types>
<!-- action for downloading file-->
<action name="downloadFile"

method="downloadFile"
class="<action-class-name>
">

<result type="myStream"/>
<result name="error">jsps/your_error_page.jsp</result>


</action>



syntax highlighted by Code2HTML, v. 0.9.1

& we are done :D.

...................................................
May be a Better method:
the time i wrote this post i was too naive to find other solution for this. One person commented a quick solution on the blog.... thank you again. i haven't tried it, so i'm not sure if it works, check yourself...here is the comment.........

Actually, there's no need to extend the StreamResult class. You can dynamically pass the contentType (and other Stream parameters) by using parameter substitution in your Action mapping, like so:


<result name="success" type="stream">

<param name="contentType">${contentType}</param>
<param name="inputName">imageStream</param>

<param name="contentDisposition">filename="${fileName}"</param>

<param name="bufferSize">${bufferSize}</param>

</result>



You then add methods set/getContentType(), set/getFileName() and set/getBufferSize() to your Action class. In the Action method which handles your business logic, all you have to do is call this.setContentType(), this.setFileName() and this.setBufferSize() and supply whatever values you like.

---------------------------------------