coderjoe.net

Me, myself, and my code

GoGeocode PHP Library Release

| Comments

Over the past two months or so I’ve been playing with an old pet project of mine that I tend to peck away at when I can’t think of a better to work on.

As part of this project I found myself needing to do a massive amount of geocoding in PHP.

After searching through the various PHP based geocoding libraries online I came to notice that none of them seemed to make use of the APIs ability to return multiple points as well as informational data about each point.

Thus GoGeocode was born.

GoGeocode is an extremely small set of classes for use in querying both the Google and Yahoo geocoding APIs.

I’ve released the code under the MIT License and posted the code at http://code.google.com/p/gogeocode/

Take and enjoy!

Update: The GoGeocode page has been updated with a description, example use case, and a tar.gz archive of the gogeocode-0.1 release tag from SVN.

Road Runner High Speed Internet HTTP Redirecting All Invalid Domains Requested

| Comments

Advertisement filled domain search sites, once the domain of shady domain squatters, have shown up on Road Runner High Speed Internet for URLs of invalid domains.

Earlier this evening I decided to visit the website for a paint ball field in Syracuse NY. Looking for their address I tried to visit their site http://www.headrush.com. Unfortunately I mistyped and ended up at http://www.headrus.com. I was greeted with the site pictured below.

Road Runner Squatter Search Page Screenshot 1

FreeRice. Com and Automaton

| Comments

I had recently become aware of a website named FreeRice. com. This site provides a vocabulary game where one identifies synonyms for words with an ever increasing difficulty. Since I could always use a better vocabulary the site intrigued me. I played the game for a few hours but was in no way satisfied with my progress. At roughly one correct answer every two seconds I’d rank up 18,000 grains of rice an hour. Unfortunately, once I reached the higher levels I was averaging only 3 out of every 4 questions right.

While 13,500 (75% of my estimated optimal efficiency) grains of rice is a lot, it was nowhere near satisfactory. After joking about my “horrible rice metrics” at work, I mused that I should write a Greasemonkey script which would play the game better than I could possibly hope to. As the rest of my work day rolled on I became more and more intrigued by the idea. There was absolutely no reason why I couldn’t write a very simple AI to play the FreeRice.com game.

Were there reasons why I shouldn’t?

I knew the most obvious reason:

This wasn’t a controlled experiment. If the script spun out of control and was allowed to play over and over I could risk exhausting FreeRice.com’s funds.

Because I didn’t want to be responsible for the downfall of a potentially lucrative source of food for impoverished children I initially abandoned my bot. Despite my fears, curiosity eventually got the best of me and I began implementing my bot. I started by implementing a simple timing method limiting page requests to once every 10 seconds for debugging purposes, just in case.

More Fun With Greasemonkey

| Comments

The past month has been a difficult one. Between readying the apartment for winter, various chores, and social obligations, I’ve had little time for my own personal projects. Recently however I came across a few things that I just couldn’t pass up.

More fun with Experts Exchange

I was recently informed that my Unhide Experts Exchange Greasemonkey script had become obsolete. Reader nico5038 points out in a comment that Experts Exchange now hides all comments from users unless they’re logged in.

I would have been content to leave it at that until my friend Sean pointed out that Experts Exchange seems to be “cloaking” its answer pages. What this means is that when a search spider visits the site Experts-Exchange they will present a page that has all comments visible. However, if you or I go visit the site, the comments are hidden. This isn’t exactly the nicest thing to do on the web these days, so I’ve decided to write a new Experts-Exchange Greasemonkey script to fetch the hidden text from one of many different potential sources and replace the hidden text with the text that we should all be able to see.

Edit: They aren’t cloaking they’re just appending the comments to the end of their page. In any case grabbing a cached version of the page will help stave off any other awkward practices they use in the future.

I’ll update again tomorrow with the script once its been tested.

In the mean time enjoy a Happy Halloween!

Experts Exchange Part 2

| Comments

It would seem that Experts Exchange has changed their free access strategy. Where they would once display the normal solutions to a question hidden under a weak rot13 encryption, they have finally chosen to hide the articles all out unless one signs up for an account.

I for one welcome the change. Since it was their intention to only provide answers to registered users in the first place, moving away from obfuscated text helps clarify the site’s goals.

As a result of this site change I’ve been asked by a number of anonymous visitors to my site to rewrite my script to fetch the answers to an article so they don’t have to log in. I would like to make it clear that given the sites new design, that a script to display the answers is no longer possible. As such no effort will be put forth to do so.

Sorry to anybody who had their hopes up, but you can’t un-hide what isn’t there.

Continuations: What Is the Deal?

| Comments

Over the past few weeks I’ve noticed what I consider to be an interesting trend. It has become almost impossible for me to browse for technical reading on the internet, or partake in a technical discussion, without someone mentioning continuations. In general, I welcome any discussion, and discussion of continuations is no different. The implementation of continuations intrigues me, and I’m curious about how useful they will turn out to be. I’ve even been known to suggest that continuations could be used to make code smaller and easier to write.

With such a positive opinion about the potential use of continuations, it surprises my colleagues to learn that I am very wary of their actual use. I find myself asking, or being asked, the same question again and again.

What’s wrong with continuations?

Quite frankly, continuations remind me too much of the “GOTO” statement. Continuations, as with GOTOs, have their potential uses. However, I feel that the problems inherent in using continuations outweigh the benefits.

From what I’ve gathered from my individual conversations, continuations are useful in a numer of ways.

  • First, in generators.
  • Second, in the form of their close cousin, the closure.
  • Finally, for their use in arbitrary state management.

Their use as a part of generators is obvious, even if only made evident through the number of times the Python Fibonacci generator has been published as an example of the use of a continuation. Despite this, I don’t find myself creating and using generators in my every day code. Generators may be helpful, but using one seems like more of an occasional convenience than the rule.

Closures on the other hand are something I use every day. My job involves a fair amount of web application development which results in a good deal of Javascript development. I will openly admit that I would be lost without closures. Closures are invaluable when dealing with things such as binding execution to event handling. Without closures, some of the things I do might very well be impossible given Javascript’s event system design. Then again, Javascript was designed with closures in mind, so one could very well consider their use a moot point.

The use of continuations for state management may not be as apparent as the previous examples. For an example, one need only look as far as the Seaside web framework. Seaside is a continuation based web framework which takes the stance that one should “share as much state as possible”. In essence, the web framework itself keeps track of the sessions. These sessions are tied to a hash of continuations, each representing a state in the current application’s logical flow. The web application URL is not meaningful and contains little more than a reference ID to the current continuation. When you render a new page, a new continuation is generated and a reference to it is pushed into a hash somewhere for fetching later. That way if you hit the back button, going back to a previous page, the page will reference the previous continuation. When that continuation is used, your application flow would start from where you left off on that previous page.

All of a sudden the back button is useful!

Seaside has found an incredibly ingenious way to manage session state. At the same time, I believe it’s important to remember that while you gain automatic session state management, you lose some rather nice perks. The first thing I would miss while using Seaside would be meaningful URLs. In addition, your web framework is maintaining an ever increasing amount of state for each session. For some reason I get the feeling that this solution isn’t as great as it initially seemed.

With so many good examples, why be so wary of continuations?

It is true that there are many examples of continuations used for some very interesting, and often ingenious tasks. However, I still remember seeing GOTOs used in some of the most interesting and ingenious examples of code I have ever seen. For a proper example of the type of “ingenious” and “interesting” code I speak of, I refer you to “The Story of Mel”.

So Internet, I ask you, what is the deal? Are continuations just the current topic fad that they seem to be to me? Or are continuations something people are actually very excited about? Should I look forward to finding more examples of good continuation practice? Or will I soon be suggesting that programmers avoid both GOTOs and continuations because they encourage lazy or hard to manage code? Could their possibly be a happy medium?

Forgive me for remaining skeptical, but I just can’t shake the feeling that continuations aren’t the magical entity that people seem to keep telling me they are. I’ll leave it up to history (or the Internet) to decide…

Addendum: It would seem that Wikipedia already agrees with me that continuations are really just “the functional expression of the GOTO statement”.

Foxnight. Net Is Dead… Anybody Want It?

| Comments

Oh no! You killed it!

When I purchased my first domain I had a nifty idea for a particularly useful and exciting web application. It was to be the be-all and end-all of all my internet needs.

Then I realized that my idea sucked harder than a vacuum.

Since then the domain has been sitting around gathering dust, and generally wasting space. People have suggested that I sell the domain, but I’ve decided to just give it to the first person to  give me a good reason why it should be theirs.

How can I get it from you?

  • First, you need whatever the transfer costs for your registrar.
  • Second, you need a good reason why you should be the lucky one to own Foxnight. net.

Ok, so the reason doesn’t have to be amazing. Your reason just needs to beat the many “because I want it” reasons I’ve been receiving.

Want to do something good with the domain? Going to start a business? Want to own your first domain and think it sounds neat?

Let me know!

Contact me via my e-mail address at coderjoe[squiggily-a]coderjoe.net with your reason, and if I like it we’ll get the transfer process started.

I’ll leave this post up for as long as it takes to catch someones interest.  Once the domain has a new owner I’ll note it at the top of this post.

Experts Exchange Encryption

| Comments

NOTE: The methods listed below are no longer necessary! Experts Exchange has moved to providing the answers in plain text at the bottom of the page. Just look past the first set of “answers”, past the advertisements and link farm, and you’ll see them.

What is Experts Exchange?

If you’ve ever tried to look up some sort of technical information on the internet, you’ve likely come across the Experts Exchange. Experts Exchange is a site on which people can ask questions about a variably infinite number of technical topics and receive a range of answers from experts purported experts.

The site then allows the user to select a “best answer” earning the answer’s author extra points. Points can be redeemed for a better type of account and access to other things on the site.

In this way the site is user supported, without the experts there would be no exchange of answers.

What’s your problem with Experts Exchange?

As an incentive to sign up, the questions asked on experts exchange are visible to all, however, the answers are obscured in two rather tricky ways.

  1. The answers are obscured by a transparent gif with alternating pixels of solid and transparent, making the words a fuzzy haze.
  2. The answer text itself is encrypted using a basic and fairly famous encryption scheme called Rot13

As a person just looking for the answer to my question I’m often frustrated by the number of times I stumble across an experts exchange thread which might answer my question, but is obscured.

What are you going to do about it?

Well I hate to be bothered with unnecessary prompts to log in as much as the next guy. With that in mind, I present to you:

The Unhide Experts Exchange Greasemonkey Script

This script does what it says, it removes the image which blurs the answer text, and then Rot13 decrypts the answers for your viewing pleasure.

As the title implies, you will need to be using Firefox, and you will need the Greasemonkey plug-in to use this script.

Will this destroy Experts Exchange?

For those of you worried that this might just ruin the Experts Exchange, fear not. In their infinite wisdom they decided to completely omit the “selected answers” for the questions unless you’re logged in.

In this way there is still incentive to get an account and contribute!

In addition, I do not believe that my little Greasemonkey script will ever gain enough momentum to offset a significant portion of potential Experts Exchange visitors. If it ever did, all they would have to do is change their cypher or insert dummy text.

Any change to the cypher algorithm will be taken as a hint. (Also I’m way too lazy to implement anything other than rot13 instead of just logging in.)

However, if you’re as lazy as I (or rather as lazy as one needs to be to write a Greasemonkey script to avoid logging in…), and would prefer not to manage yet another user name and password combination, you may use the script above.

Note: The Greasemonkey script was updated on Sunday August 12th at 1:00am. It now properly takes care of the <br> characters that they do not rot13.

A List of Nintendo DS Homebrew Resources

| Comments

I was asked recently what resources I use as references while developing Nintendo DS homebrew.

As such I’ve decided to collect my favorite links in a single post for your enjoyment.  ( Please keep in mind that I am also new to the Ninendo DS development scene, and as such this post is by no means a complete list of all of the resources available to you. )

If you know of any killer resources that I’m missing please feel free to let me know and I’ll add them to the list.

 Hardware References:

Tutorials: 

Library References:

Communities:

That’s all I’ve got for now. If you feel I’m missing something important please let me know!

Code away.

Using Notepad++ With devkitARM and Libnds

| Comments

First follow the instructions for creating a template based project.

Once you have that set up you’re almost finished.

All you need to do is set up the relevant application binds so you can build your project from within Notepad++.

Unfortunately Notepad++ is not an IDE, as such it was not designed to compile applications. In order to do this we need a few helper scripts that Notepad++ can call to build and clean our project.

I’ve taken the liberty of creating a “build script” to help in this process.

Download the Notepad++ Project Build Helper Script file here and extract its contents to “c:\Program Files\Notepad++”.

Note: Extracting this archive will remove any existing NppExec scripts you already have defined! Merge the configuration files together if you wish to maintain your existing scripts.

Extracting the archive will set up two NppExec scripts called “Build Project” and “Clean Project”. These two scripts will build and clean the project respectively. In addition it will bind the NppExec run dialog to F8.

Now to compile your project just open a file in your projects source directory, hit F8, select “Build Project”, and click “Ok”

When you run the build script a command console will open in Notepad++ which will display the result of the build.

If there are any errors in the build the errors will be displayed in the console. Individual errors can be double clicked to jump to the line on which the error occurred.

You now have everything you need to develop in Notepad++.