Skip to main content

Posts

Showing posts from 2008

Paste Ninja Goes Multilingual

Chris Cornutt was nice enough to give Paste Ninja (the premier PHP-powered pastebin app) some exposure by highlighting it on PHPDeveloper.org a week or so ago. Thanks, Chris! As a result of the extra publicity, the site saw an increase in traffic as people came to check it out. I hope they liked what they saw... but stay tuned, because there's more features to come!

It was interesting to look through the access logs afterward. There are a lot of pastebins available on the Internet, but the feature set and usability of the application is what will help differentiate it from the rest. The list of countries from which various people visited and the values of their browser's Language-Accept headers peeked my interest, and I realized that I needed to offer Paste Ninja's interface in multiple languages so people could use my service in whichever language they may find the most comfortable. So, Paste Ninja is now multilingual!

The goal is to translate PasteNinja's inte…

PHP != Perl

People irk me when they expect PHP to behave like <insert your favorite language here>. Most recently, I ran across this blog entry Perl vs PHP: Variable Scoping via the help of PHPDeveloper.org. I'm sure Leonid is a great fellow and really smart... but he just happened to trip my irk-wire.

The post is an innocent enough "here's a problem that I ran into, so I'll blog it in case someone else has the same issue." Reading between the lines though, I get the feeling his underlying belief is that because PHP and Perl are similar that they should have the same variable scoping rules, and that since PHP's doesn't correspond to Perl's that PHP is wrong and this should be documented as such.

Each language is different. If PHP were so similar to Perl, it wouldn't be called PHP... it'd be called Perl. Or maybe a dialect, like PHPerl. I really wish people would stop comparing the two. Quite frankly, I don't see much similarity between th…

JavaScript Keyboard Widget

Have you ever done something stupid just so you don't have to do whatever it is you're supposed to be doing because you feel like procrastinating?  I found myself doing that this evening by programming a keyboard widget in JavaScript.
Right now it's just sloppy code without any real functionality, but feel free to take a look at it at  http://www.saltcitytech.com/projects/keyboard.
Theoretically, one could add a couple of state variables to monitor the ctrl, shift, alt and caps lock keys, check those variables in the keys' onclick callback, and have a fully functional keyboard widget.  Since the key characters are defined in a mapping object, it should be relatively easy to internationalize it just by changing the mapping definitions.
I may clean up the code in the future depending if someone actually sees a viable use for it or if I find myself needing to procrastinate again.

Dialog and Paste Ninja

I'd like to share with everyone two projects that I've been working on in what little spare time I've had lately-- Dialog and Paste Ninja.

Dialog
Dialog is a lightweight JavaScript-based dialog window. Why does the world need another dialog widget, you ask? It probably doesn't, but I couldn't find a freely available one that was as flexible as I wanted so I wrote my own. Flexibility and portability were key design features, so Dialog is written completely in JavaScript and CSS, and its appearance is fully CSS driven.

Dialog supports multiple dialog types by default, such as confirmation, information, warning, and error, and can further be customized with a custom dialog type. It can even display modal dialogs and block input to the page until the prompt is dismissed!

You can learn more about it and get the code at its project page, http://www.saltcitytech.com/projects/dialog from my JavaScript Experiments repository at GitHub.



Paste Ninja
Paste Ninja is a pastebin ap…

Choosing an Assignment Operator

If you were to write your own programming language (as I still intend to do someday even if only for the learning experience it provides me), what symbol (or symbols) would you use to represent the assignment operator?

Even though it would looks like BNF or old-school Pascal, I would lean towards using := as the assignment operator. That would leave me free to use = for equality and there wouldn't be the issue of = vs. == tripping up new programmers. Besides, performing assignments is more common than making comparisons, so perhaps assignment should have the more distinct operator. Going one step further, if the language I wrote was not strongly typed, I would use == as the identity operator (as like PHP's ===). := and = to == seems a more logical progression to me than = and == to ===.

I suspect I wouldn't use = as both assignment and comparison as Basic does because of the ambiguity it causes. For example:
x = y = 0Does this mean "assign 0 to both x and y",…

JavaScript Frameworks Suck

There's been an interesting discussion off and on around the office this past couple of weeks about JavaScript frameworks, specifically which framework is the best so we can standardize on one. Of course I have to be difficult... my answer is none of them.

As a general rule of thumb, "frameworks are evil." There are exceptions, but frameworks seem to cause a lot of unnecessary bloat, make tasks difficult to accomplish if they fall outside the intended scope of the framework, create obstacles to efficient debugging, and adversely affect page load times causing the application to appear slow and sluggish. The real question ought not be what framework is best, but rather be what exactly are you trying to accomplish with client-side scripting in the first place.

Creating a rich user experience with standard JavaScript is not difficult. Many of the niceties the frameworks provide aren't magic... for example, $() is just function(x) document.getElementById(x);}. And AJAX i…