Flast

I’m excited to announce the official release of Flast! (my very first open source project!)

For those of you who don’t know (everyone), Flast is an open source framework for PHP version 5.3.  It is focused on performance (fast) and removing restrictions on developers (flexible).

You can check out Flast here: http://sourceforge.net/projects/flast

Your feedback is much appreciated.

Here’s a little history about why I decided to create Flast…..

While working on DealsPlus and Sazze, we evaluated many PHP frameworks, but decided to create our own because they were all to slow and/or forced us to use a particular coding methodology (i.e. MVC).  After successfully creating a very useful framework that actually improves performance, I wanted to give back to the open  source community by using my experience (and the awesome new features in PHP 5.3) to create a framework that gives the developer complete control over performance and functionality.

Right now, Flast is in a very early pre-Alpha phase, but it should be useful by the time a production ready PHP 5.3 is released.

PHP Memcached Manager

We’ve been using memcached on both our sites for a while now to help alleviate database load and speed things up in general.

However, we’ve been lacking a good web-based manager to see the cache status and manually clear the cache.  (I’ve been doing this via telnet on the command line and have been to busy to write my own script…..)

Today, I stumbled accross this gem: http://livebookmark.net/journal/2008/05/21/memcachephp-stats-like-apcphp/

It’s a simple GUI for memcached that is written in PHP and was exactly what I was looking for!

DealsPlus is out of Beta!

In case you couldn’t read the title…….DealsPlus is out of beta!

Check it out: http://dealspl.us/

A lot of hard work has gone into this and we’re all really excited about it.

One of the cool new things is the addistion of DP Tools.

DP Tools allows webmasters to add a plus button to their pages so that their users can add their pages to DealsPlus without leaving their site.  Very cool!  (and suspiciously similar to the digg button ;)

Here’s a working example (click the plus):



There’s also a much cooler button that shows the number of times your page has been plus’d, but it uses javascript and wordpress keeps deleting the script tags from my post……

Cloud Computing: wispy thoughts

With Citrix releasing their XenServer hypervisor as a free product with virtually no limitations, my thoughts have turned to implementing our own private cloud in our data center.

Just now? yep, cloud computing as a service has been around for a while and marketed to death (in my opinion).  It has big players like Amazon and Google, but it has never been a viable option (and won’t be for a while).  Any serious web2.0 company knows that one of the keys to success is to minimize downtime, and using a cloud service takes control of your uptime away from you.  Granted, not all startups are able to run their own data center, but I don’t think it’s a coincidence that every big name web site runs its own data center(s).  Think about it.  How do you guarantee uptime when you have no control over a critical service?

Anyway, the idea of the cloud is very interesting.  To have a utility like service that allows you to tap computing power without caring about individual servers is almost like computing nirvana.  And the thing that makes it practical?  With Citrix’s move to a free offering, this type of cloud can be easily (and cheaply!) deployed in your own environment that you control (at least according to Citrix).

I can see it now……..web server instances being provisioned and deprovisioned in response to demand, server instances migrating to functioning nodes in response to hardware failures (eliminating service down time), performing hardware maintenance during business hours without affecting services…….whoah there, I think I might be drooling

I really, really want to start trying this out as I’m begining to wrap my mind around a rough idea of how this would integrate into and ultimately transform our environment.  It’s like that vauge shape at the edge of your vision that you know is there, but if you look at it it slips away.  Ah well, I know it will come if I just have a little patience.  In the mean time…….back to my dream

Javascript: Timer object

So, yesterday I was working on the UI for our category menus and needed a delay before displaying the menus.

Basically, I wanted to only show the dropdown menus if the user pauses the cursor over the menu in question.  To do this, I needed a timer object that I could start when the user first places the cursor over the menu title and cancel if they move on to quickly.

If you’ve ever used the setTimeout() and clearTimeout() functions that Javascript provides, you know that they don’t always work as advertised.  Especially when many are called very rapidly (as in the case of the user moving the cursor from one side of the screen to the other).  Using just these functions gave us some weird behavior (i.e. menus displaying when they shouldn’t).

To solve the problems we encountered, I created a timer object (sorely lacking in Javascript) that tracks its state so that it more reliably executes and cancels.

Below is the code for the object (requires prototype):

var timer = function(delay, callback){
    this.isRunning = false;
    this.hndl = null;
    this.delay = 0;
    this.callback = null;

    this.start = function(){
        if(!this.isRunning){
            this.hndl = setTimeout(this.callBackFunc.bind(this), this.delay);
            this.isRunning = true;
        }
    };

    this.stop = function(){
        if(this.isRunning){
            clearTimeout(this.hndl);
            this.hndl = null;
            this.isRunning = false;
        }
    };

    this.setDelay = function(d){
        this.delay = d * 1000;
    };

    this.setCallback = function(c){
        this.callback = c;
    };

    this.callBackFunc = function(){
        if(this.isRunning){
            this.isRunning = false;
            this.hndl = null;
            eval(this.callback);
        }
    };

    this.setCallback(callback);
    this.setDelay(delay);
};

You use it by creating a new instance of timer and calling the instance’s start() method for every action you want to delay.

Below are Parameter descriptions:

  • delay: how long to wait before running the callback code (in seconds)
  • callback: a string of Javascript code to execute after the delay

Example:

    <div onmouseover="myTimer = new timer(0.5, 'myfunction(5, 6, 7)'); myTimer.start();" onmouseout="if(myTimer){myTimer.stop();}">
        Some content
    </div>

The above code will start the timer when the user places the mouse over the div and cancel the action if the user moves the mouse out of the div before the timer has fired.

DealsPlus Redesign: Sneak Peak

We have been working hard on a complete redesign of our flagship website DealsPlus for the last few months.

I’m happy to say that we are very, very close of officially launching the new version of the site and I’d like to invite the few readers I have to check out the new design before everyone else!

Feel special?  You should! ;)

You can check it out at: http://new.dealspl.us/

If you want to provide feedback, please do so by commenting on this post.

Javascript: Copy Text to Clipboard – Not anymore

In a previous post (Javascript: Copy Text to Clipboard), I described a method for using Javascript to copy text to a user’s clipboard.

Unfortunately, this method no longer works.  It relied on flash allowing script access to the user’s clipboard, and (with the release of flash 10) that is no longer the case.

Flash 10 requires that a user’s action originate in flash in order to gain access to the clipboard.  This means that IE is now the only browser that can access the clipboard from Javascript.  So unless IE is the only browser you care about, you’re out of luck using Javascript to access the clipboard. :(

The solution?  Write a flash application to handle copying data to the user’s clipboard.

Lesson Learned: Beware the Middleman

We’ve been purchasing colocation service for our servers for the past year from Advanced Colocation (a reseller).

At the time, we were on a tight budget for both time and money, so we picked them as our service provider because they gave us the best price for 24/7/365 service on a rack with a 100mbps connection to the internet with unlimited bandwidth.

Turns out that the 24/7/365 service is not provided by Advanced Colocation, but by the service provider whose services they are reselling (in our case, Hurricane Electric).  Though Advanced Colocation has no problem letting you think they provide 24/7/365 service.  In fact, they use that as a selling point.

Getting any kind of support from Advanced Colocation is a nightmare.  If you call them, you get voicemail.  If you leave a voicemail asking them to call you, they won’t call you, they’ll email you (a few days later…..).  If you email them, you may, or may not, get a response.

Anyone with any experience running mission critical services can tell you that this type of support just doesn’t cut it.

Getting support from Hurricane Electric, on the other hand, was great.  The support staff at Hurricane Electric bent over backwards to assist us in any way they could, but at certain points their hands were tied because they needed information/action from Advanced Colocation (their customer).

Case in point:

We have an IP address block that we were given for our use.  This IP address block was given to us by Advanced Colocation.  Who, in turn, gets it from Hurricane Electric (who has no idea who Advanced Colocation gives it to).

Recently we experienced 5 days of downtime because Advanced Colocation gave our IP address block to another customer……..can you believe this?!

To compound the problem, it took 4 days just to get in contact with anyone at Advanced Colocation!

And when I finally did get a hold of someone, they were just like, “sorry, our mistake, but you’ll have to wait for the other customer to stop using the IP address block….”

Just disgusting!

Hurricane Electric, on the other hand, had been trying very, very hard to help me with the problem, but couldn’t because it was an issue with our reseller.  If we’d been purchasing directly from Hurricane Electric, not only do I think that this problem never would have happened, but (if it did happen) it would have been fixed immediately, not 5 days later….

The solution:

To me, there was only one solution: dump Advanced Colocation and purchase service directly from Hurricane Electric.

That’s what we’re doing now and Hurricane Electric’s service and support has been wonderful!

Advanced Colocation?  They are giving us problems canceling our contract.  Surprise, surprise.

They want us to pay an extra month of service and be grateful that they don’t make us pay for an extra year of service (which is the term of the contract).  Never mind the fact that they broke the contract when they GAVE OUR SERVICE TO ANOTHER CUSTOMER!  This is not a piece of networking hardware failing or other service interruption.  This is taking our internet connection and giving it to another customer.  Service outage?  No.  Failure to provide the agreed upon service? Yes.

Sorry, had to let my rant out….

The bottom line:

When purchasing service from a reseller (or middleman) you need to make sure that their service and support matches your needs (not just the originator’s service and support).

Advanced Colocation is not a quality service provider (or even a reputable one) and should be avoided at all cost…….unless you like companies that jerk you around and expect you to thank them for it.

In my opinion, it’s always better to purchase service directly from the  service originator (if possible) rather than a middleman or reseller.  It will be a better experience.

For my part?  Lesson Learned!

PHP Alternative Syntax

So, I was having a discussion with a fellow developer at work today about the advantages of using PHP’s alternative syntax (details here).

Just so we know where everyone’s coming from, I come from a programming background and my colleage comes from a design background.

Anyway, he came to me asking my opinion on using the alternative syntax in scripts where we have a lot of HTML markup mixed in with the PHP code.  His reasons for wanting to do this?  The same as most proponents for using the alternative syntax…….it’s shorter and is easier to read.

Now I try to be impartial when making coding decisions because, let’s face it, our opinions do not affect how the machines execute our code.  It’s a travesty, but it’s true.  However, I just don’t agree that alternative syntax makes code shorter or easier to read.

Wait, wait.   Give me a chance to demonstrate my reasoning before you condem me.

Let’s look at some example code using the alternative syntax:

<p>What a niffty paragraph</p>
<?php if($a == $b): ?>
<p>Only the cool people see this!</p>
<?php endif; ?>
<p>Wow, aren't paragraphs great?</p>

Now, you might say, “this is super awesome. it’s so easy to see where the if block ends and there’s no separate lines for the PHP start and stop tags.”

However, you can do the same thing with less typing in the normal syntax.

Here’s the same code using the normal syntax:

<p>What a niffty paragraph</p>
<?php if($a == $b){ ?>
<p>Only the cool people see this!</p>
<?php } ?>
<p>Wow, aren't paragraphs great?</p>

As you can see, the normal syntax is shorter than the alternative syntax.  The number of lines are the same, but the number of characters is less.  Multiply this character difference by the number of times you use if, while, for, and switch in your script and you have a noticeably larger script file when using alternative syntax.  Which means?  Yep, it takes longer to execute scripts that use the alternative syntax than scripts that use the normal syntax.  Is this execution time difference big enough to matter?  Well, that’s a personal question that each script owner must answer for themselves.

And as for the readability aspect, any developer that is worth their salt uses an editor that highlights or otherwise shows matching braces.  Want to know where the other one is?  Just click on the one your curious about and the editor will show you the other one.

It is my experience that code is hard to read because the person who wrote it did  not format it properly.

Anyway, that’s just my opinion.  I’m sure everyone else has their own.  Please feel free to discuss.  Who knows, maybe you’ll change my mind ;)

Happy Holidays!

Wishing you and your families a safe and happy holiday season.

Happy Holidays!

Next Page »