-
New Kohana 3 Resources
Posted on November 29th, 2010 No commentsKohana 3 is getting new fixes and upgrades every day. Here’s the latest batch of helpful new Kohana 3 resources on various topics.
From Mixu.net…
Kohana 3 Form Validation – validating form input (here’s another post on user input in Kohana 3)
Kohana 3 i18n – localization/internationalization
From Kerkness.ca…
Kohana 3 ORM – Object Relational Mapping
From DealTaker.com – now a 9 part Kohana 3 tutorial series
Kohana 3 Routing – Choosing the right action based on the request
From o1iver.net…
Kohana 3 Introduction – 3 part series
From elsewhere…
Migrating to Kohana 3 from Dupal in 2 weeks
Awesome explanation with diagram of (H)MVC
Seems more are coming out every day. Kohana 3 rocks.
-
JQuery Timer Opens ColorBox…Then Flash Displays on Top in IE
Posted on November 22nd, 2010 No commentsI’m in the process of adding a new feature to the home page of a client’s website. The desired functionality is best described as follows:
When visiting the home page, after a few moments, I want an overlay to appear, and inside the overlay will be a promotion to sign up for the website’s email newsletter.
A friend of mine (o3c) recently turned me onto ColorBox, from Colorpowered.com. Excellent stuff! I’m almost done implementing it, and ran into a few integration issues that I thought I’d share. For the record, I want to state that none of the issues I ran into are problems with ColorBox! The ColorBox code is rock-solid. No, as usual, the problems are with Flash content on the page, and particularly within Microsoft Internet Explorer. As usual, everything works fine in Firefox, Safari & Chrome.
So we have a couple of questions to answer. One is: How do you open ColorBox with a Timer? And the second is: How do you open a ColorBox over Flash in IE?
Timers are still done with “old school javascript.” The syntax is a little goofy, but it’s not specifically JQuery related. We’ll come back to that.
You have Flash on a page, and when your ColorBox appears on the page in IE, the Flash content underneath the overlay draws over top of the ColorBox overlay content, right? Contrary to how the rest of the world behaves (correctly), Adobe Flash (by default) draws last, which causes it to look like it’s on top of everything else. There are usually some easy fixes for that (most often, #3, below).
Still reading? Ok, let’s get down to it. Here’s some general troubleshooting tips before we begin.
- Make sure your page Validates. Use the validator.w3.org
- Depending on your usage, you may have to make IE8 behave like IE7… a.k.a. force IE7 compatibility mode
- Tell the Flash content to have the “wmode” parameter, and set the value to “transparent“
Now, you may have already tried all of these things. I did, and the Flash content was still showing on top of my ColorBox content.
So what’s a web developer to do. JQuery to the rescue. What we can do is hide the Flash content before the ColorBox appears, and turn it back on when the ColorBox goes away. It’s not a perfect solution, but it will hopefully work on all browsers so we can go about our day.
In looking at the ColorBox API/Documentation, they’ve provided two events that look to be very helpful to this type of situation. Scroll down to the bit about “Extending,” almost to the very bottom where it says “Event Hooks” and look for the following:
‘cbox_open’ triggers when ColorBox is first opened, but after a few key variable assignments take place.
‘cbox_closed’ triggers as the close method ends.The container on my page that contains the Flash content has an id=’img_accordian’. My first thought was to do something like:
$('#img_accordian').bind('cbox_open', function(){ $(this).hide(); }).bind('cbox_closed', function(){ $(this).show(); });but the above did not work! When I reloaded the page, it had no effect. No errors, but nothing happening. A quick Google search revealed this tidbit on the ColorBox Discussion Group on Google. So I just tried the more obvious…
$().bind('cbox_open', function(){ $('#img_accordian').hide(); }).bind('cbox_closed', function(){ $('#img_accordian').show(); });Boo-yah! Now I can move onto something much more fun. So much of my time wasted due to inadequacies of Internet Explorer. Sigh… such is life.
Whoops — not so fast — now that we have our signup form opening into a ColorBox iFrame, it shows every time we visit the home page. We want it only to show this pop-up-style signup form once during the user’s session. A cookie is the perfect place to store a simple “yes,” value, indicating that the user has seen the popup already.
Another Google search on JQuery Cookie found the JQuery Cookie plugin. To make use of this, we need to open the signup form ColorBox only if the user has not seen it already. Then if we open it, we can set the cookie that says they saw it, thus preventing it from showing again (until we clear cookies or the cookie expires.)
The two last features you’ll see in the code below are the finished timer, which I have set to open in 7.5 seconds. In testing, I may change it to 7, 6 or even 5 seconds. Also, I wanted a second “signup for e-news” link on the page in the footer that triggered the ColorBox overlay. So you’ll see in my code I created a custom object, “cbprops” to store the custom ColorBox configuration values, and then attached it to fire on the #signup_link.
Here’s the final completed code.
$(document).ready(function() { var cbprops = {opacity: 0.5, href:"/signup", width:"660px", height:"680px", iframe:true}; if($.cookie('viewed_signup')!='yes') { var timer = setTimeout(function(){ $.fn.colorbox(cbprops); }, 7500); } $("#signup_link").colorbox(cbprops); }).bind('cbox_open', function(){ $('#img_accordian').hide(); $.cookie('viewed_signup','yes') }).bind('cbox_closed', function(){ $('#img_accordian').show(); });There you have it, folks. We’re using a Javascript timer to open a ColorBox that hides Flash content in the background and setting a cookie so it only happens once. I hope you enjoyed reading — happy programming! Feel free to steal this code. If stealing doesn’t sit right with you, feel free to donate to JQuery or buy a 2011 Funny Pug Calendar!
-
Twitter API Snowflake and MySQL
Posted on November 13th, 2010 2 commentsI’ve been looking at APIs lately, and in particular, the Twitter API.
I managed to stumble into an advanced discussion on the Twitter developer forums about Twitter’s “Snowflake” update. One of the primary changes of the Snowflake update is the use of 64-bit integers for their ID.
As a PHP & MySQL developer interested in learning more about the Twitter API, I want my database schema to be optimized properly.
On this page of the MySQL website, it says, in part:
Some things you should be aware of with respect to
BIGINTcolumns:- All arithmetic is done using signed
BIGINTorDOUBLEvalues, so you should not use unsigned big integers larger than 9223372036854775807 (63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting aBIGINTvalue to aDOUBLE.
Does that mean I cannot use a BIGINT to store a Tweet’s primary key?
Surely VARCHAR(64) will be much slower…
- All arithmetic is done using signed
-
LVS-TUN How To on RackSpace Cloud
Posted on October 6th, 2010 No commentsI have to hand it to the sales/techs over at RackSpaceCoud.com.
After just a few minutes with their Online Chat Sales, I was intrigued enough to create an account. Heck, it was free, and would give me a chance to experiment with server configuration via one of the hot topics today – virtualization.
One of the first things I mentioned to Zack (I think that was his name) was that I was interested in making a more fault-tolerant web server setup. My client at the time had a dedicated server, but was planning on a few different television appearances, and didn’t want his site to go down with the surge of traffic.
Load Balancer How-To using Apache Mod_Proxy (Easy)
The RackSpaceCloud tech linked me to this article by Brandon Woodward on how to set up a simple load balancer using Apache. I followed that article to the letter, using one CentOS VM for the load balancer, and two CentOS VMs for web heads.
Well, I have to admit, it was not as difficult as I thought it would be. Now granted, it’s not super robust, but for a simple round-robin load balanced setup, it only took an hour or two to setup and configure, and it is still in place on the client’s domain. Not bad, considering it’s the equivalent of 3 servers for less than $50/mo.
Load Balancer How-To using LVS-TUN (Intermediate-Advanced)
Having found the RackSpaceCloud article on setting up a load balancer with Apache just a few months prior, I was interested in learning more when I saw this new article by the same author on installing and configuring LVS-TUN.
I was intrigued, because even though I believe having a mod_proxy-based load balancer solution on 3 servers in the cloud is preferrable in many ways to a single server with no load balancer at all, I could still see some areas for improvement and wondered what else was out there.
Woodward explains it like this:
LVS-TUN is a tunneling load balancer solution that will take all incoming requests through the load balancer and forward the packet to the web nodes. The web nodes will then respond directly to the client without having to proxy through the Load Balancer. This type of solution can allow for geo-load balancing, but will more importantly allow a customer use the bandwidth pool available from all web nodes, instead of relying on the limited through put of the load balancer.
In other words, whereas the mod_proxy-based load balancer is quick and easy to set up and manage, the load balancer itself is a single point of failure, since it is acting as a proxy for the two web heads behind it. LVS-TUN on the other hand, enables the load balancer itself to be distributed, and also takes advantage of the web heads serving content directly back to the client.
Whether you’re looking at a load balanced setup for scalability or just your own hardware architecture experimentation, without a doubt, the cloud is the best playground.
-
How To Do A Domain Name Registrar Transfer
Posted on July 26th, 2010 No commentsTransferring your domain name from one registrar to another can be a giant pain in the rump. The process is a bit error prone and rather confusing, mainly because every domain name registrar has a different process and different interface. Plus, it is in each registrars interest to the make the Transfer Out process as cryptic and illogical as possible, since if it fails at any step along the way, they’ll retain ownership of the registry and possibly get another annual rebill out of you.
In this tutorial we will be moving domains…
From: Dotster.com (the Old Registrar, Current Registrar, or Outbound Registrar)
To: GoDaddy.com (the New Registrar, or Inbound Registrar)Don’t get me wrong – both GoDaddy and Dotster are terrific Registrars. There’s no hard feelings here, I’m just consolidating accounts to GoDaddy to save a little money and take advantage of their TotalDNS service, which usually costs extra at other registrars.
Note that if you are transferring from or to different domain name registrars, your process will be similar overall, but the sample screenshots and link names will obviously be different for you.
Overview
The registrar transfer process hinges on a basic email verification process. In a nutshell, the new registrar sends Email #1 (containing a Transaction ID and a Security Code) to the administrative contact on file at the current registrar. You login to the current registrar and generate an Authorization Code, which is sent via Email #2 to the administrative contact on file. Assuming your email is on file as the administrative contact, you’ll receive these two emails within a few minutes. You then login to your account at the new registrar, and initiate the transfer process by entering the transfer Transaction ID & Security Code, and finally, the authorization Code from the current registrar. Once all 3 codes have been entered, your domain should be migrated to the new registrar within 72 hours.
The Process
Before you begin, login to your current registrar and update your domain name contacts. The critical contact record you will want to update is the administrative contact. Domain Registrar Transfers are accomplished by emailing the administrative contact email address. If you cannot access the email account listed and need to make updates, do this step 24 hours prior to initiating the registrar transfer.
- At GoDaddy, purchase your domain name as a transfer registration. GoDaddy also has a nice interface to do bulk transfers, but – trust me on this – do domain transfers one at a time or it gets extremely confusing.

- At GoDaddy, login to your account, and go to My Account -> Domains -> Pending Transfers

- At GoDaddy, on the Pending Transfers page in the domain management area, click on the domain you want to work with. If you’re transferring multiple domains at once, you can see the status of each domain’s transfer process here.

- At GoDaddy, click the Reinitiate button. This poorly-labeled button is the one that actually sends the Transaction ID and Security Code email to the Administrative Contact on file at the current registrar.

- Now create a new browser tab and login to your domain management account at your current registrar. In my case this is Dotster.
- At Dotster, unlock your domain for transfers at the current registrar. This is done on the main account list screen by checking the domain, picking ‘Unlock these domains – to allow transfers’ from the dropdown, and clicking the Manage Domains button.

- Once Dotster says OK – Unlocked, go back to the domain management page and scroll to the bottom. Click the link that says ‘Request Authorization Code’

- Next, check your email. If you’re not the administrative contact on the domain you’re trying to transfer, have the person who is forward you any emails they receive from GoDaddy or Dotster.
- You will receive Email #1 from GoDaddy. It is from transfers@godaddy.com and lists the Domain Name, the Transaction ID and a Security Code.

- You will receive Email #2 from Dotster. It is from auto@dotster.com. It contains your Domain Transfer Authorization Code.

- Go Back to your GoDaddy account and prepare to initiate the transfer. You’ll need the Transaction ID, Security Code (from GoDaddy) and Authorization Code (from Dotster) handy.
- At GoDaddy, check the checkbox next to the domain listed under Pending Transfers, and click the black Authorize button, and pick ‘Begin Transfer Authorization’ from the dropdown underneath it.

- Enter the Transaction ID and Security Code (from Email #1) and click Next.

- On the confirmation page with your domain name shown, pick the Authorize button and click Next.

- On the Authorization page, paste the Authorization Code (from Email #2) and click Finish. Click OK to the final confirmation.

- Now, just wait 72 hours and you should be good to go with your domains at GoDaddy. Note, you’ll receive at least one additional email (a transfer notification courtesy) from GoDaddy, during this process. You can ignore this email as it has no information pertinent to the actual process.
- After a few days, log in to your GoDaddy account and re-visit the Pending Domain Transfers page. Once all the approval codes have been entered & registered (steps 1 – 15 above) you’ll need to finalize the transfer in the GoDaddy interface.
- At GoDaddy, purchase your domain name as a transfer registration. GoDaddy also has a nice interface to do bulk transfers, but – trust me on this – do domain transfers one at a time or it gets extremely confusing.
-
Read Free Book Online: Thinking In Java
Posted on July 21st, 2010 No comments -
What is ORM and why should you use it?
Posted on May 11th, 2010 2 commentsI’ve been asking myself this question a bit more lately so I wanted to find some answers. Nowadays, ORM typically stands for Object Relational Mapping, and less commonly, Object Role Modeling, although the two concepts are related. Mainly I am curious about some of the new ORM implementations for Kohana 3, namely Sprig (based on Django) and Jelly.
The first page on this topic can be found over at Stack Overflow.
On the StackOverflow page is a link to this post by Glenn Block on the MSDN blog. I found it a bit surprising that this particular post hadn’t been voted on by any other Stack Overflow members as I found it an insightful and succinct explanation of why you might want to consider using ORM.
I noticed another topic that comes up in relation to ORM is DM, the Domain Model pattern, and DDD, Domain Driven Design. I thought this post entitled DDD – why bother? was an interesting take with a terrific example illustrating the benefits of an ORM system.
This post was inspired by Koes.
-
Dreamweaver slows me down too
Posted on January 12th, 2010 No commentsThis blog is great. Tons of people expressing the same thing I’ve been feeling lately… Dreamweaver is just slow.
I recently switched from Dreamweaver CS3 on Windows (running under Bootcamp on a Macbook Pro) to Dreamweaver CS4 running under Snow Leopard. I also upgraded from 2GB to 4GB of RAM. Dreamweaver CS4 is almost unusable in Design mode, on longer documents. Maybe I have to run disk utility or something, but sheesh.
I’ve enjoyed using Dreamweaver for many years, but why is it that as computers get faster and faster, Adobe software gets slower and slower?
As I’ve pointed out before, Adobe makes some of the most expensive software out there. Why doesn’t it work better?
-
Kohana 3 PHP Development Resources
Posted on December 31st, 2009 No commentsHere is the most current Kohana 3 Documentation.
Here is the Kohana 3 API.
Here is the Kohana 3 Unofficial Wiki.
Here is a link to all posts tagged with KO3 in the KohanaPHP Forums.
Here is a search result for KO3 Models. Models represent the ‘M’ in the MVC software design pattern. Chances are your Models will use a Database backend. Here’s the KO3 Database tutorial.
Here’s a great tutorial on using Views with Kohana 3. Views represent the ‘V’ in the MVC software design pattern. Update: Now there’s 8 Great Kohana 3 Tutorials at DealTaker.
Here is a search result for KO3 Controllers. Controllers represent the ‘C’ in the MVC software design pattern. In order to decide what Controller (and Action) to run, you need to use KO3 Routing.
Once you get the hang of things, you’ll find this KO3 Cheat Sheet comes in very handy, as does this Git Cheat Sheet!
-
Git for Subversion Users
Posted on December 23rd, 2009 No commentsI just spent a few hours reading up on Git, and have to admit I saw the light. One of the coolest features of Git is that it is distributed and provides an easy way to have a repository made up of smaller sub-repositories (called submodules in Git). Try that with SVN! Why does this matter? What’s so cool about Git? you may be wondering… Well, because the Kohana 3.0 source code is stored in several Git repositories, you can easily checkout the source to a local working copy, including only the modules you want, and also build your application in a local Git repository.
All of the following links are really helpfu.
Git for Subversion users, Part 1: Getting started




