Tag Archive: programming

Black Swan Theatrical release posterI’m in the middle of watching Natalie Portman in Black Swan, a veritable work of art.  I have always loved Darren Aronofsky, and the way he can capture madness on film.  I am very happy to see him get the accolades and recognition he has gotten with this film.

At one point in the film, Portman’s character whispers, almost shamefully, “I just want to be perfect.”  A short while later, the ballet director points out the ease with which the character played by Mila Kunis dances.  He tells her that perfection is not just about technique, it is about letting go.  On a personal note, I am at this moment wearing a T-shirt that says “prefecionist.”  I have struggled with perfectionism much of my life, and it was fed early on by my getting perfect scores on standardized tests in high school.  My own perfectionism has resulted in my starting personal projects and not following through because I deemed them less than perfect.  This week as I design a website for darlynebaugh.com, I find myself lacking in ease while holding onto my ideas of perfection.

An example of this was an attempt to have the links to pages on the left menu highlighted so that the user knows where they are on the site.  I kept trying to change the code to make this happen, but I found that some other piece of code was overriding it.  I was able to make it so that I was able to change the background behind the link, but not the font color.  After attempting to find the answer I was looking for over the course of two hours, and trying different solutions, I was frustrated and no closer to the idea that I was stuck on, as to how it should look.  At some point, and I’m not sure exactly when or how I reached this point, I decided to just keep the background but change the color.  I said to myself it was good enough, but I was annoyed that I couldn’t figure out the answer to the problem.  As if I should know how to do something I had never had any experience with.  And that, to me, is madness.

It is certainly a good thing to strive for excellence, even perfection, perhaps, but not at the cost of ease and piece of mind.  In my experience, the thing striven for is never achieved in this way.


Google Maps, PHP, and Javascript

I decided to take on a Google Maps project, as Google Maps is one of my favorite apps.

In looking for data to Geocache, I came across the NYC Metro Intergroup website.  They have over a thousand meetings a week in NYC and its environs, yet their interface for finding a meeting leaves something to be desired.

There were quite a few obstacles, the first of which was scraping the data from the site itself.  I decided to start with the Manhattan meetings, of which there are about 750.  In order to scrape the data, I used the iMacros add-in for Firefox, and extracted to a CSV.  From there, I wrote some VBA code in Excel to parse the data into a workable form.

At first I decided to use a free mapping service called Click2Map, but the main problem with that was that it somehow, in the process of geocaching from Yahoo, placed half of the Manhattan meeting in Brooklyn.  It was also fairly primitive and slow, so I figured I would have a go at creating my own map using the Google Maps API, along with an excellent book from Apress called “Beginning Google Maps Applications with PHP and Ajax.”

I have a webserver hosted at GoDaddy under the domain michaelblaustein.com, but it was running IIS 6, with no PHP support.  After some poking around I discovered I could upgrade to IIS 7 which supported PHP 5.  I have been programming in VB for the past ten years, and am now out of a job, so I figured this would be a good opportunity to expand my skillset, using technologies that are a bit more widespread.  VBA doesn’t get much respect among programmers. although I have found it highly useful in the business world.

I had never really played with PHP before, except for a stint at a web marketing company and when I asked someone to code a shopping cart and he used PHP.  Still, I never really touched the code in either of those cases, and I was a little intimidated by the syntax.  I started with some examples from the Apress book, and the Google documentation (which is also quite good), and then came upon a way I could geocode all the addresses in the csv using the Google Geocoding API and some code examples.  I created a mySQL database on my server, used the phpMyAdmin tool provided by GoDaddy, created the table, and imported the data.  I wrote out the PHP to get the lattitude and longitude for these addresses, only to discover that PHP on my server was not able to request files.

A couple of calls to GoDaddy and some research showed me that the setting I needed was in the php.ini file, but I didn’t have access to it on the server.  I found out I could create my own and put it on the web root, but had no clue as to how to do so.  GoDaddy sent me a list of dlls in the extensions folder, and I found on the web someone elses php.ini.  Tried loading a couple of different versions of the ini only to break PHP.  Finally I discovered that running getinfo on my machine spelled out the current settings for me, so I went over the php.ini line by line trying to preserve the settings and making adjustments when needed.  I got it to work, but then it was timing out, so I edited the ini again.  Finally I had to edit the SQL in the PHP script a few times because it would only geocode about 150 records before giving me a 500 error.

I now have all the Manhattan meeting geocoded in a mySQL database on the server.  Next step is writing the Javascript to customize a map.  Once I get the map up on michaelblaustein.com, I also want to turn it into a mapplet, so that it can be found easily on Google.  Then I will submit my work to Metro Intergroup and see if they will give me access to the data on their web server so that I can avoid all this web page  scraping nonsense.  Then, perhaps, I can find some work doing this for a real estate company, or some such institution.

In the next few posts, I will go into a bit more detail about iMacros, the VBA code I wrote, the php.ini solution, and the specific php and javascript I wrote in order to geocode the data.