Kristian Lunde

www.klunde.net

Archive for the ‘Misc’ Category

Automated backups with Amazon S3

with 3 comments

I recently decided that I my half hearted backups to an external drive wasn’t really good enough, so I started to look at alternatives.

Note, this howto is for Mac and *nix system, if you need a windows version please try to google it.

I tried Crash plan, considered a extended dropbox plan but none of them seemed like the correct solution (still I love dropbox, its a great app). I ended up registering an Amazon S3 account.

After a quick google search I found this brilliant little blog post “Using Amazon S3 for personal backups” which describe how to use jetS3t to semi automate the synchronization of the iPhoto library on a Mac OSX.

I am not going to repeat the instructions found on the “Using Amazon S3 for personal backups” blog post, I did however have to do a few minor tweaks to get it to work, I also extended the functionality slightly, to enable a fully automated backup solution.

JetS3t has had a few releases since the “Using Amazon S3 for personal backups” article was written, I downloaded jets3t-0.8.1.zip. Adding the link of the jetS3t directory to the path in .profile didn’t work for me (I’m on Mac osX 10.6), so I added it to my .bash_profile file. You can find .bash_profile in /Users/YOUR-USERNAME/, you’ll have to replace YOUR-USERNAME with your proper username of course. Other than that I followed the examples in “Using Amazon S3 for personal backups”.

Once that was in place and worked properly I started to add some custom scripts.

1. Create a scripts directory in your home directory
2. Create a logs directory in the scripts directory

  1.  cd
  2. mkdir scripts
  3. mkdir scripts/logs

2. Navigate to your scripts directory and create a amazon-s3-backup.sh file.

  1. cd scripts
  2. touch amazon-s3-backup.sh

3. Use your favourite text editor to add the following code to the script

  1. #!/bin/bash
  2.  
  3. #Backup iPhoto
  4. synchronize.sh UP YOUR-IPHOTO-BUCKET /Users/YOUR-USERNAME/Pictures/iPhoto\ Library >> logs/amazon-s3-iphoto-backup.log
  5.  
  6. #Backup Documents
  7. synchronize.sh UP YOUR-DOCUMENTS-BUCKET /Users/YOUR-USERNAME/Documents >> logs/amazon-s3-document-backup.log

Replace YOUR-IPHOTO-BUCKET with the amazon S3 bucket you want to use, and replace YOUR-USERNAME with your username on your mac or *nix system. We pipe the output from the sync process to files in the logs directory, one log file for the iphoto and one log file for the documents process.

4. Edit your crontab. The crontab is a file where you can add files that you want to automatically execute on a regular basis.

  1. crontab -e

5. Add the script to your crontab, I’ve chosen to run it once a week at 20:00 every Sunday, which is expressed by (0 20 * * 0).

  1.  0 20 *  * 0 /Users/<em>YOUR-USERNAME</em>/scripts/amazon-s3-backup.sh

6. Save your cronjob

There you go, now you’ll backup your iPhoto library and Documents every Sunday at 20:00 as long as your computer is turned on and online. You can of course tweak when and how often you want to sync to Amazon S3, you can read more about scheduling cron jobs at wikipedia

Written by Kristian Lunde

May 21st, 2011 at 9:04 pm

Posted in Mac,Misc,Real Life

Tagged with , ,

Review: PHP5 Social Networking

without comments

Packt publishing contacted me couple of months back, asking me if I was interested in reviewing “PHP5 Social Networking” by Michael Peacock. The title intrigued me as I’ve built several social networking applications and I was interested in seeing Michaels approach to this.

The first chapter starts by defining social networking, it looks at the most known social networks out there. It also reviews available social network software out there such as Elgg, drupal and joomla. The approach taken in this book is to roll out an own application from scratch with no base framework. The basics of this framework is described in chapter 2 and 3.

Chapter 4 to 10 deals with the core elements of social networks, such as friends, friend requests, statuses, streams, messaging and events. Each chapter describe how to the functionality should work, a detailed implementation plan is shown and ideas for further development is discussed.

Chapter 11 show the reader how the application easily can support an API, I really like that Michael chose to add this chapter as I think it is a crucial element to any social network that is going to go somewhere.

Maintenance, security and deployment is discussed in chapter 12. I find this chapter a bit odd as it describe very basic steps to get the application up and running on the production server. I would have liked to see more about automated deployment in this chapter.

All social network sites need to get users and hopefully generate some revenue, this is the topic of chapter 13 which describe solutions and approaches to marketing, SEO techniques and monetization.

The last chapter is “Planning for growth” a very important chapter in my mind. It describes approaches for profiling of web applications, server scaling, redundancy and more.

It is a well written book with good examples and it describes the build of the application in detail so the user easily can follow and copy the examples. I would definitely recommend this book to novice developers as it is a good introduction to a lot of good programming practices. It can also be a decent book to read if you are an experienced developer that want to learn more about the core concepts of building a social network.

Written by Kristian Lunde

May 6th, 2011 at 8:34 pm

Lunde Development – In Business

with 2 comments

Say hi to Lunde Development.

The 3rd of August 2010 was the first official day of my own company, Lunde Development. I had at that point already been working with the company ideas and proposals for a while and was able to hit the ground running with my first project already secured. Since then I’ve had several cool clients such as hoverState a high-end US based digital agency, the Newcastle based software company Band-X and Sharpe Recruitment a recruitment agency in Newcastle. You can read more about these projects on my portfolio page.

The future looks bright for Lunde Development and I enjoy every second of running my own business, it is challenging, I learn so much and most important of all, it is fun.

Please check out http://www.kristianlunde.com.

You know where to go if you need a new web site, a piece of software or consultancy ;)

Written by Kristian Lunde

October 5th, 2010 at 8:54 am

Posted in Misc,Real Life,web

Zend_Input_Filter and the Alnum Validator

without comments

The Zend_Input_Filter is a very useful tool when you need to validate and filter the input to your application. It allows you to both filter and validate the input without a lot of hassle. One of the cool features it has is that it allows you to add the validators you need and meta commands to each validator. For instance you can set an Alnum validator to allow empty fields, set a default text and so on.

I came over this annoying issue the other day when I tried to setup the Alnum validator to allow white spaces and have a few meta commands attached to the validator chain. The manual says that you can do this:

  1. $validators = array(
  2.     'month'   => array(
  3.         'Digits',                // string
  4.         new Zend_Validate_Int(), // object instance
  5.         array('Between', 1, 12)  // string with constructor arguments
  6.     )
  7. );

Which I assumed would also work like this:

  1. $validators = array(
  2.     'name'   => array(
  3.         'Alnum',                
  4.         new Zend_Validate_Alnum(true), //allow whitespaces
  5.        'default' => '',  //meta command 1
  6.        'presence' => 'required', //meta command 2
  7.     )
  8. );

This does not work though. You need to remove the validator type string and replace it with an instance of the Zend_Validate_Alnum validator to get it to accept whitespaces and meta commands. This is the right way to do it:

  1. $validators = array(
  2.     'name'   => array(            
  3.         new Zend_Validate_Alnum(true), //allow whitespaces
  4.        'default' => '', //meta command 1
  5.        'presence' => 'required', //meta command 2
  6.     )
  7. );

The entire script ends up looking like this:

  1.  
  2. $filters = array('name' => 'StringTrim');
  3. $validators =  array(
  4.     'name'   => array(            
  5.         new Zend_Validate_Alnum(true), //allow whitespaces
  6.        'default' => '',
  7.        'presence' => 'required',
  8.     )
  9. );
  10.  
  11. $input = new Zend_Input_Filter($filter, $input, $this->getRequest()->getParams());

Written by Kristian Lunde

July 18th, 2010 at 9:00 pm

Klunde.net moved server

with 2 comments

Tonight (Friday 06.11.2009) klunde.net was moved from the servetheworld.net server to my new server provider Webfaction.co.uk. The move seemed to go painlessly, even the email accounts seem to work properly.

Klunde.net has been with servetheworld for approx. 5 years now. Webfaction had a much better solution to offer than Servetheworld and it was therefore an easy choice.

Farewell Servetheworld.

Written by Kristian Lunde

November 6th, 2009 at 11:39 pm

Posted in Misc

Recurring payments with Paypal and PHP

without comments

I have spent the past few days working with online payment solutions for mysapient. Yesterday I came across a bit of a troublesome issue when setting up recurring payments with paypal. There is no secret that the quality of the paypal documentation varies, so I had some troubles finding any proper information about this issue. Luckily there was a lot of other developers struggling with this same issue.

A quick google search gives you a lot of results about this topic and it can take you a while to get through them all, but at least here is the forum post that helped me getting this solved:

http://www.pdncommunity.com/pdn/board/message?board.id=nvp&view=by_date_ascending&message.id=5463

It seems like the setExpressCheckout needs the following parameters to work properly:

  1. [L_BILLINGTYPE0] => RecurringPayments
  2. [L_BILLINGAGREEMENTDESCRIPTION0] => Basic Plan

It is also important to add the “desc” field to the createRecurringPaymentsProfile call.

  1. [DESC] => Basic Plan

Written by Kristian Lunde

October 2nd, 2009 at 9:59 am

Posted in Misc

Amazon Frenzy

without comments

The other day I had a frenzy at amazon and ordered quite a few books I have had on my shopping list. The books are of course all computer and web related. The books I ordered was:

I am halfway through the building scalable web sites and it is really good, even if you are a seasoned web developer I think you can learn quite a bit from it. I have also started to read the MySQL book and can’t wait to learn more about database replication, that is something I really want to find out more about. The “Don’t make me think” book will hopefully assist me on building more user friendly web sites, and hopefully the javascript book(still in the mail) will help me to brush up my js skills.

The Cocoa book was on sale, and you never know when you have to do a bit of programming for a mac :P

Written by Kristian Lunde

September 24th, 2009 at 8:29 pm

On the move

without comments

I am currently switching both domain host and web host, and in that case this site might be down for a little while. I am about to replicate the site to my new web host so hopefully it will be a minimum of down time.

I have chosen to leave servetheworld.net which has been my web host since 2003, they have done a great job, but the time has now come to move to a web host which can provide me with some more advanced features.

I have chosen webfaction.com as my new web host. I chose them because they offer a multitude of different applications, for instance svn, python, ruby on rails and of course PHP. They also offer ssh access.

I chose 123-reg.com to host my domain names, that was done out of convenience, they are well known, large and hopefully know what they are doing :P

Written by Kristian Lunde

June 3rd, 2009 at 8:00 pm

Posted in Misc,web

Tagged with , ,

My 7 things

with 2 comments

The 7 things have been all around the PHP community for a while now, and I got tagged by Christer a while ago. So I guess I should go around and publish my seven things:

  1. I am an assisting nurse graduate
  2. I have a 3 year old daughter
  3. Expired dairy products are some of the most disgusting things I know
  4. I dream of some day having a small cabin by the lake, without any internet or television?!?
  5. I often think about how it would be like to be the only person alive on the earth. (Something similar to the “I am legend” movie, without the zombies).
  6. I took dance lessons when I was a kid, however I really suck at dancing.
  7. I drink way to much Pepsi

Those seven things were not really interesting at all, but it was all I could get together for now. Who knows someday I just might publish: “the top 1000 things you did not know about me” :P

My lucky seven bloggers which I tag are:

Here are some rules that must be followed by anyone who decide to follow up:

* Link your original tagger(s), and list these rules on your blog.
* Share seven facts about yourself in the post – some random, some wierd.
* Tag seven people at the end of your post by leaving their names and the links to their blogs.
* Let them know they’ve been tagged by leaving a comment on their blogs and/or Twitter.

Written by Kristian Lunde

January 22nd, 2009 at 1:34 am

Posted in Linux,Misc

Merry Christmas

without comments

I wish you all a very merry christmas :)

Written by Kristian Lunde

December 24th, 2008 at 11:54 am

Posted in Misc

Get Adobe Flash player