Warning: include_once(/home/nullvoid/blog.mikezhang.com/wp-content/plugins/wordpress-support/wordpress-support.php): failed to open stream: Permission denied in /home/nullvoid/blog.mikezhang.com/wp-settings.php on line 217

Warning: include_once(): Failed opening '/home/nullvoid/blog.mikezhang.com/wp-content/plugins/wordpress-support/wordpress-support.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/nullvoid/blog.mikezhang.com/wp-settings.php on line 217
NullVoid » 2009 » August NullVoid » 2009 » August

Archive for August, 2009

BibTeX Title Capitalization (Uppercase) Tool

Wednesday, August 26th, 2009 -- By ET

I type my BiBTeX entries carefully, but different journals may have different requirements for capitalizing paper titles.

Some would like a plain format, like
Some, Author, 2009, “Capitalizing BibTeX titles: A simple tool,” Science, 110(1), 1-20.

Some Bibtex class files may automatically lowercase all words after the first, so the title looks like:
“Capitalizing bibtex titles: a simple tool,”

To make the title correct, we can add curly brackets, and change the title as:
“Capitalizing {B}ib{T}e{X} titles: {A} simple tool,”

This helps to address the issue, but what if a journal requires all first Characters to be capitalized? like this:
“Capitalizing BibTeX Titles: A Simple Tool,”

It is not hard to write a program to capitalize all words, but then there are complications, like the following case:
“Capitalizing BibTeX titles for Some Journals: A Simple and Intuitive Tool,”

In the above example, “for”, and “and” should not be capitalized.

In another example,
“Capitalizing BibTeX titles for Some Journals: Vote For a Solution,”

The second “For” should be capitalized, but “a” should not be capitalized.

So some intelligence is needed to convert the titles. That’s why I wrote this tool that correctly capitalize the titles.

The location of the tool is: http://blog.mikezhang.com/dcolumn/bibcapital.cgi.

There are some example entries in the box, just click “submit”, see how it works.

To process your file, simply copy and paste into and from this text box.

Again, this tool is offered as is. If you find it useful, that’s great. If you have problems with it, please talk to my friend Feng Zhu, he helped me to debug this tool, I’m going to hold him responsible for additional bugs.

A Complicated SQL Query

Monday, August 17th, 2009 -- By ET

Just wrote the most complicated SQL query I’ve ever encountered.  Since the table “clicks” has more than 5 million records, I’m going to wait till tomorrow to get the result.

The reason I have to write this is that I was trying to use a PERL program to do the same, and so far, after two days, it is still running with very slow progress.


create table sqlhistory as
SELECT a.inc, a.clicktime, (SELECT MAX(clicktime) FROM clicks b
where a.keyid=b.keyid and a.adid=b.adid and b.clicktime<a.clicktime
) as bctime, a.keyid, a.adid, a.bid, a.price, a.rank, a.reserve_price, a.reserve_price_new
FROM clicks a
where a.bid<>(select c.bid from clicks c
where a.keyid=c.keyid and a.adid=c.adid and c.clicktime=(SELECT MAX(clicktime) FROM clicks b
where a.keyid=b.keyid and a.adid=b.adid and b.clicktime<a.clicktime

)
limit 1
)

======Update====

Sun Wei suggested a new way to do it, and the productivity increased almost 1000 fold

1.

create table clickorder as
select * from clicks
order by keyid, adid, clicktime

2.

create an auto_increment field called ‘inc’, and a new field called lastbid

3.

update clickorder a, clickorder b
set a.lastbid=b.bid
where b.inc=a.inc-1 and a.keyid=b.keyid and a.adid=b.adid


BlogTimer
You are visitor number several since September 1, 2001

Copyright Xiaoquan (Michael) Zhang, 2004-2020. All rights reserved.
All trademarks property of their owners.