Misc

Manual Website Deployment

Posted in Misc on August 17th, 2010 by helloworlder – Be the first to comment

Regardless of what language your app is coded in there are some things that are common to pretty much all deployments. Deployment scripts such as capistrano and Ant are great but if you haven’t done a manual deployment before, jumping the gun to a full auto deploy can be pretty confusing. We’re not talking about opening up an FTP client and dragging your files onto the server, although there’s nothing to stop you from doing that. With simple static websites it’s OK, but doing that with any non-trivial web app this approach is very inefficient. The nightmarish file management practices alone is enough discouragement.

Imagine deploying a PHP/MySQL app onto a Linux Ubuntu VPS with SSH access and Apache running. These are the things I would do for a manual web deploy:

1. Set up an SVN repository on your web server. You cannot live without a version control system. If you’re progressive and using Git or Mercury, that’s great.

2. Commit your entire web app into the SVN repository - well actually you should be working and committing to a repo on day 1 of development. If you’re developing on Windows, TortoiseSVN is a good GUI client.

3. Most non-trivial web apps run a database. Assuming that you add data to the database during development, you need to keep the data “in sync” with the rest of your web app. It’s obvious yeah? - export the database into a file e.g. mydata.sql and commit it to the SVN repository with the rest of your web app, not placing it in a folder exposed to the public.

4. Log onto the server (using Putty if on Windows) via SSH, and navigate into the folder where your website is served. From there do an SVN checkout from your repository, which goes something like:

sudo svn co file:///home/helloworlder/repository/myproject trunk .

5. Create the database on your web server if you haven’t already. Or, if you already have the database with outdated data in it then drop it and create it again. Now, you just need to import the database (in our case a .sql file) that’s in your repository (step 3).

6. SVN metadata is served with the rest of the website, and you don’t want that. There are many ways to deal with this including using exports and not checkouts, but you can do this.

7. After doing all that many times over you might even start to get tired of it. Maybe write a script that does the svn checkout and database import in one fell swoop.

Why I Chose The Zend Framework Over Other PHP Frameworks

Posted in Misc on July 30th, 2010 by helloworlder – Be the first to comment

I posted this on Stack Overflow a while ago and it got some up votes so I’ll re-post it here. Here are the things I considered before choosing to use the Zend Framework:

1. Learning Objectives

I know with CakePHP you can get started quicker, but with a blackbox framework such as that I feel I’d be missing out on a lot of learning. If I used CakePHP I’d be missing out on learning about OO concepts and patterns because I just won’t get the chance to apply them. And, if I were to stop my freelancing work and look for a job I want to be able to tell me employer I really understand OO programming, as it’s in pretty high demand now. A common argument is to go for CakePHP if you’re new to programming, but I strongly disagree. When you’re new you want to understand the concepts behind all these things first, before you start using a framework that hides implementation details from you. And when things do break in a blackbox framework such as CakePHP you want to know exactly what’s going on in the background so you can fix it. It’s kind of like using Dreamweaver but not understanding HTML! You need to understand the architecture of CakePHP, and for that to happen you need to know the OO concepts, patterns and architecture behind it.

A bit of learning goes a long way. It might be harder in the beginning when you need to write more code by yourself, but in the long run it’s a lot more enjoyable to understand what is actually going on. There is dogma that says “Don’t write anything yourself that has been written before”. OK, I agree mostly, but if you have much to gain from writing something yourself, it’s better to do it. The things to gain may be having a more flexible framework at your disposable, and of course better understanding of what you’re doing.

2. Documentation and Support

What if the Framework developers decide in a flash of brilliance that no one needs documentation for version XXX of the framework and overwrite it with a new documentation version, but you are still using that old version? I’d say you’re screwed in a big way. The guys at ZF put all the doc versions at your disposal — http://framework.zend.com/docs/api and it’s something you’d just expect. I strongly believe that a framework is only as good as it’s documentation.

If you’re going to create a very long running project with lots of unknowns, I’d go with the Zend Framework. It’s got corporate backing and official training courses. CakePHP does have a great community, but there’s always more security with corporate backing. The fact that Zend is commercializing it’s products (the Zend Framework is open source), does not bother me in the least, and is more or less irrelevant. I couldn’t care less about ideologies on free software or whatever, I just want to get things done.

3. Flexibility

You never know what the client will ask for next (or what you yourself will need next). If he/she asks for some insane/strange feature from Mars that will break or stretch a framework beyond its capabilities, then you’re going to be in trouble. The Zend Framework is well known for being very flexible - you can pick the components you want to use and it doesn’t force an architectural doctrine on you. In some cases you could go for an existing CMS, but CMSs are only good for websites that fit a certain mold, beyond that they’re no good.

4. Project Hand-off to Other Developers

If it ever comes to this, you want to make sure the clients have access to a large number of developers who understand the framework you have used. I don’t know the numbers here so I can’t honestly say whether Zend or CakePHP has a larger developer base. My guess is Zend as it has a lot more financial backing than CakePHP and the organization has the ability to officially train developers who use it. Probably it’s easier to hire a Zend developer by asking for his/her certification.

5. Continual Development of the Framework

Is the framework continually developed and at what pace? Is the documentation able to keep up with the framework development? And, does the organization support older versions of the framework? What if the lead developer of a framework gets hit by a truck? What’s going to happen now? Is the organization that develops the framework as brilliant managerially as they are technically? I give Zend Framework the go here.

Why Doesn’t My Phone Show Missed Calls?

Posted in Misc on June 8th, 2010 by helloworlder – 1 Comment

This has got to be the most annoying mobile phone problem I’ve encountered. It doesn’t show the numbers of missed calls. It used to. Now it doesn’t. What the hell?

But I’ve heard worse. I have a friend with a phone that has the buggiest software like alarms not going off at the set time (yes he was late to something when the alarm failed to go off in the morning), and contacts being randomly deleted without input from the user. Apparently that phone’s poor software has been over-compensated with the strongest physical armor to protect it from bangs and drops.

I dislike Apple’s hypocrisy when it comes to open standards and propriety software and hardware, especially it’s fiasco with Adobe recently regarding the Flash CS5 packager for iPhone, but maybe it’s time to get an iPhone … now just need some money :/

In Europe

Posted in Misc on October 16th, 2009 by helloworlder – Be the first to comment

I m in Europe at the moment. Have been for the past 2 weeks and will be for another 2 so thats the reason for the lqck of updates. Actually in Paris right now. Cant type much because dont know how to use the french keyboard thus the dodgy punctuation, and Im real tired. So goodnight and ill write somthing in 2 weeks.

The Landing Game

Posted in Misc on September 28th, 2009 by helloworlder – 2 Comments

The Landing Game was originally an experiment I was doing to simulate the forces that act on a plane with “real physics”. Then I couldn’t do that so it kind of turned into a game. Because it wasn’t planned I did a bit of the famous spaghetti coding :-)

Though The Landing Game only has 1 level (lol), I learned a bit about game design. One of the most difficult aspects is getting the difficulty right. Too difficult is frustrating and too easy is just boring. I got some friends to test it and the general feedback was - toooo hard. Furthermore, the instructions were not that clear. I ‘m a huge flight sim fan so it was ok for me. That’s why it’s important to do testing.

Anyway you can play the game here. I haven’t fixed up the difficulty yet because I’m pretty busy preparing to go overseas - so I guess you better be up for the challenge!

hehe

Just showing you that it is actually possible to land the plane even at this difficulty!If you’ve played flight sim before then you might find it easier.
TIP: Remember to flare the plane and keep your eye of the Vert Speed indicator. For more info on flaring, see the wikipedia page on Landing.

EDIT: The game has now been made a lot easier after overwhelming feedback that the game was far too difficult and even “impossible”. Now it might be a bit too easy. The main problem is that it only has 1 level! With multiple levels I can gradually make it harder each level. But, I don’t really have time to work on this anymore so I’m leaving the game in its current form indefinitely.

Life’s Like a Depth-first-search

Posted in Misc on September 22nd, 2009 by helloworlder – Be the first to comment

life_dfs

BadProgramming.com

Posted in Misc on September 22nd, 2009 by helloworlder – Be the first to comment

Just found a site called Bad Programming and unfortunately it looks pretty dead.

However I do like the idea of studying bad coding practices. In programming we talk a lot about code smell which is based on our intuition. But intuition is not magically drawn from the ether. Instead, it comes from our own experiences of past mistakes, right? Some mistakes we learn from, and others we don’t. And there are many mistakes we haven’t made yet. So studying bad practices or anti-patterns helps us to avoid making old mistakes and prevent new ones from being made.

The “Re-inventing The Wheel” anti-pattern is one of my favorites. Whether based on pride or ignorance the result is the same - you waste time solving a problem that has already been solved before. If you use Ruby then you know that RubyGems helps you to address this problem.

Capistrano with Windows - Solution to “No such file or directory”

Posted in Misc on September 11th, 2009 by helloworlder – 2 Comments

If you’re trying to deploy a Rails app from Windows* and you get a No such file or directory warning during cap:deploy, then it’s very likely that you don’t have a command line svn client installed. Google CollabNet Subversion and grab the command line client tool from their website. You’ll need to sign up but it’s quick and painless compared to the pain you just went through searching through the Internet for this information in the last hour :-)

Just remember that after installing the client you need to close down and re-open the command prompt window. Do not forget that because I did. Also you really should type svn at the command prompt to see if svn is actually in the PATH. If it is, then you should get a nice “Type ’svn help’ for usage. If not then you’ll get some error.

Good luck with the rest of the deployment.

*I’m assuming you’re not trying to deploy TO a Windows machine. It’s possible but you’re a minority if you’re trying to do that, which means it’ll probably be harder to find info pertaining to your needs :-)

Automatically Tweet Your SVN Commits

Posted in Misc on September 7th, 2009 by helloworlder – Be the first to comment

There’s a very cool Ruby script called ruby_scm_twitter written by the guys at www.thewebfellas.com, that will automatically tweet your SVN commits. Download it here.

However I had to make some changes to the ruby_scm_twitter.rb script to make it work. You’ll need to do the same. Before you go any further you might want to read the readme file that comes with the script so you know what I’m going on about. Ok, the changes:

You need to replace the contents of the run method on line 120 with the following code:

httpauth = Twitter::HTTPAuth.new(@options.username, @options.password)
Twitter::Base.new(httpauth).update(message)

That is because the Twitter gem that the script depends on has been updated since the script was written, and Twitter::Base.new(…) expects only 1 parameter now, namely a Twitter::HTTPAuth object. Also, make sure that you do NOT have @options.user, but instead you should have @options.username. That was a typo in the original script.

This was mentioned in the readme file, but I want to remind you: You must make sure that this script - ruby_scm_twitter.rb - is executable.

Alright, that’s all we’re doing with that script. I had to also make some changes to the post-commit file in the hooks folder. If this is your first time working with the post-commit file be aware that under hooks there is a file called post-commit.tmpl. You have to get rid of the .tmpl - just rename it to post-commit. If you don’t do this then SVN will not execute the post-commit script.

The actual contents will need changing too. The readme file says:

REPOS="$1"
REV="$2"
/opt/svn/hooks/ruby_scm_twitter.rb -u twitter username -p twitter password -f "${REPOS}" -r "${REV}"

You should change it to

REPOS="$1"
REV="$2"
/usr/bin/ruby1.8 /opt/svn/hooks/ruby_scm_twitter.rb -u twitter username -p twitter password -f "$REPOS" -r "$REV"

/opt/svn may not be the path to your repository. For me it was /home/helloworlder/repository/hooks.

Finally, you must make the post-commit file executable.

And that should do it.

The Ruby Toolbox

Posted in Misc on August 28th, 2009 by helloworlder – Be the first to comment

I just found this site today and I wish I’d found it earlier. It’s The Ruby Toolbox, and it helps you find the right tools for your Ruby project. It’s a directory and then some.

For example, have you ever had the problem of needing to find a suitable plugin or gem for your Rails project? It can be really frustrating looking for plugins/gems for some purpose (such as a file upload plugin) then after starting to use it you realize it’s out of date, no longer actively developed, incompatible with your current Rails version, or simply difficult to use.

Or, maybe you just want to know which is currently the most popular web server to deploy Rails applications with?

The Ruby Toolbox helps you choose by coralling Rails plugins and gems (and other Ruby or related programs) into categories such as “Rails Authentication”, “Rails File Uploads” and even “Game Libraries”. The cool thing is that once you click on a category you can see all the items under them and their popularity. For example, under “Rails Authentication” , restful_athentication is at 100% popularity with rpx_now on the other end at 4% popularity. Nice. There is also news for each item.

It’s not an exhaustive list of tools, but nevertheless it’s been very helpful to me. I’m guessing more tools will be added with time.


http://www.ruby-toolbox.com/


Easy AdSense by Unreal