stephenminded.com http://stephenminded.com/ The personal site of Stephen Lounsbury en-us Fri, 21 Nov 2008 03:15:10 EST http://blogs.law.harvard.edu/tech/rss CakePHP steve@stephenminded.com steve@stephenminded.com Zend Framework Link Roundup http://stephenminded.com/posts/zend-framework-links <p>I've recently been looking into the Zend Framework for a project at work. I found it tough to find good, up to date documentation out there for it. So, I thought I would present everything that I have found to be somewhat useful so far.</p> <ul> <li><a href="http://framework.zend.com/manual">The Zend Framework Manual</a> is always a good place to start. Its actually quite good, but I think it lacks the practical examples that other php frameworks have provided (read CakePHP, CodeIgniter) with something like a <a href="http://codeigniter.com/tutorials/watch/blog/">15 minute blog tutorial</a>.</li> <li><a href="http://framework.zend.com/wiki/display/ZFDEV/Tutorial">The tutorial on the Zend Wiki</a> its a little outdated, but it explains a lot of the core concepts behind the framework and alludes to how the core components can interact with the MVC framework.</li> <li><a href="http://akrabat.com/zend-framework-tutorial/">The Tutorial at Akra's DevNotes</a> is probably one of the best of the lot so far. It has been kept up to date with the changes in the framework and is guaranteed to work fully on 1.0.0 (and with that, it should work fine on 1.0.1). He goes over key concepts like using Zend_Db_Table and Zend_Filter as well as how to work them into the MVC framework.</li> <li><a href="http://www.ibm.com/developerworks/library/os-php-zend1/index.html">IBM's Understanding the Zend Framework</a> series is good, too. Its a bit outdated (June 2006) but goes into all the details that you can expect from an IBM developer works article.</li> <li>Andries Seutens <a href="http://andries.systray.be/blog/2007/06/18/zend-framework-just-get-me-started-okay/">created a default scaffold</a> for getting setup and going with Zend Framework. Just unzip the file into your web directory and you get: <ul> <li>A conventional directory structure</li> <li>A bootstrap file</li> <li>A configuration file with 2 stages: production, staging</li> <li>An error controller</li> <li>An index controller</li> <li>A host of other goodies</li> </ul></li> </ul> <p>The Zend Framework is great so far and offers a lot of power to those capable of digesting the documentation and actually arranging the components in a way that is reusable and avoids complexity. I think the framework would benefit greatly from some of the standards that have been set in other frameworks in terms of getting users started. Something like Cake's Bake script or some screencasts demonstrating how to setup the MVC framework would be welcome.</p> <p>With that all being said, I continue my learning and development with the Zend Framework and look forward to seeing what is in store for the future.</p> <p>If you think I missed any particularly good references, please post them.</p> Thu, 23 Aug 2007 22:24:11 EST http://stephenminded.com/posts/zend-framework-links Jonathan Snook Relaunches WithCake.com http://stephenminded.com/posts/snook_relaunch_withcake <p>When <a href="http://snook.ca/jonathan">Jonathan Snook</a> first got into <a href="http://cakephp.org">CakePHP</a> he launched <a href="http://withcake.com">withcake.com</a> as a spot to share his experience using CakePHP. This served as an excellent reference for people starting out with Cake, as the documentation can sometimes be lacking in certain areas. WithCake provided help on a lot of issues that I had a hard time finding answers to -- it was great.</p> <h3>A New Direction</h3> <p>Snook eventually stopped posting to WithCake and merged the posts back into his main site, <a href="http://snook.ca/jonathan">Snook.ca</a>. He has now relaunched the site as a <em>free</em> job board specifically for CakePHP developers. The site has been redesigned and it looks pretty good. The job board contains sections for both developers looking for work as well as companies looking to hire developers (as well as RSS feeds for both sections).</p> <p>It's a great idea that I'm sure will get a lot of attention as well as help out the CakePHP developer community. I think Snook should be commended for taking this on and offering it as a free service.</p> <p><a href="http://withcake.com/">Go check it out!</a></p> Fri, 6 Apr 2007 17:29:18 EST http://stephenminded.com/posts/snook_relaunch_withcake Generic CSS Switcher http://stephenminded.com/posts/stylesheet_switcher <p>After reading the recent digg article about a <a href="http://digg.com/design/Time_Sensitive_CSS_Switcher">Time Sensitive CSS Switcher</a>, I was inspired to make a more generic version that would allow you to switch the style based on whatever criteria you wanted. For instance, what if I wanted to switch the style based on the referring URL instead of the time of day?</p> <h3>Demo, or it didn't happen!</h3> <p>To all of you who just want to skip the boring details and see the demo, <a href="http://stephenminded.com/files/styleswitch/styleswitch.html">here it is</a>.</p> <h3>How it works</h3> <p><em>Note: I know this is probably better done on the server side, but this is an exercise in JavaScript, so I will leave the server side implementation to someone else.</em></p> <p>The code to switch the stylesheet can be removed from the logic of deciding which style should be presented. So, when you want to change how you decide which stylesheet is used (ie: via the refering URL), you don't need to worry about actually switching the stylesheet because that is already done for you.</p> <p>I also wanted the flexibility to define how the style was switched. Switching the stylesheet is great, but you could also modify the ID of the body element.</p> <p><em>Edit: Someone has suggested adding multiple class names to the body element in order to achieve a similar effect. Its an interesting idea.</em></p> <p>I decided that I would build a function called <strong>StyleSwitcher</strong> to encapsulate the stylesheet switching. This function takes a <strong>Switcher</strong> object as a parameter, this object must have the following properties:</p> <p> <dl> <dt>strategy (String)</dt> <dd>The strategy for switching the style (body ID or stylesheet)</dd> <dt>targetId (String)</dt> <dd>If the strategy is defined as stylesheet, targetId is expected. This defines the id of the stylesheet link element to use to switch the stylesheet.</dd> <dt>getStyle (Function)</dt> <dd>A function that returns the style to apply.</dd> <dt>defaultStyle (String)</dt> <dd>A default style to apply if the getStyle function returns false.</dd> </dl> </p> <p></p> <p>So, the <strong>StyleSwitcher</strong> function is expecting an object that conforms to a specific set of guidelines. In object oriented programming, this "specific set of guidelines" is called an <a href="http://en.wikipedia.org/wiki/Interface_%28computer_science%29">interface</a>. So, this means that I can pass the StyleSwitcher function any object which conforms to the Switcher interface and it can do its work.</p> <p>For the sake of keeping everything encapsulated in one namespace, I've put the function in an object named StyleSwitcher and defined a function called doswitch.</p> <p><em>Note: Don't worry about copying this code, I've provided an example page where you can download everything.</em></p> <p>Here is what the function looks like:</p> <pre><code>var StyleSwitcher = { doswitch : function (switcher) { if (!switcher.strategy || typeof(switcher.strategy) != "string") throw new Error("strategy must be defined as a string in switcher object"); if (!switcher.getStyle || typeof(switcher.getStyle) != "function") throw new Error("getStyle must be defined as a function in switcher object"); if (!switcher.defaultStyle || typeof(switcher.defaultStyle) != "string") throw new Error("defaultStyle must be defined as a string in switcher object"); var newStyle = switcher.getStyle() || switcher.defaultStyle; switch (switcher.strategy) { case "id": document.body.id = newStyle; break; case "stylesheet": if (!switcher.targetId || typeof(switcher.targetId) != "string") throw new Error("stylesheet switchers must have targetId defined"); var ss = document.getElementById(switcher.targetId); if (!ss) throw new Error("switcher targetId refers to non-existent element"); if (!ss.rel || ss.rel != "stylesheet") throw new Error("switcher targetId does not refer to a stylesheet element"); ss.setAttribute("href", newStyle); break; default: throw new Error("strategy must be one of 'id' or 'stylesheet' in switcher object"); break; } } }</code></pre> <p>Basically, the function verifies that the Switcher object passed in has the correct parameters, runs the getStyle function and then sets the resulting style using either the stylesheet or body id strategy. You might be wondering what an example Switcher object looks like, so here is an example one using the referrer:</p> <pre><code>var ReferrerSwitcher = { strategy : "stylesheet", targetId : "style_target", defaultStyle : "referrer.css", styles : {'/digg.com/' : 'digg.css', '/stephenminded.com/' : 'sm.css'}, getStyle : function () { var ref = document.referrer; for (var i in this.styles) { var pattern = new RegExp(i); if (pattern.test(ref)) return this.styles[i]; } return false; } };</code></pre> <p>I've put together a demo which includes switching by referrer as well as time of day like the digg article I mentioned. Here is the <a href="http://stephenminded.com/files/styleswitch/styleswitch.html">demo</a>. Skip the demo and download the <a href="http://stephenminded.com/files/styleswitch/styleswitch.js">code</a>.</p> <p><em>Note: I used <a href="http://jquery.org/">jQuery</a> to attach to the onload event because it provides a nice way of ensuring the DOM is loaded, but by no means is jQuery required.</em></p> Mon, 19 Mar 2007 15:25:38 EST http://stephenminded.com/posts/stylesheet_switcher Comment spam -- already? http://stephenminded.com/posts/comment_spam <p>So after this site being up only a few weeks, I have already managed to get some cowardly spammers to show up. I thought I could get away with not moderating comments, but I was wrong.</p> <p>I can't believe how fast it happened. I mean, there isn't much up here yet and I haven't had a lot of visitors, but somehow the spammers still found it.</p> <p>So, all comments are now being moderated by default. I am going to look at making it so that if you have left at least two good comments, then your comment will show up automatically. That should help cut down on the moderation work when its needed.</p> Fri, 16 Mar 2007 09:10:24 EST http://stephenminded.com/posts/comment_spam stephenminded.com - Now with RSS! http://stephenminded.com/posts/now_with_rss <p>So I finally got around to getting the RSS feed going. So, if you use a feed reader and don't want to have to check my site to see if I've updated it, add the following to your feed reader: <a href="http://stephenminded.com/rss">http://stephenminded.com/rss</a></p> Fri, 9 Mar 2007 15:06:47 EST http://stephenminded.com/posts/now_with_rss Textmate is sexy http://stephenminded.com/posts/textmate_is_sexy <p>I've been watching <a href="http://www.dustindiaz.com/">Dustin Diaz's</a> screen casts lately and they are pretty informative and entertaining. He uses Textmate as his editor and WOW, it looks awesome. The main thing that I really like is the macros (actually, I think they are called snippets, not sure though). I assume you can achieve the same thing with Vi or Emacs, but I haven't looked into it yet. UltraEdit for Windows has macros where you can record key strokes and then play them back, but I don't think it supports the nice tab-complete style of running them like Textmate does.</p> <p>There is a clone of Textmate for Windows called <a href="http://www.e-texteditor.com/">E-TextEditor</a>, so I may have to try out the 30 day trial and see what its like.</p> Sat, 3 Mar 2007 17:03:28 EST http://stephenminded.com/posts/textmate_is_sexy Birth of a website http://stephenminded.com/posts/birth_of_a_website <p>When thinking about how I would bring my new site to life, I looked at a few open source CMS systems like Wordpress and Textpattern. These projects are great and give you everything you need to get a fully operating site up in minutes (in fact, I've used both of them before); but, that's no fun, now is it? More importantly, I think it would be a missed learning opportunity if I just blindly installed Wordpress and dropped on a template. That's not really the way I like to do things. Also, I had recently jumped into CakePHP so I thought to myself "Hey, why not develop the thing in CakePHP?" Not a bad idea eh? I thought so.</p> <h3>CakePHP</h3> <p>For those of you who don't know what <a href="http://www.cakephp.org/">CakePHP</a> is, here's what the website has to say for itself:</p> <p><q>Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.</q></p> <p>Oooh, MVC! What does that mean? It stands for Model View Controller and it's a common way for software developers to keep the data model, business logic, and presentation separated. Why would you want to keep these things separate? Well, it comes down to code maintainability, readability, and the ability to add features to the application in the future (that's a lot of 'ability'). For instance, if I want to take this post and make an RSS version of it, I really shouldn't have to change any of the code to get that data or change any of the data itself, I should just change the way I present it to the people who read it. A properly setup MVC framework lets me do that by just changing the view and leaving the model and controller untouched. If you want to know more about this stuff from people who can explain it better than I, google it.</p> <p>So yah, the site. Cake made it really easy to come up with a very basic back end which let me add, edit, delete and display posts. This was one model, one controller and a few views. After getting the basics done, I started to add on things like comments and article tags. In the end I came up with something quite useful for my purposes. I won't go into all the details here, but I plan to have some posts in the future about that.</p> <h3>Design</h3> <p>Here is the thing that took me the longest. I tend to be picky about how things look and could endlessly tweak here and there. So, I usually come to the point where I have to just throw it out there and leave the tweaking for a redesign. I'm pretty happy with what I have here so far, but it will undoubtedly change in the future.</p> <p>I have always liked light on dark sites, and I wanted to attempt it with this site. The colour scheme was thus inspired by some light-on-dark sites that I have been impressed with, namely: <a href="http://www.totalspore.com/">Total Spore</a> and older versions of <a href="http://www.snook.ca/jonathan">Snook.ca</a> (not to say the new design isn't impressive, its just not light-on-dark for the most part). So, thanks to <a href="http://warpspire.com/">Kyle Neath</a> and <a href="http://www.snook.ca/jonathan">Jonathan Snook</a>.</p> <p>Since this is a light-on-dark design, I tried to keep the text large and readable. The line-height is also increased and I use an sans-serif font so as to make the text easier to follow.</p> <p>There you have it, don't be surprised when it changes in the future and please let me know what you think in the comments.</p> <p> <em>By the way, RSS is on its way :)</em> </p> Mon, 19 Feb 2007 09:31:28 EST http://stephenminded.com/posts/birth_of_a_website Stuck at a Fork in the Life (er, road) http://stephenminded.com/posts/first_post <p>Well, this is my first post to this long in development/design site of mine! It feels pretty good to unleash it on the world, so I thought I would write a little bit about why it came to be.</p> <p>Here's the deal. I'm having a bit of a <a href="http://www.urbandictionary.com/define.php?term=pre-life+crisis">pre-life</a> crisis right now. What, exactly, is a <em>pre-life crisis</em> you ask? Well, I think a lot of students go through it after they graduate and it has everything to do with not knowing what to do. Thats right, I really don't know what to do with my life. Now, its not like I have absolutely no clue, because I know it has something to do with this little box I'm pouring these words into right now (<em>psst, it's a computer...</em>), but I don't know specifically what that something is. I like this whole web development kick I've seemed to be on for, well, a long time now; so, for now I'm going to go with that.</p> <p>End Post.</p> <p>Wait! You thought I said that I didn't know what I wanted to do? Well, I lied. A bit. My specific case of pre-life crisis happens to be something similar to: "Should I go get a 9 to 5 job, or should I continue on this freelance path I've been on for a while now?" There, that's my problem.</p> <img src="/img/pics/working.jpg" width="256" height="192" alt="Grado Headphones" /> <p>Those of you who know me are aware of the fact that since I graduated from Carleton in June I've been working on contracts for various clients doing web development (PHP, MySQL, JavaScript, XHTML, etc). This has been great so far, it's paying the bills and I get to be my own boss, a dream of mine for a long time. (The dream is being my own boss, not paying bills -- although I do have nightmares about that one from time to time.) So, I had to come up with something to do to keep doors open on both sides; something to help build my career -- ugh, I sound like a guidance counselor now.</p> <p>That's where this site comes in. Along with allowing me to occasionally post personal stuff like what you are reading now, it provides a few more important functions:</p> <ul> <li>It helps build an online presence, since some people might actually find my articles here useful.</li> <li>It provides somewhere to show prospective employers my work.</li> <li>And, it serves as a reference for me.</li> </ul> <p>Overall, I think the time invested to get this site up and running was definitely worth it. I hope to look back on this in a year and see it as one of the most important things I did in 2007. So, with that said I now go to sleep and ponder my situation some more.</p> <p>Good Night.</p> Sun, 18 Feb 2007 12:00:03 EST http://stephenminded.com/posts/first_post