Setting up a regex route to use with Zend Paginator

January 19th, 2012

Here is an example of a route that has an option ‘page’ parameter in the url to use with Zend_Paginator. For example, http://aj.tarachanowicz/admin/blog/page/2.

$this->getPluginResource(’frontController’)
->getFrontController()
->getRouter()
->addRoutes(array(
‘blog-admin-index’ => new \Zend_Controller_Router_Route_Regex(
‘admin/blog(?:/page/([0-9]*))?’,
array(
‘module’ => ‘blogs’,
‘controller’ => ‘manage_blog’,
‘action’ => ‘list’,
‘page’ => 1
),
array(
1 => ‘page’
),
‘admin/blog/page/%s’
)
));

Automount Samba (SMB) Sharepoints using autofs in OSX Lion 10.7

August 15th, 2011

Recently, I’ve moved my development stack off my laptop onto a local server. One of the things on my todo list was making my workspace automount on boot. The only requirement I had was not to use 3rd party applications. Autofs to the rescue!

I need to mount the Workspace samba share on 192.168.1.2 under /Volumes at boot. Open the Terminal.app and sudo to root.

sudo su –

Next you need to create a file to manage all of your SMB mounts.

touch /etc/auto_smb

Add the single line below to the newly created /etc/auto_smb file.

/Volumes/Workspace -fstype=smbfs ://ajt:xxxx@192.168.1.2/Workspace

After saving the file be sure to make it read only by root.

chmod 600 /etc/auto_smb

Now we need to tell Autofs to load our SMB sharepoints. Edit the file /etc/auto_master and add the following line to the bottom of the file.

/- auto_smb

FInally, we need to mount our shares. This can be done by rebooting or running the following command.

automount -vc

The rebirth of IOUBeer.com with Symfony2 and Git Flow – Part 3

May 21st, 2011

Now that I have a basic Symfony2 application in my repository it’s now time to initialize the git flow branching model. The first thing I needed to do was install the git flow plugin. This was rather simple accomplish by using macports.

knix:ioubeer alex$ sudo port install git-flow
—> Computing dependencies for git-flow
—> Fetching git-flow
—> Verifying checksum(s) for git-flow
—> Extracting git-flow
—> Configuring git-flow
—> Building git-flow
—> Staging git-flow into destroot
—> Installing git-flow @0.4.1_0
—> Activating git-flow @0.4.1_0
—> Cleaning git-flow

After installing the git plugin for git flow I had to initialize the project and set it.

knix:ioubeer alex$ git flow init

Which branch should be used for bringing forth production releases?
– master
Branch name for production releases: [master]
Branch name for “next release” development: [develop]

How to name your supporting branch prefixes?
Feature branches? [feature/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? []

Next I wanted to develop the basic functionality that I originally had in my first Zend Framework application. To do this I needed to add to create a feature branch to commit my work.

knix:ioubeer alex$ git flow feature start userauth
Switched to a new branch ‘feature/userauth’

Summary of actions:
- A new branch ‘feature/userauth’ was created, based on ‘develop’
- You are now on branch ‘feature/userauth’

Now, start committing on your feature. When done, use:

git flow feature finish userauth

Next I install the UserBundle, configure it and get everything work as expected. After this I need to merge my changes into my develop branch.

knix:ioubeer alex$ git flow feature finish userauth
Switched to branch ‘develop’
Already up-to-date.
Deleted branch feature/userauth (was d1809af).

Summary of actions:
- The feature branch ‘feature/userauth’ was merged into ‘develop’
- Feature branch ‘feature/userauth’ has been removed
- You are now on branch ‘develop’

Now that I have my basic functionality back in place it’s time to release 0.1.0.

knix:ioubeer alex$ git flow release start 0.1.0
Switched to a new branch ‘release/0.1.0′

Summary of actions:
- A new branch ‘release/0.1.0′ was created, based on ‘develop’
- You are now on branch ‘release/0.1.0′

Follow-up actions:
- Bump the version number now!
- Start committing last-minute fixes in preparing your release
- When done, run:

git flow release finish ‘0.1.0′

This is where I added a RELEASE_NOTES file which I added a list of all my changes in 0.1.0. I then needed finish the release

knix:ioubeer3 alex$ git flow release finish 0.1.0

Released IOUBeer.com 0.1.0

Switched to branch ‘master’
Deleted branch release/0.1.0 (was d1809af).

Summary of actions:
- Latest objects have been fetched from ‘origin’
- Release branch has been merged into ‘master’
- The release was tagged ‘0.1.0′
- Release branch has been back-merged into ‘develop’
- Release branch ‘release/0.1.0′ has been deleted

I’ve now noticed that Symfony2 Beta 1 has been released and I want to upgrade my code to the latest release. This is easily accomplished by preforming another pull request.

knix:ioubeer3 alex$ git pull sf2-se tags/v2.0.0BETA1
remote: Counting objects: 86, done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 67 (delta 47), reused 2 (delta 1)
Unpacking objects: 100% (67/67), done.
From git://github.com/symfony/symfony-standard
* tag v2.0.0BETA1 -> FETCH_HEAD
Auto-merging app/config/config.yml
Merge made by recursive.
README.md | 2 +-
VERSION | 2 +-
app/check.php | 1 +
app/config/config.yml | 20 +++++++————-
app/config/config_dev.yml | 3 +++
app/config/parameters.ini | 2 +-
bin/vendors.sh | 26 +++++++++++++————-
web/app.php | 1 +
web/app_dev.php | 1 +
web/config.php | 4 ++++
10 files changed, 33 insertions(+), 29 deletions(-)

Now that my local repository has the latest code I need to push it up to my remote repository on github.

knix:ioubeer alex$ git push
Counting objects: 94, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (70/70), done.
Writing objects: 100% (71/71), 6.60 KiB, done.
Total 71 (delta 51), reused 0 (delta 0)
To https://github.com/ajt2/ioubeer
d1809af..547f908 master -> master

My code is now up to date and I can continue on developing new features and functionality. I will be updating this series of posts over the next couple of days. I will also be writing a post on how to install and configure the UserAdmin bundle for Symfony2 as there doesn’t seem to be any good tutorials that are straight to the point.

The rebirth of IOUBeer.com with Symfony2 and Git Flow – Part 1
The rebirth of IOUBeer.com with Symfony2 and Git Flow – Part 2

The rebirth of IOUBeer.com with Symfony2 and Git Flow – Part 2

May 21st, 2011

Now that I have a plan it was now time to put things into action. The first thing I needed to do was to get Symfony2 Standard Edition into a git repository in such a way I could easily upgrade the core code to new releases. I started talking to Rob about the problem and he wasn’t aware of an easy way to accomplish this but he had a few ideas he shared with me.

I then headed into #symfony on irc.freenode.net and started asking developers if they knew of a way to accomplish my goal. Someone pointed me at the standard edition git repository and someone else mentioned git submodule. After a few hours of reading tutorials and scouring man pages I have come up with what I’d consider a simple solution to my objective of keeping my applications core code in sync with the Symfony 2 Standard Edition all the while maintaining my changes between releases.

First I started by cloning a copy of my github repository.

cd ~/Workspace
knix:Workspace alex$ git clone git@github.com:ajt2/ioubeer2.git ioubeer
Cloning into ioubeer…
warning: You appear to have cloned an empty repository.

Next I need to add a remote repository to pull in Symfony2 Standard Edition

knix:Workspace alex$ cd ioubeer
knix:ioubeer alex$ git remote add sf2-se git://github.com/symfony/symfony-standard

Now that I have the remote repository I need to pull in a release by tag

knix:ioubeer alex$ git pull sf2-se tags/v2.0.0PR12
remote: Counting objects: 632, done.
remote: Compressing objects: 100% (297/297), done.
remote: Total 632 (delta 361), reused 531 (delta 284)
Receiving objects: 100% (632/632), 105.72 KiB, done.
Resolving deltas: 100% (361/361), done.
From git://github.com/symfony/symfony-standard
* tag v2.0.0PR12 -> FETCH_HEAD
knix:ioubeer alex$ ls
LICENSE README.md VERSION app bin src web

You’ll notice that if you do a git status it’ll tell you nothings change.

knix:ioubeer alex$ git status
# On branch master
nothing to commit (working directory clean)

This is to be expected because I pulled my code from another repository and haven’t committed anything to our repository. However we need to push the history of the remote repository up to our repository.

knix:ioubeer alex$ git push origin master
Counting objects: 631, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (219/219), done.
Writing objects: 100% (631/631), 105.59 KiB, done.
Total 631 (delta 361), reused 631 (delta 361)
To https://github.com/ajt2/ioubeer2
* [new branch] master -> master

Once I’ve pulled in SF2 SE I need to modify the config removing the line below otherwise when I attempt to load the vendors submodules an unexpected exception will be thrown.

knix:ioubeer alex$ vi app/config/config.yml
delete the line “error_handler: null”

I had to then also move the secret option up into the framework group because an exception was being thrown and that’s what the all knowing google told me to do.

charset: UTF-8
secret: %csrf_secret%
csrf_protection:
enabled: true

Now that I have the standard edition of Symfony2 in my repository I need to pull in the vendor branches as submodules in the vendor/ directory

knix:ioubeer alex$ sh bin/vendors.sh
Xdebug requires Zend Engine API version 220060519.
The Zend Engine API version 220090626 which is installed, is newer.
Contact Derick Rethans at http://xdebug.org for a later version of Xdebug.

> Installing/Updating assetic
Cloning into assetic…
remote: Counting objects: 3206, done.
remote: Compressing objects: 100% (1406/1406), done.
remote: Total 3206 (delta 1875), reused 2634 (delta 1430)
Receiving objects: 100% (3206/3206), 354.17 KiB, done.
Resolving deltas: 100% (1875/1875), done.
HEAD is now at db41b52 fixed lessphp test

… REMOVED A BUNCH OF LINES …

Cloning into WebConfiguratorBundle…
remote: Counting objects: 197, done.
remote: Compressing objects: 100% (193/193), done.
remote: Total 197 (delta 98), reused 0 (delta 0)
Receiving objects: 100% (197/197), 33.13 KiB, done.
Resolving deltas: 100% (98/98), done.
HEAD is now at 3c272a6 added missing files
Xdebug requires Zend Engine API version 220060519.
The Zend Engine API version 220090626 which is installed, is newer.
Contact Derick Rethans at http://xdebug.org for a later version of Xdebug.

Xdebug requires Zend Engine API version 220060519.
The Zend Engine API version 220090626 which is installed, is newer.
Contact Derick Rethans at http://xdebug.org for a later version of Xdebug.

Installing assets for Symfony\Bundle\FrameworkBundle into /Users/alex/Workspace/ioubeer/web//bundles/framework
Installing assets for Acme\DemoBundle into /Users/alex/Workspace/ioubeer/web//bundles/acmedemo
Installing assets for Symfony\Bundle\WebProfilerBundle into /Users/alex/Workspace/ioubeer/web//bundles/webprofiler
Installing assets for Symfony\Bundle\WebConfiguratorBundle into /Users/alex/Workspace/ioubeer/web//bundles/symfonywebconfigurator

The next thing that needed to be done was give apache permission to write Symfony2’s cache files to the app/ directory and log files to the logs/ directory.

knix:ioubeer alex$ chmod -R a+w app/cache/ app/logs/

I now can load Symfony2 up into my browser and and view the demo app successfully! Since I’ve modify app/config/config.yml I need to commit those changes and push them up to my repository.

knix:ioubeer alex$ git add app/config/config.yml
knix:ioubeer alex$ git commit -m ‘Removed error_handler option and moved secret option into framework group’
[master d1809af] Removed error_handler option and moved secret option into framework group
1 files changed, 1 insertions(+), 2 deletions(-)
Counting objects: 9, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 480 bytes, done.
Total 5 (delta 4), reused 0 (delta 0)
To https://github.com/ajt2/ioubeer
1f2be22..d1809af master -> master

The rebirth of IOUBeer.com with Symfony2 and Git Flow – Part 1
The rebirth of IOUBeer.com with Symfony2 and Git Flow – Part 3

The rebirth of IOUBeer.com with Symfony2 and Git Flow

May 21st, 2011

Recently I decided to quit looking at my side project IOUBeer.com as a side project and have began to refer to it as a startup. I mainly did this to motivate myself to work on it more often. Because if I looked at it as a business instead of some hair brained project I tinkered with when I have spare time it’d be more likely to succeed.

Armed with a new mentality, motivation, and a bunch of unforeseen free time (for all you freelancers read funemployment) I set out as a man on a mission to build an app that let me collect all those damn beers people have told me they owe me and I never see. You know the ones your friend promised you when you helped him move for the 3rd time that year because him and his girlfriend continuously kept breaking up and she’d kick him out. Or the ones you thought you were going to get for helping a friend fix their care. I’m sure you have your story because we all have been given an IOU and very rarely do we actually have the opportunity to collect on them.

When I originally started building IOUBeer.com I started with Zend Framework and got the basics up and working after about a month. By basics I had the ability for a user to register and authenticate using a username and password or Facebook connect. I then started digging into ACLs and remember that I’d pretty much have to write my own database schema for users, roles, and permissions. I’d then need to write more code to bootstrap my application to use ACLs and restrict access based on the user’s role. I’ve done it before and pretty sure I’ll do it again. However, the difference this time is that I’m the lone coder. I’m not working with a team of developers who could pump this code out in a matter of days.

I needed a simpler solution and that’s when I remember that Rob Zienert had recommended that I check out Symfony2. I read through the introduction tutorial and got started playing around with the framework and code. I very quickly discovered the holy land for developers of Symfony2. They called this place “Symfony2 Bundles”. Not only logical but simple. It has a rather nice ring to it I think. If you remember the reason I was ditching Zend Framework was because I didn’t want to reinvent the wheel. The top scored bundle just so happened to be a UserBundle. Well who would of thought commonly used functionality would be so widely needed.

Anyway around this same time I was also introduced to Git Flow – a successful Git branching model – by a colleague of mine Adam Diehm. After watching the short introductory video on Git Flow there was no doubt in my mind that I was going to use it with IOUBeer.com

The rebirth of IOUBeer.com with Symfony2 and Git Flow – Part 2
The rebirth of IOUBeer.com with Symfony2 and Git Flow – Part 3

Slowly making progress

January 10th, 2011

The next walk started with the same routine. I put Janes’ leash on her, sit down at the kitchen table, and wait for her to come to me. I pick up her leash, stand up, and wait a few seconds before giving her the command to walk with me. This time it only took about 5 minutes to get to the point where she wasn’t pulling. Thankfully I’ve got a rather smart dog who picks things up quickly.

We do a couple laps around the house and make our way to the back door. This time I try a different approach. Instead of letting her in front of me to go out the door I make her stay behind me. Something my old roommate trained her to do. After locking the door and opening the screen door I gave Jane the command, “With me” and started on my way out the door.

We made it out the door without her pulling me but that lasted maybe 5 seconds. I didn’t even get a chance to close the door before she started to pull me down the stairs. I wait for her to quit pulling and put some more slack back in the leash. I tell her, “With me” and I walk into the house. She was not prepared for that one.

I do a couple laps around the house and end up at the back door again. With her behind me and waiting patiently behind me we start out the back door. Again, we make it out the door just fine but she hits the end of her leash and steps back. This time I actually get to close the door. Once shut, she tries to take me out by pulling me across the ice on the deck.

I get some grip and finally stop her. Jane and I are now at another stand off. It remans this way for a while before she finally puts some slack in the leash. Again, I tell her, “With me” and walk into the house. I repeat going in and out of the house several more times before we can walk to the edge of the deck and she doesn’t try to pull me down the stairs.

Teaching an old dog a new trick

January 10th, 2011

I have previously researched and half ass attempted to teach Jane how to walk on a leash before but never succeeded. This time was going to be different tho. I don’t know why but I am going to teach this dog how to walk properly on a leash without pulling me.

Per recommendation her next walk started in the house and we never even made it outside. Damn was she pissed. I put her leash on her and she went absolutely ape shit like she normally does. At this time I went and sat down at the kitchen table waiting for her to calm down. A few minutes later she grasps what’s going on and comes over nudging my arm. You all know that thing the dog does when they want to go. Similar to a three year old grabbing your finger and pulling you.

Armed with my new knowledge I know I have to teach her that I’m leading and if she pulls she is not going anywhere. Which is the one thing that I know is going to be hard as hell to accomplish. I pick up her leash and instantly she starts pulling so I let go. She stops, looks at me, and comes over and starts nudging me again. We repeated this a good 15-20 times before she finally lets me pick up the leash without pulling.

Awesome I finally got her to understand that if she pulls, she’s not going anywhere. This is absolutely key in what I’ve been reading. Next, I stand up and she almost yanks me off my feet. Again, I let go of her leash and sit down. This goes on for about 10 minutes before I can pick up her leash and stand up. They were not joking in the least bit about having patient is going to be the most difficult thing.

Once being able to pick up the leash and stand up without her pulling me I say, “With me” and take a step with my right foot. Before it even hits the ground Jane is at the end of her leash pulling. I stop and stand there. This is where the stand off begins. A few minutes later she finally quits pulling and comes over and nudges my hand. Her way of saying let’s go. I tell her she’s a good girl, pet her, and say, “With me”, and lead with my right foot. This time she doesn’t pull but slowly starts walking with me.

A couple steps later she’s pulling but hey at least she’s getting the idea. I stop, wait for her to put slack back in the lease and start again. Same as last time by saying, “With me” and leading with my right foot. We eventually make it to the door. At this point I turn around and leader her through the house.

Here’s a HUGE tip if you’ve never trained a dog before. They absolutely hate, if not despise going back the way they just came. If you want to teach your dog quickly that you are leading. Once they quit pulling and you say, “With me” go in the direction you just came from. Notice that they’ll walk by your side perfectly and look up at you watching your every move. This is because they really, really, want to go back the other way where they haven’t been yet.

After a few laps around the house I was feeling adventurous and decided we’d continue our lesson outside. However, the moment I opened the back door Jane drug me out it. Back inside we went. This is when I decided to call an end to our training session. We made good progress and there’s the 5PM walk to look forward too.

Being taken for a walk

January 10th, 2011

I left Jane with my parents while I was away in London on vacation. When I returned my Dad informed me that he’s got her on a strict walk schedule. She goes for a walk at 10AM and 5PM. If she starts bothering you around those times that is why. Then my Mother informs me that she’s been feeding her every at 6PM she’s probably going to want to eat shortly after getting back from her walk. No big deal I thought. Damn was I wrong.

I picked her up from the rents’ around 4PM and we got home shortly before 5PM. Like clockwork Jane started pestering me at 5PM. With what my father said freshly in the front of my mind, out the door we went for her walk. Literally! She drug me out the door faster than I could close it. We made it down the street and around the corner before I had enough of being taken for a walk. Jane has never been well behaved on her leash.

We finished her walk and made our way home. Which by that time I was bound and determined to train her how to properly walk on a leash. When I got home I started googling and researching leash training. Below is the basic concept for teaching an older dog to walk on a leash:

  1. Training starts inside the house before you even leave for your walk
  2. The moment they begin to pull stop moving immediately.
  3. When they move closer to you putting slack in the leash reward them with praise or a treat.
  4. Use the same command and lead with the same foot EVERY time you start walking.
  5. Be patient and be prepared for a stand off.
  6. Beware your neighbors will think you’re insane.

Armed with my research I was bound and determine to teach Jane how to properly walk on a leash. Could it really be that hard? I’ve taught myself how to program computers. Train a dog to walk on a leash can not be all that difficult. Can it?

Restructured my blog

January 10th, 2011

I noticed that the majority of my posts were in only a couple categories and I had several categories which really had no true content. I’ve restructured my blog to contain only 4 categories: Development, Personal, Politics and Professional and I’ll be using tags a lot more in future posts.

Running Reboot Recap

January 10th, 2011

I made it through day 6 of running reboot which happened to fall on Thanksgiving. I however did not make it to day 7. While running on day 6 I was in what I like to call the runners tunnel. Which is where you got you headphones on, your pace set, and you’re just cruising. I was doing just that when I didn’t see an uneven section in the sidewalk. Landed wrong on my left foot and jacked it up. Today I’m still recovering from the injury and it’s just about healed. I should be back out running by this coming weekend!