Red Hyphen

According to Twitter, Eli Fox-Epstein
Warning: file_get_contents(http://twitter.com/statuses/user_timeline/elitheeli.xml) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in /home/redhyphen/public_html/index.php on line 4

Eli is busy with Drupal, Java, C, PHP, Python, Ruby, and concurrency.

Eli likes ping pong, Standard ML of New Jersey, naan, the syntax of Javascript, Canon cameras, collaboration, Chopin, chop sticks, hiking sticks, mountain biking, plantains, and power plants.

He aspires to write a Verilog to Javascript compiler.

Contact Eli by emailing

Lots of sources say that PHP is inherently bad with Comet. It's designed for quick responses, not persistent connections. Still, I find this to be a lot snappier than constant polling. Using memcached instead of MySQL makes the code simpler and probably slightly faster.

So, let's make a cool AJAX group chat application. It's going to be brandable and have some basic validation. First, the server-side bit. Then we'll make a user interface. I decided to make this object-oriented. Here is the Chat class. The two most important functions are:

As you can see, there's a "chats_num" field that stores the number of messages in this instance. And then, for each chatmsg_0 to chatmsg_n, a message is stored with that key.

The Comet is done in the while loop on line 4. In English, it says, "while the number of messages is less than or equal to the last one reported as received by the user, and we haven't exceeded the poll duration, then do nothing." There's a half-second delay between each check to save some CPU cycles. For speedier chats, though, this could be reduced.

There's a very simple controller for the application. It needs no explanation.

So, to access this, an AJAX request has to specify the "act" parameter as either "post" or "poll". The remaining PHP and the Javascript isn't very exciting. You can download and explore it here, but most of it could be radically different, depending on the use case and design styles.

For the most part, it's very straightforward. There's no indication that this uses Comet. If the server were to deliver a snappy response, polling would occur every half a second. However, we configured the PHP to take up to 50 seconds to respond.

A demo is coming soon. I also plan to investigate whether using an array to store all the chats is faster than using a separate memcache entry for each message.

In a future release, expect to see more robustness. This, however, was just a proof of concept. Enjoy.

Fractal generation is usually done in very quick languages like C. They take scores of iterations per pixel and millions of calculations in total. It's obvious that Javascript and fractals don't belong together. After all, Javascript is incredibly slow (although that's changing).

So, let's start with the Mandelbrot set. Here was my initial implementation of the function mandelbrot, which is called on often over a certain subset of the complex plane.

It works, too, at least in Firefox. Here's some functions to drive it:

Obviously, its speed is much lower than that of a compiled language. Still, I think that it is pretty groovy. Also, I'm almost done with an optimized version and a few other fractals.

Make fractals!

Privacy is something we are losing every day as more and more information becomes available on the Internet. While I'm in favor of easy access to aggregated statistics and useful, interconnected websites, I also know that every supposedly secure system eventually gets broken into.

When you sign up for something, ask yourself why giving a company a piece of information will help you. If it won't help you, you should not be forced to give it.

I particularly enjoy cryptography problems. They present interesting mental puzzles that I can actually use on a day-to-day basis as I work with databases, user logins, and personal information.

Food is incredibly important to me. I have a cooking team. More elaboration to come. The gist of it is that we're trying to cook food from every country.