Where I don't care what others think

Real Intelligence

April 19th, 2009 Posted in Life, Personal | No Comments »

I’ve been meaning to write a blog for the past few days, but I wanted to leave the PHP on Google’s App Engine post up top for a little while to help people find it.  Hopefully its been helpful to a few people.

Lately I’ve been watching Season 2 of Terminator: The Sarah Connor Chronicles and thinking a lot about computers, robots, etc.  I’m unsure if robots could just start slaughtering us tomorrow, but if they do I’d like to either be responsible for it or responsible for putting up a good counter attack.  None of this bystander stuff for me.

On a slightly more realizable route, I’ve been thinking a lot about what tends to be classified as “Artificial Intelligence” and the whole AI field.  One of my favorite topics, is cars that drives themselves.  If I didn’t have so much school work due this week, I would start working on this problem.  As I’ve read, a lot of the attempts out there deal with two pieces: 1) Teaching the computer how to drive a car and 2) Testing your car by having it navigate across the desert.

I think both of these ideas are pretty poor ways to approach the problem.  First off, why write a program that supports the ‘learning’ function of a vehicle?  Its far easier to write a program to emulate a human driver than to develop a program to facilitate the development of a human driver.  I think of the car that taught itself how to drive only to freeze up when approaching a bridge, because there was no green grass on the side of the road.  My limited understanding (reading an article a year or two ago) led me to believe the car determined that grass was important to have, something any of us with a brain know it untrue.  Any ‘manuallly programmed’ approach to the problem wouldn’t be freaked out by water, mulch, or leaves.. the road is what’s imporant!

Then there’s the issue of testing cars in the desert.  There is a large race thing in the desert each year where teams have their cars try to complete a course without any human interaction.  Cars have been getting better and better at it over the years, but its not a very realistic scenario.  Personally, I would be a bit freaked out if my Accord just started offroading it to get to the destination.  Yes, there are similiar obsticles in the desert and the highways of america, but the highways of america also have paved surfaces, gaurdrails, painted lines, curbs, etc.  As I see it the problem isn’t designing a program to best avoid a pothole, but to avoid other human-drive vehicles and kids running out into the road chasing those pesky balls.

I don’t think anything about driving a car is programmatically challenging.  Sure, there are a few minor computer vision issues to be solved here or there, but once the tools are available I don’t see it being terribly hard to pull off… at least a drivers-ed level computerized pilot.

Most people will just write off what I’m saying as the rambling of someone who doesn’t know what he’s talking about.  I encourage that, the less people expecting me to do anything the less likely I am to get complaints when things perform strangely.

A correlary to all this has been some thinking about intelligence, what it really means to be intelligent, and what it means to act human.  I think we do a lot of emulating, and very little actual intelligent things.  If we were all good at the intelligent part, there would be far more Einsteins in the world and far fewer telemarketers.  Not that telemarkets are dumb, they are quite good at emulating things.  From a young age we don’t ‘develop’ many new skills on our own.  None of us evented the concept of walking, talking, typing, or doing math.  We all saw someone else doing it, and figured we should copy them.  With enough practice we managed to figure out how to copy them suffecient enough to produce the desired result.  I guess we can ‘adapt’ in some sense… which is really the process of combining emulations to form something a bit different.  Its far less exciting to think of the magical learning process when you’re really just applying a fancy copycat algorithm.

No Comments »

PHP on Google App Engine

April 9th, 2009 Posted in Uncategorized | 28 Comments »

Warning:  I am not an expert on anything that I did here to make PHP work, nor am I likely following the best practices for doing something like this.  Experiment at your own risk.

I’m going to cut to the chase here.  If Ruby on Rails can run on Google’s App Engine (via JRuby) I figured that there is no reason why  PHP shouldn’t be able to work.  Of course I wasn’t interested in writing my own PHP interpreter in Java or something like, so I used Google to find Quercus.

Using the instructions to get JRuby working, as well this very useful guide about getting Groovy to work, I set off to piece together something for PHP using Quercus.  My biggest problem during this whole process was extracting the jar’s I needed.  For some reason, anything I downloaded from the quercus website wouldn’t extract correctly on my Mac or my PC… with the specific quercus.jar file being corrupt.  After dropping them into my war/WEB_INF/lib folder and starting my Web Application (I’m using Eclipse FYI) I would get errors about zip not being able to do its job.

Google helped me find a SVN repo out there that had the 3 jars I needed, and  after loading them into the correct folder. Eclipse stopped throwing errors.  If you’re looking for the files I used, you can find them here: http://lportal.svn.sourceforge.net/viewvc/lportal/portal/trunk/lib/development/.  I determined that quercus.jar, resin_util.jar, and script-10.jar were needed for Quercus to do its thing correctly… at least that’s what I think.  Drop them in the WEB_INF/lib folder and you should be all set.

Configuring PHP to work was surprisingly easy.  Edit web.xml to have the following lines:
<servlet>
<servlet-name>Quercus Servlet</servlet-name>
<servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
<init-param>
<param-name>ini-file</param-name>
<param-value>WEB-INF/php.ini</param-value>
</init-param>
</servlet>

…..and….
<servlet-mapping>
<servlet-name>Quercus Servlet</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>

I don’t know if any order is important here, but I put the php servlet first, followed by the default servlet, followed by the php servlet-mapping, followed by the default servlet-mapping.  By default I mean the one that was generated for me when they thought I wanted to use Java.

Next on the to-edit list was appengine-web.xml.  I can’t take credit for knowing to do this, I read it on purrrgatory’s twitter. I added the following lines, right after the close of the system-properties tag.
<static-files>
<exclude path="/*.php" />
</static-files>
<resource-files>
<include path="/**.php" />
</resource-files>

Looking back at that file I wonder if my exclude path is correct…. but hey its working.  I’m not going to complain.  I created a php.ini, which is completely blank at the moment, in war/WEB_INF.  I think I can put stuff here later.

The last step: write some PHP.  I through together the lamest test php file I could imagine, and saved it as war/index.php.

Initially when I tested this out I was getting a wierd error about org.mortbay.util.ajax.Continuation not being there.  I don’t know what that is, but its included in the jetty-util-6.1.0.jar file, which I found here.  I’m unsure if this is specific to the development platform (where I know jetty is used) or required somewhere in the Quercus mix.

Once in a blue moon, when I start the application up I get an error “java.lang.ClassNotFoundException: `org.mortbay.jetty.handler.ContextHandler’ not valid: java.lang.ClassNotFoundException: org.mortbay.jetty.handler.ContextHandler” but refreshing the page seems to clear that up.

I deployed to Google App Engine and everything worked perfectly! (http://txter.appspot.com/)

Of course I quickly remembered the JDBC wasn’t supported, so in turn the database wrappers that I could easily enable from Quercus weren’t going to work.  I’ll play around with this more, trying to figure out how to get it to interact with DataStore or something.

Here are some screenshots incase you’re as confused as I was when I started out with all this.

And I’ve uploaded my war directory, incase its of any help.

Best of luck!

— UPDATE 1 —

Initially, I was very wearsome of getting PHP to talk nicely with the datastore.  Doesn’t look like it will be too bad to sort out.  I’ll post a more detailed post about getting the datastore to work cleanly… maybe with a nice php or java wrapper class, but for now I’ve posted some sample code here .  The two .java files went in my source/projname/ directory, and the php file went with the other PHP files.

28 Comments »

Noisy Walking

April 1st, 2009 Posted in Personal, Stupid People | No Comments »

I drag my feet sometimes when I’m walking.  Not because I have poor fitting shoes or because I have a strange  stride.  Rather I drag my feet out of courtesy to others.

I walk fairly fast and pass a fairly large number of people each when I’m going places.  In crowded areas, like outside a school building or in a dining hall people are getting passed and changing directions left and right, and I really don’t need to anything special to let them know I’m approaching their flank.

Walking on Sherry Road down from BARH is a different story.  There usually only 2-3 other people walking on the same street… not a very densely populated route at all.  If I’m coming up one someone, maybe 20 feet away, I will drag a foot once or twice when taking a step.  Just enough to make a noticeable sound, but not enough to sound as if I just fell over like a moron.  The closer I get to passing someone, the frequency to which I drag my feet increases.  Right before passing someone I probably drag both feet at least once; so if they haven’t noticed I’m right behind them at this point they really should turn their ipod volume down.

An attentive person, aware that I am gaining on them, allows me to pass with little hassle.  Sometimes people slow down when I get closer to help me pass quicker, I don’t really care.  Others might glance over their shoulder to check if I’m carrying a knife or gun or something.  If the person I’m going to pass is really with-it, they will choose a side of the sidewalk to stay on, such that I don’t have to pass them on the grass or bordering lawn.

The problem really occurs when I don’t drag my feet.  For whatever reason I just don’t feel like giving my shoes the extra mileage, or maybe I’m in an extra hurry or something.  Lots of people freak out if you pass them, especially if you approach them rather silently.  I can count numerous expressions people have given me indicating some sense of shock and surprise.

Sometimes I want to wear a sign indicating that I am not here to assault, rape, or otherwise threaten anyone and I would really appreciate it if you didn’t look like you are considering stabbing me.  I try not to look super creepy most of the time too!

Here are some cases I see once or twice a week:

Passing Target: Girl

Course of Action: Drag my feet early and often.  Girl will turn around an average of 3 times to scope me out.  If the girl is on a phone or clearly distracted (potentially by another girl) I may cough moderately loudly.  Sometimes females respond by departing the sidewalk for the other side of the road.. problem solved.  Otherwise, upon getting within a reasonable distance girls tend to slow down to a really really slow speed.  Maybe they are saving their energy encase they need to sprint away from me… but I doubt it.  Sometimes girls stop walking and pretend to get a phone call.  I can usually tell when a phone call is real because the phone rings.  In either case, I keep walking as quickly as possible and avoid making eye contact.  Only looking to see if they are about to stab me in the side or attack me with pepper spray.

Passing Target: Football/Hockey/Player of sports that require people of the ‘large’ body build

Course of Action:  Ok, my goal here is to avoid triggering a potential knee-jerk reaction of being punched in the face.  I am less than confident with the notion of startling a {insert position here} and catching them off guard, so I will do my best to avoid that.  Apply similar strategies like when passing a girl.  I am less likely to cough here, as I don’t like leaving an impression that I am some sickly nerd and therefore increase my personal unpleasantness level.  Passing a larger target can be more delicate.  If I step off the sidewalk, I may be implying that they are wide/fat.  Staying on the sidewalk risks an awkward side brush.

Passing: Someone walking in the middle of a small sidewalk

Course of Action: Get behind them and start dragging my feet, hoping to signal to them that someone is right behind them and they should consider picking a side.  This approach rarely works.  Instead I have to pick up speed and traverse the terrain next to the sidewalk, which slows me down significantly.  Doing this triggers the person to switch to the far side of the sidewalk (furthest from where I crossed)… which is of no use to me since I already passed them!  Way to be aware of your surroundings.

Passing: Small/Tall/Scrawny Male much like myself

Course of Action:  It really depends on my mood.  On a good day, I’ll try inform them of my presence gently with a drag or two.  On a bad day I will blow right by them and they might jump or emit some “eek” sound effect (commonly a sharp inhale) when I pass them while thinking to myself why is this person walking so slow.  Clearly they aren’t enjoying a scenic stroll down the same road they’ve walked down for the last N days.  Picking up the pace is a valid exercise, which is useful to counteract the effects of sitting in front of a computer screen for many hours at a time.

Usually these strategies have to be applied to a larger degree at night, when people are more fearful of walking on a road who’s street lights turn on and off like blinking christmas lights.  Sometimes I’m on the phone and don’t have to apply these techniques, or sometimes I pretend to be on the phone just because.

No Comments »