Nola Stowe's blog

More VIM tricks

Since my post a few weeks ago, I've been using VI when developing and I only need to access one file, if I need to be workin with multiple tabs at once then I use UtraEdit.(I wrote a review here).

Comment a block of code
I learned this from my friend Brian... say you have 5 lines of code you want to comment out, perhaps you are doing caveman debugging to find where the real problem is..

ctrl-v to go into visual block mode
j down to select the first column in each line
I to insert at begining of line
enter your comment symbol
esc

And there you go! Thanks Brian :)

VIM does orgami
Almost, although you can't make a paper crane with VIM, you can fold your code to make long chunks of code easier to live with. This is something I use in UltraEdit, when I have a really looooooong function that I am not curently working with and I have to scroll up and down to see the code around it.

PHP can be cool like Ruby

All the cool kids these days are using Ruby...however I am stuck in a PHP world at the moment. I've been doing Ruby on some side projects and its got me thinking in a ruby mindset...and I wonder.. can PHP do that? And I've found a few things that might make a PHP geek's life a bit easier or at least PHP a little more tolerable.

Looping
Yes yes, the good old for loop.

for ($i = 1, $i <= 10; $i++) {
    print "Processing $<br>";
}

The simple act of doing something 10 times. Ugly huh? He's one way to do it in Ruby..

Hi Ho Silver! Away!

Remember the Lone Ranger? Believe it or not, I actually watched it as a kid. I don’t know why he was called the Lone Ranger, he always seemed to have Tonto - his Indian sidekick with him. Often, I code alone (I thought about rewriting the "I Drink Alone" song to "I Code Alone" but I had only had 1 small cup of coffee when I wrote this) and I’ve been thinking of some "tricks" to help me with my lonely quest.

Say Hello to My Little Friend

With my recent Ruby on Rails project, I've done more on the linux command line than with PHP development. For example, you run a ruby script to generate a code skeleton for scaffolding, controllers, models and views. Stuck with a windows environment for my development on the go (I commute 3 hours a day, in which time I'm hacking away on my laptop, which I am doing right now. In Vim.)

I reached into the crevices of my mind to remember how to create Batch files. Yes, that’s right, batch files. Yes, Good Old MS-DOS. I still have a DOS For Dummies book (aquired long after DOS was out, I just couldn't resist the nostalgia and I think it only cost 2 bucks). I created a batch file for ls, mv and cp. Not rocket science I know and although I had installed cygwin I was not particularly keen on using that all the time, I also had found some exe's that imitate many of the unix commands...but I didn't need all that jazz. I just wanted a ls, mv and cp command!

As my project progressed, I was doing more and more on the server side, tweaking here and there. Man, I said… I need to get VI for windows I knew it existed, I had it many years ago. Actually, I think it was only a dos version that I had. I searched and discovered GVIM. And it’s pretty darn nice!

Stupidly Easy MVC - Group Membership Application - Part 2

This is part two of an example of using my Stupid Easy MVC framework in PHP. In this example we will talk about the how to use the Model. Originally I thought I might make the Directory a separate controller, but at this point I decided not to. I have some more ideas that I haven't quite worked out yet for extending this even to be more like the Rails framework for Ruby (again I do not expect to totally implement RoR, spare the language wars please!).

Stupidly Easy App Walkthough

One day, the phone rings.
Joe: Hey!! can you make a website for my Candy Wrapper Club?
You: "Candy Wrapper Club?!?"
Joe: "Yes! We collect Candy Wrappers! We just need a little bit about the group, how to contact us and a membership list. It will probably only take you a week. My cousin has a webserver with PHP and MySQL. How about it?
You: <sigh> Sureeeeeeee, I've been wanting to try this MVC thing with PHP.
This is a long one, so grab a cup of coffee!

Stupidly Easy MVC - Directory Structure

There are probably many ways to setup a structure using MVC and this article will talk about two of the ways I have done it and explain why I did it that way and how I think it works out after the fact.

Structure 1
For this project, I used Ruby On Rails as inspiration (Imitation is the best form of flattery, yes?) and used a separate directory for each of the Model, View and Controller. I knew I I was going to have multiple models as well. I used inline php/html for the view for this project since it was only a few forms and we didn't want to do a template system yet. It would be easy to change to templates later of course by just editing the view methods to call a template instead of spitting out html.

More Stupidly Easy MVC in PHP

If you've been living under a rock and missed the previous two articles about this EASY 3 class framework, go read Part1 and Part2.

After my initial project where I first created the simple framework I have since used it on 2 other projects. I didn't even use a template solution for one of them, making it even MORE simple. So I've had a chance to really collect my thoughts on this and put it through the ringer. I've had requests for more examples on using this and hopefully this will answer some of your questions.

Sharing my cool toys

I was berated the other day by Keith. He told me about PLEAC and I said yeah, I know!! He said no fair you didn't share your cool toys! So for all you remaining coders out there, I'm sharing! Here's a few handy code snippet sites and I'll review for you today.

PLEAC
This site uses the Perl Cookbook as the basis (which has the Perl source freely available) and volunteers rewrite the snippets in other languages where possible. Very handy, if you know one language and wonder how you would do it in another language.

Embarking on PHP5 Objects

After a brief few weeks studying Perl and its nuances I'm going to take a look at PHP5 Objects. Perl is rather strange when it comes to objects, its basically a hash with methods. May whatever god you Perl programmers worship bless you. Supposedly when Perl 6 comes out (similarly, we don't know when the end of the world will come either) it will have real objects.

One of the annoying things with object in PHP 4 was you had to use a lot of references, you know, that funny & symbol. No longer needed in PHP 5 because you use "Object Handles" perhaps similar to a file handler you when fopen a file. Also available now are access modifiers "public/protected/package" and interface implementation. I can hear the beer mugs of java programmers being raised in celebration to this one. Also new to PHP 5 are real constructors and destroy methods. There are many more features, but lets see some code.