Saturday, 10 August 2013

How can i search records in a large table efficiently?

How can i search records in a large table efficiently?

I have a table(product) with 5.4 million recods. If i'm using below query
to get result but it's working very slow. Is there a more efficient
approach?
SELECT sd.imageid, sd.licencetype, sd.imgcollection, sd.orientation,
sd.pname, sd.pcaption, sd.ptype
FROM (SELECT imageid
FROM product
WHERE productkeyword IN (SELECT primary_kwd
FROM searchkwdmgmt
WHERE allkwd IN ( 'IPhone' ))
GROUP BY imageid
HAVING Count(*) = 1
LIMIT 0, 31) q
JOIN searchdetails sd
ON sd.imageid = q.imageid

How to add an extra URL mapping for an servlet that already mapped in Eclipse IDE 4.2?

How to add an extra URL mapping for an servlet that already mapped in
Eclipse IDE 4.2?

I want to add an extra URL mapping to my we application in Eclipse. Since
the eclipse IDE not using web.xml as deployment descriptor , I don't know
how to do this.
That is , the servlet LogServlet was already mapped as /LogServlet , but I
have need to add an extra mapping as /tamil/LogServlet .
Since web.xml not used as deployment descriptor in Eclipse , I don't know
how to do this .
Please help me in this issue.
(Project created in Dynamic Web Module 3.0 in Java EE 6[jdk 7] )
2) Please guide me how to create the web.xml file which contains all
deployment info on it.( that "Generate deployment descriptor stub" not
generating servlet mappings , only welcome pages tags )

proving an isomorphism of two open sets (Hartshorne Corollary I 4.5)

proving an isomorphism of two open sets (Hartshorne Corollary I 4.5)

Let $X,Y$ be birational varieties and $\phi: X \rightarrow Y, \psi: Y
\rightarrow X$ mutually inverse rational dominant maps. Let $\phi$ be
represented by $(U,\phi_U)$ and $\psi$ by $(V,\psi_V)$. Then Hartshorne in
Corollary I 4.5 says that the open sets $\phi_U^{-1}(\psi_V^{-1}(U))
\subset U$ and $\psi_V^{-1}(\phi_U^{-1}(V)) \subset V$ are isomorphic via
$\phi$ and $\psi$ respectively.
I am wondering if he means that they are isomorphic as topological spaces
or as varieties. Moreover, how can we actually see this isomorphism? It
seems to me a little bit confusing. Here is the closest i got:
$\phi_U(\phi_U^{-1}(\psi_V^{-1}(U)) \subset \psi_V^{-1}(U) =
\psi_V^{-1}(\phi_U^{-1}(Y)) = \psi_V^{-1}(\phi_U^{-1}(V))^c$, where $^c$
denotes closure.

Friday, 9 August 2013

Blocking request in Chrome

Blocking request in Chrome

I'm trying to block some requests in a Chrome app.
I created a JavaScript listener that does this validation:
chrome.webRequest.onBeforeRequest.addListener(
{
urls: ["*://site.com/test/*"]
},
["blocking"]
);
But the requests are not blocking. Did I miss something in this code?
My manifest:
"background": {
"scripts": ["listener.js"],
"persistent": true
},
"permissions": ["tabs", "http://*/*"],
"manifest_version": 2,

Java Mail with Attachment-Attachment file location not found

Java Mail with Attachment-Attachment file location not found

My code for sending email without attachment works fine. But when I try to
send an email wth attachment, I am getting an error message
'C:\Temp\test.txt (The system cannot find the file specified)' The code is
below: '
package com.ceridian.test;
import java.util.Properties;
import javax.mail.*;
import javax.activation.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
public class TestJavaMail {
/**
* @param args
*/
public static void main(String[] args) {
final String username = "from@gmail.com";
final String password = "xxxx";
Properties props = new Properties();
props.put("mail.smtp.auth", true);
props.put("mail.smtp.starttls.enable", true);
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication
getPasswordAuthentication() {
return new PasswordAuthentication(username,
password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("manojvtp@gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("mvarghese@speech-soft.com"));
message.setSubject("Testing Subject 1");
message.setText("PFA");
//
Transport.send("manojvtp@gmail.com","mvarghese@speech-soft.com",
"Hi Kamran, how is going?" , ")");
MimeBodyPart messageBodyPart = new MimeBodyPart();
Multipart multipart = new MimeMultipart();
messageBodyPart = new MimeBodyPart();
String file = "C:/Temp/test.txt";
// String fileName = "test.txt";
DataSource source = new FileDataSource(file);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(fileName);
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
System.out.println("Sending");
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
e.printStackTrace();
}
}
}
Do I need to set any ClassPATH or anything else to get the file attachment
working?
Thanks

Split List into Sublist using Linq based on content of list

Split List into Sublist using Linq based on content of list

This is similar, but not quite what is being asked in this question
I have a list that I want to break into sublists, but the break occurs
based on the content of an entry and not a fixed size.
Original List = [ split,1,split,2,2,split,3,3,3 ]
becomes [split,1], [split,2,2], [split,3,3,3] or [1], [2,2], [3,3,3]

Bootstrap controls inline alignment?

Bootstrap controls inline alignment?

Other than hacking margins how can I get the following button to display
inline with same height as the select in the following code (instead it's
dropped down on top margin)?
BootPly -> http://www.bootply.com/73169#
<div>
<h4 class="ilLabel">Select:</h4>
<select class="form-control" placeholder=".input-medium" height>
<option value="all">Default</option>
<option value="s1">Select1</option>
<option value="s2">Select2</option>
<option value="s2">Select3</option>
</select>
<button type="submit" class="btn btn-primary
btn-small">Submit</button>