March 2010
3 posts
1 tag
CakePHP Visible URL Links Using Proper Routes
If you are every writing body content that requires you to mention a local URL then you are like to be tempted to write a very static, such as:
http://yourdomain.com/users/login
Instead it’s better to use CakePHP routes, just in case you change the URL structure of your site (ie, to use pretty urls, etc). So instead do something like this:
2 tags
Setting Timezone in CakePHP
When looking over my friend Tony Milne’s shoulder as he worked on his new blog built in CakePHP, we ran into the issue of our server being hosted in the US so comment timestamps were being given dates based on the current US date/time. To change the timezone CakePHP uses just place the following in your bootstrap.php
// place in app/config/bootstrap.php
// Australia Daylight Saving...
2 tags
Install & Uninstall MySQL - Ubuntu
Ran into an issue on with a VPS on Slicehost that I cloned the other day. The MySQL server wouldn’t start as it failed to find the mysqld.sock file (which appeared to be non-existent). I uninstalled MySQL, which was fine because we didn’t need any of the cloned databases and then just reinstalled it.
Install MySQL:
sudo aptitude install mysql-server mysql-client...
February 2010
2 posts
1 tag
JQuery Dialog - Lightbox Alternative
A project currently being developed needed a popup box similar to Lightbox or Fancybox but not for the purpose of displaying photos, video, slideshows, etc but to purely be used to render a page within a floating box - without all the bells and whistles. The solution has been Joel Moss’ Codaset Dialog. Its beauty is in its simplicity and clean widgetless design.
Tip: On line 180 we found...
1 tag
Embeded Video with "Video for Everybody"
Just wanted to point out this Video for Everybody site as a neat tool to have in your toolbelt. It basically provides a snippet of HTML that attempts to best show users video based on their system - with multiple fallback included depending on whether or not certain technologies are supported.
Worth checking out!
January 2010
12 posts
2 tags
Terminal Tip - Remove .svn Files
A quick way to remove all the annoying little .svn files recursively from a working copy. Its a bit of a hack way of doing a svn export.
find ./ -name ".svn" | xargs rm -Rf
2 tags
JavaScript "Syntactic Sugar"
I’ve just been glancing over this post about JavaScript syntax goodies (aka sugar) on StackOverflow. Two highlights were:
Defaults
I’ve been jealous of ruby having this method - php doesn’t have an equally succinct equivelant - however it appears Javascript does.
arg = arg || 'default'; // if arg evaluates to false, use 'default'
Object Membership Test
A nice, natural...
1 tag
CakePHP Sequence Behaviour
I’ve yet to use this CakePHP Sequence Behaviour but it seems like a solid solution for any model that you want to maintain an order to the records. The demo shows it being implemented with drag and drog.
1 tag
JQuery Plugin - HoverIntent
My coding partner in crime Tony Milne pointed me in the direction of the HoverIntent JQuery plugin today whilst we were attempting to delay the appearance of Tipsy (previously mentioned here) tooltips.
HoverIntent attempts to improve JQuery’s “hover” event by delaying the event until it appears the user is actually actively trying to hover on an item.
Extract from the...
1 tag
PostBin - Easily Debug Web Hooks
If you are doing any experimenting with web hooks, there’s a neat little site - http://www.postbin.org/ - that allows you to easily see what POST data is being sent from a web hook provider (ie, HookPress for WordPress).
2 tags
1 tag
Tipsy - JQuery Tooltip Plugin
I needed a quality tooltip plugin and after looking at a few I fortunately stumbled upon Tipsy (homepage & github). If you’re in the market for one, its worth checking out. Based on Facebook’s tooltips and used by Twitter, Github, plus others.
3 tags
Secure Google Apps Email Using SPF
Almost every domain I get my hands on I end up adding Google Apps as the email server/software. The other day I was setting up yet another installation when I stumbled across this helpful slicehost article about preventing email from your domain being forged and being treated as spam by other clients.
Googles own support page outlines that all you have to do is:
Add a new TXT record in your DNS...
2 tags
jQuery Cookie Plugin
Very easy implementation for interacting with browser cookies using jquery
$.cookie('the_cookie'); // get cookie
$.cookie('the_cookie', 'the_value'); // set cookie
$.cookie('the_cookie', 'the_value', { expires: 7 }); // set cookie with an expiration date seven days in the future
$.cookie('the_cookie', null); // delete cookie
Download
Demo (view the source to see example js code)
...
1 tag
Nginx Access Restriction
A detailed article about how to add basic access restriction on a website using an nginx web server. Use either the perl or ruby script mentioned here to generate an encrypted password.
1 tag
CakePHP Flash Messages
A method you can use to check whether there are flash messages to show:
$session->check('Message.flash')
An example of how you can use it to add custom DOM elements and JavaScript animation:
<?php if($session->check('Message.flash')) { ?>
<div id="flash-messages">
<?php $session->flash(); ?>
</div>
<script type="text/javascript"...