Leland USA

Saturday, May 28, 2011

Defeat NYTimes Paywall with GlimmerBlocker

There are a variety of methods to defeat the NYTimes paywall using bookmarklets. But if you're super lazy and don't want to do that extra click, you can block the script file that loads the overlay. Use GlimmerBlocker and create a new filter. The file is

http://graphics8.nytimes.com/js/gwy.js


One great thing about this method is once you create the filter, it works on all your installed browsers. More laziness.

Tuesday, February 14, 2006

I was working on a project where we want to integrate google maps into a form page to induce people to enter their address information. We basically want the map to update dynamically as the person is entering their information. Integrating google maps is rather simple. Just sign up for an account with google and follow the instructions. However google generate maps based on longitude and latitude coordinates, so it's necessary for us to be able to get those coordinates as the user is typing.

There are plenty of free services out there that will do this for you, but after trying a few , we found all of them to be pretty slow. We realized we need the database of addresses and their coordinates on our local server. Here's how we did it. Many thanks to Dan Egnor (winner of the 2002 Google programming contest)

You can get an address database from US Department of Census and build an index yourself. But since we're lazy, we just downloaded a prebuilt index from Dan Egnor's website http://dan.egnor.name/google.html Unarchive it and save it in your cgi-bin folder.
From Dan Egnor's website, you can also download the files need to build the executables that will query the index. You can go through the files and build everything according to the README to see how everything works. You can basically use the files as is if you know what you're doing.

We, however, want to modify Dan Egnor's program so we don't have to do too much parsing later on. Open up the geo-client.c file in your favorite editor and replace the main function with the following

int main(int argc,char *argv[]) {
struct io_file *index;
index = io_open("all-map");
struct geo_location loc;
if (!geo_find(index, argv[1],strlen(argv[1]),&loc))
printf("");
else {
printf("%.8g,%.8g\n",loc.at.longitude,loc.at.latitude);
}

return;
}

Once you save, do make clean. Then make. Test everything out by typeing in something like ./geo-client "4910 Michoud Blvd. New Orleans, LA 70129" on the command line. You should see the longtitude and latitude coordinates.

If everything works, copy all the executables to your cgi-bin folder. Now you need to create a cgi file to interface between the geo-client and your website. We modified Dan Egnor's query.cgi file to the following

#!/usr/bin/python
# Copyright 2002 Daniel Egnor. See LICENSE file.
#
# This is a simple CGI script which invokes 'idx-client' to provide a
# Web interface to the geo-search functionality. It outputs
# references to MapBlast to draw maps of query results.
#
# Many many thanks to Tessa Lau for help with Python!

import cgi, sys, string, re, os

# EDIT THIS PATHS
source_dir = '/var/www/cgi-bin/'
# END EDIT

client_exe = source_dir + 'geo-client'
print "Content-Type: text/html\n\n"

form = cgi.FieldStorage()
if (form.has_key('a')):
address = '"'+form["a"].value+'"'
cmd = string.join([client_exe, address], ' ')

fp = os.popen(cmd, 'r')
results = fp.read()
print results
else:
print ''

Test out query.cgi with your browser by passing it a query string ?a=Your_Address_Here.

If everything works, you're ready to integrate this with javascript and have some ajax action on your website. You can probably go from here, but if not, check out this excellent totorial http://ejohn.org/projects/gaddress/

You can download scripts from John Resig. Just don't use his cgi script. Used the one you just made.

Tuesday, May 18, 2004

Hotbar and DSO exploit

i've ben working on a PC installed with XP Home. There is something on it that exploit the DSO exploit in Internet Explorer. I can find it with Spybot Search and Destroy but I can't seem to get rid of it. Every time I use Spybot, the problem goes away and I can launch Internet Explorer. But if i reboot the computer, I can't launch IE. If I run Spybot again, the DSO is found again. Strange. I tried turning off System Restore and updating everything but no luck. As long as the computer is on, IE works fine.

Also I can't get rid of the Hotbar folder in c:\program files. Launching IE will always create the folder.

Any help is appreciated.

Tuesday, May 11, 2004

Sasser Worm and spyware

Yesterday I helped a friend fixed her computer, which was infected with the Sasser Worm. No problem, except that her computer also had a ton of spyware. What happened was that the spyware was using up so much system resources that there was really no way to update Windows fast enough before the Sasser worm shut down the system. And I couldn't get rid of the spyware first either.

If this happens to you, boot up in safe mode, update Windows, get rid of spyware with Ad aware or something similar. Reboot normally.

Monday, May 10, 2004

Welcome to Leland USA

This blog is about everything Leland