PHPMonkey? I wanted to use PHP to alter web pages and http traffic, so I downloaded many scripts that said they were PHP proxy. I didn't find any that really worked, they all just fetched the page, mangled all the links, and puked it back at me. I couldn't log in to any website, and if the site I was visiting used javascript to inject links, scripts, and all sorts of other dynamic content these so called proxies failed horribly. So, I figured I'd try writing one myself, and I've come up with something that works.
Autoindex for PHP Built in Web Server
Today, while working on the Atropa Toolbox, I wanted an autoindexing option for the PHP built in webserver like the Apache HTTP server has. By default the PHP server was giving me 404 errors whenever I would request a directory that didn't have an index.php file in it. The documentation said that the PHP command line web server would recognize index.html files but that didn't appear to be working for me. There wasn't a chance I was going to create hundreds of index.php files just to be able to navigate through directories on my server, so I wrote a router script to automatically generate a hyperlinked list of files and directories when I reach a folder that doesn't have an index.php or index.html file. The router recognizes index.html and will redirect the browser to it if present. While it isn't as fancy as the autoindexing options on the Apache server, it gets the job done. I can now click on the names of files and folders and make my way through the filesystem on the PHP commandline webserver. If you would like a copy of the router I'll post the code below. Any updates I make to this basic router will be incorporated into the Atropa Toolbox currently hosted on google code.
Unexpected 'in'. Compare with undefined, or use the hasOwnProperty method instead
Unexpected 'in'. Compare with undefined, or use the hasOwnProperty method instead.
Problem: JsLint Confusion
I don't understand why JsLint is giving me this error message: Unexpected 'in'. Compare with undefined, or use the hasOwnProperty method instead.
(see infix_in at http://www.jslint.com/msgs.html). The "in" operator seems to be very clearly defined. There appear to be only three outcomes for 'someProperty' in anObject which is one of: true, false, or a TypeError exception is thrown. When it evaluates to true, then there is definitely 'someProperty' in anObject. When it evaluates to false there is definitely not 'someProperty' in anObject. When a TypeError is thrown there is definitely not 'someProperty' in anObject because anObject is either null or it isn't an object at all. This all seems very clear to me. When I want to know if an object has a property and, I don't care if that property is the object's own property or being inherited and, I don't care what the value of the property is, then I simply look for 'someProperty' in anObject.
Closures in PHP
Closures in PHP
Have you ever wanted to generate functions on the fly with PHP like you can in JavaScript? Well, the short answer is that you can and it has everything to do with closures. I'll break it down briefly for you and then take you through an example, step by step, so you can see just how awesome "use" is in a function definition.
Closures Let You Define a Function that Defines a Function Using use
Batch File For Running JsDoc Toolkit
Batch File For Running JsDoc Toolkit
Just released today, I've written a batch file to automate running the JsDoc Toolkit
Set Default Values for Optional Function Parameters in JavaScript
Set Default Values for Optional Function Parameters in JavaScript
Setting the default value of an optional parameter in a JavaScript function is easy. Since it is perfectly acceptable to call a function in JavaScript with more or less parameters than the function was defined with, you may wish to define every acceptable parameter for your function and set a default value for the truly optional parameters. JavaScript does not have a way of explicitly defining an optional parameter because, it seems, by default all parameters are optional. So how do we find out whether a specific parameter was supplied and, in the case where it was not, set a default value for that specific parameter?