Ideas and Code

mercoledì 12 maggio 2010

buzzbox google gadget (test)

venerdì 26 febbraio 2010

Tweet about a Story with buzzbox

The tweet button on buzzbox is pretty nice because with 1 click you get:

- the title of the story
- the source name
- the short url (using bzbx.us - buzzbox's shortening service)
- the most important topics (this is kind of unique, as far as I know)

Everything is formatted so it will fit in a tweet. For example:


Google Enhances Local Search With "Nearby" Filter [techcrunch] http://bzbx.us/S32 #Filter #Google


We could also include the buzzrank or other sources writing about the same story... we are experimenting about that.
What do you think? Do you find it useful?

martedì 23 febbraio 2010

Best Daily Video from Youtube

I like the way I was able to use BuzzBox to use the data provided by Fast Forward to show the feed of the best videos from youtube, constantly updated. A great channel to check out when you are bored and want to have some fun watching videos.

Popular YouTube Videos Feed

mercoledì 13 gennaio 2010

Spring Jdbc and no transaction

You don't need transaction? Are you using Spring Jdbc (SimpleJdbcTemplate)?
If you enable profileSQL in the jdbc connection url you will notice that all your queries are sorrounded by other 2 queries:

1. SET autocommit=1

2. YOUR QUERY

3. SET autocommit=1

You don't need 1 and 3 with you are not working with transaction. They are very fast to execute but they require network communication with your DB (and you don't want that!)

You can fix that adding to your connection URL:

elideSetAutoCommits=true
useLocalSessionState=true

in my case:

jdbc:mysql://localhost:3306/myDb?connectTimeout=4000&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&profileSql=false&elideSetAutoCommits=true&useLocalSessionState=true

In my case I'm working on Mysql ISAM tables.


Similarly, I had an annoying SHOW WARNINGS query after every query. It went away when I upgraded Spring from 2.5.4 to 2.5.6
I'm using mysql connector for Java 5.1.10

lunedì 5 ottobre 2009

JTidy errors to Log4j

By default JTidy logs all the errors on the standard output, kind of an old fashion way of doing logging. So I spent some time to integrate it with log4j to clean up my standard output.

First, you need a PrintWriter as a bridge from JTidy to Log4j:

public class Log4jPrintWriter extends PrintWriter {
Priority level;
Category cat;
StringBuffer text = new StringBuffer("");

public Log4jPrintWriter(org.apache.log4j.Category cat, org.apache.log4j.Priority level) {
super(System.err); // PrintWriter doesn't have default constructor.
this.level =level;
this.cat = cat;
}

// overrides all the print and println methods for 'print' it to the constructor's Category
public void close(){
flush();
}
public void flush(){
if (!text.toString().equals("")){
cat.log(level,text.toString());
text.setLength(0);
}
}
public void print(boolean b){
text.append(b);
}

public void print(char c){
text.append(c);
}
public void print(char[] s){
text.append(s);
}
public void print(double d){
text.append(d);
}
public void print(float f){
text.append(f);
}
public void print(int i){
text.append(i);
}
public void print(long l){
text.append(l);
}
public void print(Object obj){
text.append(obj);
}
public void print(String s){
text.append(s);
}
public void println(){
if (!text.toString().equals("")){
cat.log(level,text.toString());
text.setLength(0);
}
}
public void println(boolean x){
text.append(x);
cat.log(level,text.toString());
text.setLength(0);
}
public void println(char x){
text.append(x);
cat.log(level,text.toString());
text.setLength(0);
}
public void println(char[] x){
text.append(x);
cat.log(level,text.toString());
text.setLength(0);
}
public void println(double x){
text.append(x);
cat.log(level,text.toString());
text.setLength(0);
}
public void println(float x){
text.append(x);
cat.log(level,text.toString());
text.setLength(0);
}
public void println(int x){
text.append(x);
cat.log(level,text.toString());
text.setLength(0);
}
public void println(long x){
text.append(x);
cat.log(level,text.toString());
text.setLength(0);
}
public void println(Object x){
text.append(x);
cat.log(level,text.toString());
text.setLength(0);
}
public void println(String x){
text.append(x);
cat.log(level,text.toString());
text.setLength(0);
}
}

Thanks to JD Evora for this.

Then, declare your Logger and your PrintWriter

private static Logger log = Logger.getLogger(HtmlProcessor.class);
private static Log4jPrintWriter log4j = new Log4jPrintWriter(log, Level.DEBUG);


And finally, make JTidy work with it:


InputStream pageStream =  new ByteArrayInputStream(html.getBytes("UTF-8"));
Tidy tidy = new Tidy();

tidy.setOnlyErrors(true); //<------------------

tidy.setInputEncoding("UTF-8");
tidy.setOutputEncoding("UTF-8");
tidy.setQuiet(true);
tidy.setShowWarnings(false);
tidy.setErrout(log4j);
dom = tidy.parseDOM(pageStream, null);
dom.normalize();
...


Enjoy your clean catalina.out!

giovedì 24 settembre 2009

My Personalized Tech News

I've been working on BuzzBox for a while, so I feel now confortable now to share the first links to it.
I'm currently using BuzzBox to read the most popular tech news every day.
News from BuzzBox are:
- personalized: I picked my favourite web sites
- filtered: I get only the most popular news every day
- clustered: so I don't get the same news twice

I like to describe this first stage as a "personalized techmeme" (techmeme is an tech news aggregator).

You can see My BuzzBox at My BuzzBox



I've put the RSS in my Feed Reader, and I consume the news there. Others are pushing thier News from BuzzBox to Twitter. See for example http://twitter.com/anigamBuzzBox or Anu's tech BuzzBox

We have a long roadmap ahead. We want to bring personalized news to social networks, we want to be a preferred place to share and comment about news with your friends and everybody else.

Check out the site and let me know what you think.

domenica 20 settembre 2009

A video blog on App Engine

I'm working on this basic idea: an automatic video blog created from a search on youtube.

I like following the interviews of the David Letterman Show on youtube but it's quite difficult to subscribe to a good RSS for that. A simple query returns old and new results and many duplicate videos. Some interviews are partials, other are of bad quality. So I start building a filtering engine, using the Google Data Api.

I started the project on Google App Engine, on the Java environment.
It's still pretty basic, but you can already see the results:

http://videovertigo.appspot.com/letterman/

I start with the query:
"+letterman 2009|09 -monologue -"top 10" -"top ten""

Then I look in the title and in the description for a Date. The parsing is performed by Antlr (thanks to Piercarlo for implementing this part).
Then I assign a rank to each keyword, based on their frequency in the result set.

Finally I try to cluster the videos that look similar, based on keywords and date.

I'm still playing with the clustering to make it as general as possible. I would like users to build thier own video blog from a complex query, using tools like information extraction and clustering.

In the home page there is a simple search functionality you can use to play with the engine: http://videovertigo.appspot.com/

What do you think? Any idea how to improve the product? Are you an engineer and you would you like to contribute? Please contact me!