July 10th, 2008
Instant message has become a part of my daily life. I use it pretty much non stop for work, and my work involves writing a lot of code. It isn’t uncommon for me to send something like
if ($a=($b+$c))
I like iChat (Adium of course is the old favourite, but hasn’t been used much since I moved to Leopard and Apple improved iChat so much), but sometimes it’s too cute for its own good. This is especially true of the “helpful” way it converts :) and ;) into
and
respectively. Helpful in the same way that Clippy was helpful.
This behaviour gets very annoying when one is trying to look at code. The above code example becomes
. You can image how annoying this is when every third line of chat is code. So I went hunting through the iChat preferences to find a little box I could uncheck and turn off smileys, only there was no box to be found.
A quick trip through google didn’t turn up too much either, but I was able to figure out where iChat kept its preferences for that. A minute later, I had figured out a way to turn them off. Here’s how:
Browse to /Applications/iChat.app, and “Show Package Contents”.
Next up, browse into Contents/Resources/English.lproj and look for a file called SmileyTable.plist. This is where all the smiley definitions are stored. Without it, iChat can’t translate smiles, so rename it to “SmileyTable.plist.banished”. If you ever want smileys back, just reverse the process!
There, that feels better
Continue reading “Turning off smileys in iChat 4”. Posted in
How-To, Mac with 4 comments 
April 13th, 2008
So, I just spent the last hour getting a screencast built to show how you can start using ExpressionEngine on your site now, even if you don’t “know” ExpressinEngine yet. Good times. Used Screenflow, had a sexy little video thing going… and then realized that I recorded the blasted thing nearly fullscreen on my computer (it’s a 24inch iMac). I tried to scale it down so that it would fit onto 1 screen for most people, but then so much detail got lost that it looked like crap.
How frustrating.
So I’ll re-build it at some point in the near future, and for now, you can admire all my hard work in static, useless, image form ;)
Continue reading “failed screencast”. Posted in
ExpressionEngine, How-To with 11 comments 
November 21st, 2007
If you’ve been following the CodeIgniter community, then you’ll know that some time ago, we made an subversion (SVN) repository available. Subversion is a version control system that we use internally to be sure we’re all working from the same page. The SVN is publicly available, and is committed to by 4 of the fine folks at EllisLab. I’ve referred to it before, but I’ve never really talked about how to use it. Recently, there’s been some people interested in getting the latest and greatest CodeIgniter changes pre-release - and heck, why not, as there’s some fine work in there. This post will talk about how you can use the SVN to keep up with the latest CodeIgniter changes.
First of all, the standard disclaimer: we make great efforts to be sure that the code in the repository is bug free and functioning, but as is the case with all “bleeding edge” releases, from time to time things may slip in there, so I don’t recommend you use it in a “mission critical” environment.
So, how to use it? If you are a Mac user, there are 2 pretty nice graphical interfaces. SCPlugin gets the most attention, but I really like SVNX.
In windows? Go for Tortoise SVN. Integrates with Windows Explorer and has probably the most intuitive interface I’ve ever worked with. In any event, pick a client ;)
Now create a folder on your computer somewhere, and rightclick to set up a new repository. As your destination, choose “http://dev.ellislab.com/svn/CodeIgniter/trunk” which is where we keep our stuff. Now your goto command is “update” and “show log”. Update gets you the latest files, and “log” let’s you see what changed. Here’s an example of the log file from today.
Notice that most times when we check something in we make a comment? Sometimes a change is so minor that we don’t bother, but in general it’ll help you stay on top of what is new in the repository.
Changes tend to come in fits and spurts. You might see nothing for two weeks, and then a dozen changes in two days. In general, anything particularly noteworthy will be discussed here (on this blog), so you don’t need to check it every day, but you might want to keep an eye on future changes yourself.
Welcome to the cutting edge! ;)
Continue reading “Checking CodeIgniter out of the Subversion Repository”. Posted in
CodeIgniter, How-To with 16 comments 
November 16th, 2007
A few days ago, I wrote about the release of ExpressionEngine 1.6.1. In it, I highlighted the “live look” feature, as a great new addition. Live look allows you to preview a post within a template, rather than previewing only isolated content. So you can see what your content will look like inside your template. This is great if you have a future entry, or a post that you are leaving “closed” until you have a chance to finish it up.
But there has been a bit of confusion about how live look should work. Essentially, all it does is load your entry into a template, so if you have a future dated entry, or a closed entry, it won’t be visible by default. The solution? Create a “preview” template, and take advantage of the status and show_future_entries parameters. Essentially, make it look like this
{exp:weblog:entries weblog="default_site" status="open|closed" show_future_entries="yes"}
I’d further recommend that you take advantage of Template Access Restriction in your preview template. Without it, anyone who guesses your preview template will be able to see upcoming or closed content. Probably a good idea to restrict it to the same member groups as your authors.
Happy ExpressionEngineering!
Continue reading “Setting up “Live Look” in ExpressionEngine”. Posted in
ExpressionEngine, How-To with 2 comments 
August 14th, 2007
A recent CodeIgniter bug report had got me looking into the depths of the database results functions of the framework. Essentially, the orderby() function of CI’s Active Record says that you can sort by ASC (ascending), DESC (descending) or RAND(). Imagine this:
$query = "SELECT * FROM table ORDER BY RAND()";
Anyone familiar with PHP probably looks and that and thinks of the native PHP rand() function. This is pretty neat actually, and I’d never really thought about randomly ordering things. But on further investigation, it became clear that this code wasn’t as nice as it initially seemed. Firstly, its non-standard SQL, reducing its portability greatly. While MySQL uses RAND(), other databases have their own way of doing things:
- MySQL uses ORDER BY RAND()
- PostgreSQL uses ORDER BY RANDOM()
- Oracle uses a subquery with ORDER BY dbms_random.value
- SQL Server users ORDER BY NEWID()
So then, how would one randomly order their database results? Read on for my solution…
Continue reading “Ordering Database results by “random” in CodeIgniter”. Posted in
CodeIgniter, How-To, PHP with 12 comments 
August 12th, 2007
CodeIgniter is one of the most flexible, powerful, unobtrusive frameworks you could choose to use. It’s so useful in many ways, including pre-existing convenience libraries (I can’t live without the email library anymore), plugins (for handy little tools such as javascript calendars and CAPTCHA creation) and the appropriately named “helpers”.
In the world of CodeIgniter libraries, plugins and helpers, the libraries are Rock Stars. They get most of your attention, they do most of the heavy lifting. They date super-models, party in Europe, and return on Monday to keep your application humming along (sometimes Tuesday… you know those darned unreliable rock stars). They can be extended, overwritten, and you can create your own, wholly new libraries just for your application. Wow. No wonder super-models want to date them.
One of the most handy aspects of libraries, is that you can create a libraries folder in system/application/libraries, and leave the existing CodeIgniter libraries untouched. This makes upgrading to newer versions of CI a breeze, as you never need to worry about going in and re-implementing all the changes you made to a library. From the userguide:
As an added bonus, CodeIgniter permits your libraries to extend native classes if you simply need to add some functionality to an existing library. Or you can even replace native libraries just by placing identically named versions in your application/libraries folder.
And while libraries are doing all this work, we’re left with the humble, but infinitely handy helper. Here’s what the userguide has to say about helpers.
Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular category.
Makes them sound like one-trick ponies; but they are not. Helpers, while not quite as flexible as libraries, are tremendously useful. They are written procedurally, instead of object oriented (as the rest of CodeIgniter is). And while they can’t be extended as libraries can, a little known fact is that they can be overwritten. Better yet, is the method in which you’d override them. Much like libraries, the trick lies in creating a folder underneath system/application for helpers. Then, when CodeIgniter loads helpers, it looks first in your application/helpers folder, and only if that folder can’t be found does it then fall back on the default system/helpers folder. So you can add your own helpers, or overwrite existing ones.
Here’s a case study. In BambooInvoice I use the date helper’s timespan() function to determine exactly how overdue an invoice might be. My problem is that the default timespan() function keeps tabs down to the second of the span of time. When tracking invoices, I don’t care how many hours, minutes and seconds have passed, only how many days and weeks (or months if you have a really bad-paying client ;)) So for use in Bamboo, I want that helpers default output changed. The solution, to remove or comment out those lines of the helper.
But the problem with modifying the system helper is that in the next upgrade, that helper gets overwritten again. Since I use BambooInvoice as part of my testing codebase for vetting new CodeIgniter code, I tend to overwrite these files a lot. This then required carefully keeping track of what helpers were modified, and introduced some other problems. A preferable approach would be to simply make a copy of system/helpers/date_helper.php in application/helpers. Now, the application helper will be loaded preferentially, and I can modify to my hearts content without ever fearing I’ll accidentally overwrite my changes.
Application based helpers are a handy feature indeed. There have been discussions about changing the procedural structure of helpers to allow for extending and over-riding, but for now, the simplicity of helper functions are preserved, and you can easily maintain your own modified versions.
How are you using CodeIgniter helpers? If you’ve modified any of the base helpers, or created your own, I’d love to hear about it here.
Continue reading “Giving your Helpers a little Help”. Posted in
CodeIgniter, How-To with 7 comments 
July 30th, 2007
Need a series of non-repeating but random numbers? For example, random images from a gallery or portfolio screenshots? Let me save you some time:
$numbers = range($min, $max);
shuffle($numbers);
$random_1 = $numbers[0]; // first random number
$random_2 = $numbers[1]; // next random, non repeating
$random_3 = $numbers[2]; // next random, non repeating
Normally I wouldn’t blog about something like that, except that I just spent 20 minutes using rand() to generate a random number, then saved it into an array, then ran an in_array() to look for it, and start the process over.
It wasn’t until I was about 15 minutes into it that I thought to myself… “What on Earth am I doing?”. Then stubbornness kicked in and I tried to finish my monstrosity, then I finally re-evaluated my strategy.
Funny, because I’ve never used shuffle() before for anything, so my brain could only think of commonly used array functions like sort() and asort() (and of course, your favourite and mine… array_intersect_uassoc() - which I freely admit to only just now looking up to discover it exists).
Why are we sometimes driven to code the most complex solution possible, and worse, even when we know it is utterly involved and inelegant, we still drive to make it work, “just to see it working”?
Continue reading “Using PHP for random, non-repeating numbers”. Posted in
How-To, PHP with 5 comments 
July 16th, 2007
With BambooInvoice 0.8 about to be released, and the big new feature being internationalization, this has brought to light a few issues with character sets, particularly as they apply to the database. It seems that MySQL, in its default configuration, and especially with popular installers such as XAMPP, MAMP and WinLamp, usually sets the default character set as “latin-1”. For English, this is a complete non-issue, and things work as they should, however if you try to set other languages, characters such as ö, ä, and ï (as well as dozens of others) tend to load to the screen as garbage. This is often compounded by the fact that the webpage itself might be in a character set such as UTF-8, which is very “international friendly”, and so things appear to work on the “front end” but as soon as data goes into a database and back out… its borked.
The solution of course is to simply use UTF-8 as the character set for your database. The problem though, is that many of us have legacy data in MySQL, and as mentioned above, the data started its life as latin-1. This is particularly true of BambooInvoice, as the installer I set up did not specificy any character set, so nearly everyone’s databases (my own included) is in latin-1.
I’ve found 2 good ways of converting an existing database from latin-1 to UTF-8. Here’s how you can convert your data…
Continue reading “Changing MySQL default character sets to UTF-8”. Posted in
BambooInvoice, How-To with 3 comments 
May 22nd, 2007
I've been asked how I acheive the alternating comment styles in my blog. When this blog was custom built on CodeIgniter, I used alternator() in the string helper. It looked like this:
<?php foreach ($post_comments->result() as $comment): ?>
<div class="comment<?= alternator(' even', ' odd');?>
<p><?php
if ($comment->comment_author_website) {
echo anchor ($comment->comment_author_website, $comment->comment_author_name);
} else {
echo $comment->comment_author_name;
}
?> wrote on <?= date ('F jS, Y @ G:i', $comment->comment_date);?></p>
<?= $comment->comment_body;?>
</div>
<?php endforeach; ?>
When I switched my blog over to ExpressionEngine a few months ago, I decided to change my strategy a bit, and use the tools EE makes available for me. Specificly, the {switch} tag for comments.
{exp:comment:entries sort="asc"}
<div class="{switch="even|odd"}">
<p>{url_as_author} wrote on {comment_date format="%F
%d<sup>%S</sup>, %Y @ %G:%i"}</p>
{comment}
</div>
{/exp:comment:entries}
I find it ever bit as intuitive as pure PHP, and I love the convenience shortcuts like {url_as_author} (Hyperlink pointing to the URL (if it exists) with the author name as the link title. If the URL does not exist simply the name is returned).
I still have all the legacy code (of course) from the custom written blog app, and while I don't want to release it wholesale, I'd be happy to field any specific questions about any part of it.
Continue reading “alternating comment styles”. Posted in
CodeIgniter, ExpressionEngine, How-To with 1 comment 
April 22nd, 2007
Some of you who know me, know that I roughly split my professional time between development and training. I’ve been lucky to have some success over the years, and I’ve managed to build up a pretty good rapport with local universities and colleges. Like any relationship, after a while, your input starts to be highly trusted, and I’m fortunate to find myself in this situation. It has put me in a position recently to get a new course on the books at area schools, I’ve called it “Building a Web Application: Concept to Completion Workshop”. Why do you care? It’s a course on how to build a web application using CodeIgniter and other “web 2.0” technologies.
My vision was to create a course for working web professionals who want to explore the ins and outs of CodeIgniter, professional web 2.0 application development, and/or have a vision for a web application, but don’t know how to make it a reality. This is not a course to teach you PHP, and javascript - I expect that you already have intermediate knowledge of that - and preferably you’ve built a few things with PHP/JS before, and now want to get ambitious. I will assume though that you’ve never used CodeIgniter before, and on that front we’ll start at “ground zero”, and quickly build our way up.
We’re going to plan, wireframe, mockup and build a full-on, functional web-application. I’m not sure what exactly yet, but it’ll be something practical, and not a complex example of “hello world”. It’ll be data-intensive, and I’ll probably release the final product under the GPL, just like BambooInvoice.
The first run is going to be in North Toronto at Seneca College’s Markham Campus. If I get any interest from around Hamilton, I also have permission to start up a course at McMaster University.
Continue reading “Web Application / CodeIgniter face to face course in Toronto”. Posted in
CodeIgniter, Education, How-To with 14 comments 
1 2 3 >