I almost wish I hadn't gone down that rabbit-hole — and yet — and yet — it's rather curious, you know, this sort of life!
Friday, November 21, 2008
Creating mozilla extension
http://ancaluca.blogspot.com/2007/10/java-firefox-extension.html
http://groups.google.com/group/mozilla.dev.tech.java/browse_thread/thread/41a2db6eb748e6f6
File i/o:
https://developer.mozilla.org/En/Code_snippets:File_I/O#Writing_to_a_file
Monday, November 17, 2008
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
1. swarm-bots project. watch the video. paper about swarm-bots
2. head tracking for VR displays using WiiRemote. watch the video.
Wednesday, June 25, 2008
Happiness
The art of being happy lies in the power of extracting happiness from common things.
~Henry Ward Beecher
Thursday, June 05, 2008
Monday, June 02, 2008
Thursday, May 22, 2008
Grad Student Comic Strip
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
CREATE TABLE temp AS SELECT * FROM sampleTable;
DROP TABLE sampleTable;
CREATE TABLE sampleTable AS SELECT * FROM temp;
DROP TABLE temp;
source
reference
Wednesday, May 21, 2008
faq on struts spring
--
Sheetal
--A journey of a thousand mile begins with a single step --
Thursday, April 17, 2008
osgi tutorial
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
eclipse osgi sample project for beginers
Monday, March 24, 2008
Two Days We Should Not Worry
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.
Thursday, March 13, 2008
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.
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
Thursday, March 06, 2008
Wednesday, March 05, 2008
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
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.
---------------------------------------
Upload data to oracle using sql loader
I have a table named user in my oracle database.
Table creation commands:
create table user
(
id number,
name varchar(10)
);
To insert large amount of data (e.g. 1 million) row into that table, we could use sql loader. This utility (SQL LOADER)is used to load data from other data source into Oracle.
Steps for doing this:
1. write .csv file user.csv. Its a simple text file with comma separated data.
data are written in the following way:
1,"user1"
2,"user2"
2. copy user.csv file to the server where oracle is running. You could use ftp or ssh for this.
Let, user.csv is copied in /root/mycsv folder
3. write user.ctl file
LOAD DATA
INFILE '/root/mycsv/user.csv'
append into table user
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(id,
name
)
Notes:
- The LOAD DATA statement is required at the beginning of the control file.
- The INFILE option specifies where the input file is located
- Specifying BADFILE is optional. If you specify, then bad records found during loading will be stored in this file.
- Specifying DISCARDFILE is optional. If you specify, then records which do not meet a WHEN condition will be written to this file.
- You can use any of the following loading option
a. INSERT : Loads rows only if the target table is empty
b. APPEND: Load rows if the target table is empty or not.
c. REPLACE: First deletes all the rows in the existing table and then, load rows.
d. TRUNCATE: First truncates the table and then load rows.
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
This line indicates how the fields are separated in input file. Since in our case the fields are separated by “,” so we have specified “,” as the terminating char for fields. You can replace this by any char which is used to terminate fields. Some of the popularly use terminating characters are semicolon “;”, colon “:”, pipe “|” etc. TRAILING NULLCOLS means if the last column is null then treat this as null value, otherwise, SQL LOADER will treat the record as bad if the last column is null.
(id,
name
)- In this line specify the columns of the target table. Note how do you specify format for Date columns
4. execute the following command to load data from user.csv file to your database.
sqlldr userid=username/password@SIDname control='user.ctl' log='user.log'
5. If you don't know the SID name for oracle server, you can find it using following command:
echo $ORACLE_SID
if sid name was wrong, you'll get following error:
SQL*Loader-704: Internal error: ulconnect: OCIServerAttach [0]
ORA-12154: TNS:could not resolve the connect identifier specified
If the csv file is too large and tablespace is full, you'll get following error:
SQL*Loader-605: Non-data dependent ORACLE error occurred -- load discontinued.
Check your .log file and if you find the following if tablespace is full
ORA-01653: unable to extend table username.tablename by X in tablespace yourtablespace
To resolve this, you need to add another table space. Execute the following command to see current status of your tablespace:
select * from dba_data_files where tablespace_name = 'yourtablespace;
You'll find current something like the following:
FILE_NAME
----------------------------------------------
/usr/local/oracle/oradata/webct/yourtablespace01.dbf
FILE_ID TABLESPACE_NAME BYTES BLOCKS STATUS
---------- ------------------------------ ---------- ---------- ---------
11 yourtablespace 4294967296 524288 AVAILABLE
RELATIVE_FNO AUT MAXBYTES MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS
------------ --- ---------- ---------- ------------ ---------- -----------
11 YES 4294967296 524288 65536 4294443008 524224
Now you have to add more table space using following command:
alter tablespace USERS add datafile '/usr/local/oracle/oradata/webct/yourtablespace02.dbf' size 1024M autoextend on next 512M maxsize 4096M;
See details solution here.
Wednesday, February 20, 2008
Tuesday, February 19, 2008
Friday, February 15, 2008
30 Largest Social Bookmarking Sites
Here are the 30 Largest Social Bookmarking Sites ranked by a combination of Inbound Links, Google Page Rank, Alexa Rank, and U.S. traffic data from Compete and Quantcast. Although no traffic metrics are completely accurate we do believe the data below to be useful for gauging relative audience size.
1 | digg.com
117,796,083 - Inbound Links | 16,964,445 - Compete Monthly Visitors | 8,700,000 - Quantcast Monthly Visitors | 98 - Alexa Ranking. | Page Rank: 8
2 | Technorati.com
75,306,437 - Inbound Links | 3,231,709 - Compete Monthly Visitors | 1,400,000 - Quantcast Monthly Visitors | 216 - Alexa Ranking. | Page Rank: 8
3 | del.icio.us
171,593,051 - Inbound Links | 1,699,128 - Compete Monthly Visitors | 1,300,000 - Quantcast Monthly Visitors | 248 - Alexa Ranking. | Page Rank: 8
4 | Propeller.com
997,000 - Inbound Links | 1,454,912 - Compete Monthly Visitors | 2,180,176 - Quantcast Monthly Visitors | 2,308 - Alexa Ranking. | Page Rank: 7
5 | StumbleUpon.com
19,050,177 - Inbound Links | 1,313,586 - Compete Monthly Visitors | 695,239 - Quantcast Monthly Visitors | 300 - Alexa Ranking. | Page Rank: 8
6 | reddit.com
45,307,577 - Inbound Links | 1,226,467 - Compete Monthly Visitors | 344,383 - Quantcast Monthly Visitors | 852 - Alexa Ranking. | Page Rank: 7
7 | Fark.com
11,438,723 - Inbound Links | 306,597 - Compete Monthly Visitors | 1,767,165 - Quantcast Monthly Visitors | 1,958 - Alexa Ranking. | Page Rank: 7
8 | MyBlogLog.com
1,742,265 - Inbound Links | 1,972,847 - Compete Monthly Visitors | 84,922 - Quantcast Monthly Visitors | 432 - Alexa Ranking. | Page Rank: 7
9 | Slashdot.org
13,555,035 - Inbound Links | 724,424 - Compete Monthly Visitors | 269,884 - Quantcast Monthly Visitors | 579 - Alexa Ranking. | Page Rank: 9
10 | kaboodle.com
100,266 - Inbound Links | 1,751,763 - Compete Monthly Visitors | 851,858 - Quantcast Monthly Visitors | 9,125 - Alexa Ranking. | Page Rank: 6
11 | Bloglines.com
50,717,948 - Inbound Links | 382,663 - Compete Monthly Visitors | 103,711 - Quantcast Monthly Visitors | 853 - Alexa Ranking. | Page Rank: 9
12 | newsvine.com
24,200,775 - Inbound Links | 315,857 - Compete Monthly Visitors | 203,761 - Quantcast Monthly Visitors | 3,977 - Alexa Ranking. | Page Rank: 7
13 | blinklist.com
23,770,576 - Inbound Links | 243,277 - Compete Monthly Visitors | 165,306 - Quantcast Monthly Visitors | 4,647 - Alexa Ranking. | Page Rank: 6
14 | netvouz.com
8,112,272 - Inbound Links | 75,507 - Compete Monthly Visitors | 54,325 - Quantcast Monthly Visitors | 15,048 - Alexa Ranking. | Page Rank: 6
15 | clipmarks.com
164,419 - Inbound Links | 196,107 - Compete Monthly Visitors | 147,131 - Quantcast Monthly Visitors | 6,740 - Alexa Ranking. | Page Rank: 6
16 | Furl.net
49,595,144 - Inbound Links | 148,975 - Compete Monthly Visitors | 57,547 - Quantcast Monthly Visitors | 4,112 - Alexa Ranking. | Page Rank: 8
17 | Mister-Wong
13,214,146 - Inbound Links | 25,416 - Compete Monthly Visitors | 3,432 - Quantcast Monthly Visitors | 1,889 - Alexa Ranking. | Page Rank: 7
18 | dzone.com
1,065,009 - Inbound Links | 100,784 - Compete Monthly Visitors | 117,897 - Quantcast Monthly Visitors | 5,187 - Alexa Ranking. | Page Rank: 6
19 | ma.gnolia.com
13,701,444 - Inbound Links | 110,662 - Compete Monthly Visitors | 32,363 - Quantcast Monthly Visitors | 7,454 - Alexa Ranking. | Page Rank: 7
20 | Tailrank.com
5,320,211 - Inbound Links | 71,563 - Compete Monthly Visitors | 35,783 - Quantcast Monthly Visitors | 28,920 - Alexa Ranking. | Page Rank: 7
21 | ShoutWire.com
168,480 - Inbound Links | 101,738 - Compete Monthly Visitors | 55,337 - Quantcast Monthly Visitors | 10,552 - Alexa Ranking. | Page Rank: 6
22 | simpy.com
13,107,730 - Inbound Links | 62,645 - Compete Monthly Visitors | 49,205 - Quantcast Monthly Visitors | 10,948 - Alexa Ranking. | Page Rank: 7
23 | BlogMarks.net
9,748,453 - Inbound Links | 61,740 - Compete Monthly Visitors | 28,075 - Quantcast Monthly Visitors | 11,880 - Alexa Ranking. | Page Rank: 6
24 | BlueDot.us
1,159,780 - Inbound Links | 107,717 - Compete Monthly Visitors | 60,045 - Quantcast Monthly Visitors | 12,072 - Alexa Ranking. | Page Rank: 6
25 | Spurl.net
18,628,253 - Inbound Links | 42,300 - Compete Monthly Visitors | 3,483 - Quantcast Monthly Visitors | 14,300 - Alexa Ranking. | Page Rank: 6
26 | Spotplex.com
541,599 - Inbound Links | 52,176 - Compete Monthly Visitors | 15,106 - Quantcast Monthly Visitors | 42,809 - Alexa Ranking. | Page Rank: 6
27 | linkswarm.com
150,842 - Inbound Links | 14,504 - Compete Monthly Visitors | 10,476 - Quantcast Monthly Visitors | 47,267 - Alexa Ranking. | Page Rank: 5
28 | Spotback.com
97,564 - Inbound Links | 42,838 - Compete Monthly Visitors | 5,037 - Quantcast Monthly Visitors | 42,015 - Alexa Ranking. | Page Rank: 5
29 | PlugIm.com
161,039 - Inbound Links | 48,078 - Compete Monthly Visitors | 2,000 - Quantcast Monthly Visitors | 13,133 - Alexa Ranking. | Page Rank: 5
30 | MyBookmarks.com
25,191 - Inbound Links | 10,934 - Compete Monthly Visitors | 7,727 - Quantcast Monthly Visitors | 108,226 - Alexa Ranking. | Page Rank: 5
Wednesday, February 13, 2008
Free bangla books download
I will keep adding more books. stay tuned !!!
Meanwhile, think about those less fortunate people and donate
/**********************************
- Many Free books from boi-mela
- My Friend Rashed by Mohammad Jafar Iqbal
- maa by Anisul Haque
- Fobiyaan er jatri by Mohammad Jafar Iqbal
- Sultana's dream by Begum Rokeya
Rabindranath Tagor:
Tuesday, February 12, 2008
Monday, February 11, 2008
Sunday, February 10, 2008
Thursday, January 24, 2008
Wednesday, January 23, 2008
Thursday, January 17, 2008
Sunday, January 13, 2008
Saturday, January 12, 2008
and your head on the ground
try this trick & spin it ... ... ...
your head will collapse
if theres nothing in it
you will ask yourself where is my mind?
Thursday, January 10, 2008
Regular expression in java
String input = "something";
1. write a regular expression
String regex="your_reg_ex";
2. create a pattern object compiling your regex
Pattern p = Pattern.compile(regex);
3. create a matcher object that will match input string with the compiled regex
Matcher m = p.matcher(input);
4. check whether any matching found
if (m.find()) { //5. if found, the matched portion will be available at m.group() String found = m.group(); // do whatever u like }
let, input = "fjkl;pokjhA123ss456Apghkit"
u want to read block between 2 A's
regex = (?<=X).*?(?=X) where X = "A" here output = "123ss456" u can only use fixed length string in (?<=X), never use .*? or + in X otherwise u'll get exception
Look-behind group does not have an obvious maximum length near index ..
Java code for this:
1 2 String regularExp = "(?<=A).*?(?=A)"; 3 4 String input = "fjkl;pokjhA123ss456Apghkit"; 5 6 Pattern pattern = Pattern.compile(regularExp); 7 8 Matcher matcher = pattern.matcher(input); 9 10 if(matcher.find()) 11 { 12 String parsedData = matcher.group(); 13 System.out.println(" Output ->"+parsedData); 14 } 15