Archive for Programming
30th April, 2008 at 12:40 PM PDT · Filed under Code, PHP
Although you can use variables within strings in PHP, you can’t do functions. Well, not quite. If your function name begins with a dollar sign ($), it works fine. You can exploit this to call non-object functions such as htmlspecialchars.
<?php
$F = "F";
function F($s) { return $s; }
$filename = '<some code>';
echo "{$F(htmlspecialchars($filename))}";
It’s still not as clean as if you had separated application logic and presentation code like you should have. >:o
11th October, 2007 at 10:43 PM PDT · Filed under JavaScript, Software
My InvisionFree scripts have gone to Google Code! Updating the repository for me is a cinch, and server reliability is no longer an issue. In addition, there’s no more of that domain expiration business that plagued several forums over the last few days (with nasty advertisement redirects). I also took the time to update Quick Edit a bit, finally adding Safari support (took only two changed lines, too), and updated the design for the form. For those using an InvisionFree forum, I encourage you to go install the Quick Edit script immediately. Quick edit is so de facto nowadays, mainly because it’s so useful.

15th August, 2007 at 11:19 AM PDT · Filed under Code, JavaScript, Programming
CodePress and EditArea have become rising stars of the edit-code-in-your-browser scene, but which one fits your needs?

EditArea, hands down, has the features. There’s cut and paste, full block/line forward and backward tabbing, search and replace, smart tabs, and spaces as tabs. So what’s the catch? EditArea loses its charm when you become friends with its slow response time. A file with 500 lines is a no-no. EditArea aligns another layer over a TEXTAREA element to color code the text. The bottom line: go for EditArea if you want the features, sacrificing speed.

CodePress instead uses an IFRAME with edit mode enabled, giving CodePress the response time akin to a native text editor, but CodePress lacks many of the “vital” features. You won’t find smart tabs, spaces-as-tabs, tabbing blocks of code forward and backward, and the ability to paste cleanly to outside the editor. The bottom line: go for CodePress if you want to edit large files.
By the way, there are two more options: CodeArea 2 and Helene. The former uses the same mechanism as CodePress, but it has unfortunately fallen out of development. Helene was one of the first (if not the first) to edit code, but it does itline by line, so the interface is a little awkward.
20th January, 2007 at 12:34 PM PST · Filed under Actionscript
FileReference and FileReferenceList in Actionscript will cause a script timeout (or rather several script timeouts) with lengthy uploads. This is a problem because Flash is sometimes the only practical way to upload a large file with a progress bar (Java is fat, a memory hog, and is not as widespread as Flash). I managed to solve this “bug” by periodically calling a worthless function in Actionscript from JavaScript, successfully “tricking” the Actionscript engine to reset its timeout. I imagine it would work from within Actionscript too, but at the time I was working with a JavaScript< ->Actionscript JavaScript library.