Tuesday, 23 March 2010

My Brain


I was listening to Are We Alone podcast this morning on the way to work (on an old iriver instead of my HTC Touch HD - but that's another story) and it was all about how your memory works. One thing I always think about and complain to others about is what I perceive to be the state of my memory.

I really think I have problems remembering things. I think I spend a lot of time listening to podcasts (science, linux, etc), reading literature/blogs and watching documentaries and I am quite annoyed at the fact that I seem to really struggle to retain all the interesting facts that I am reading/listening/watching. I could read a book on something, thoroughly enjoy it, then forget most of it. The subject could come up in conversation and I always feel that I should be able to speak up because I have read about it, but I usually quite blank!

Its really beginning to bother me as I imagine how much I would know if I remembered more that I took in, as I do feel like I make an effort to keep myself reasonably well read. Its worse when I hear someone talking about something that I know I have learnt about, and they are saying it wrong, but I am not able to recall the facts to put them right.

One of the interesting things in the podcast was that 2 main things are detrimental to whether you remember something or not: 1) Interruption and 2) Concentration (I actually can't remember from this morning if that's the right word, but it fits for what I remember I was going to write about).

Interruption is obvious and an external factor, but concentration is really interesting. I realised when I heard this that that is exactly what happens to me. I find myself all the time when reading or listening to someone, realising that my mind has actually wandered onto something else and I have to kinda snap myself out of it.

I actually did this whilst listening to the podcast as I was thinking about the above paragraph, so missed the next few minutes of the podcast! And then when I realised that's what I had done, I started thinking about that too missing even further minutes! Its ridiculous.

I don't think I have problems, I just think I want to be able to have a better memory, as I do have interests in many things and my mind is always going at a hundred miles an hour on different topics.

So I guess if I really do think it is a problem I will have to find ways to train my memory... can only be a good thing...right?

Monday, 8 March 2010

Samsung N130

Recently got a new netbook in the form of a Samsung N130 to replace my Advent, which met its demise at the hands of my 20 month old. It was replaced on household insurance fortunately and its spec seems basically the same. I think they're all much of a muchness really. Seems like a nice netbook for my basic purposes.

Firstly booted it up into XP to ensure it worked. Was a bit put off by the Samsunng recovery facility, which has a partition of its own plus it also wanted to split the XP partition further into a C: and D: and run a backup. Took ages before I could get to actually use it. The XP install is about 6GB! So didn't look around that much.

So I quickly set to installing Ubuntu9.10 on it from a live USB stick, setting up a dual boot. I kept XP seeing as it was already paid for and has its occasional use, but I am very tempted to wipe out everything, including all the restore nonsense and just have 100% Ubuntu. But I know I would probably regret it. It would be nice to be able to clean it up to just a Windows partition and an Ubuntu partition, but I don't know how to get rid of all the Samsung stuff. Suggestions welcome!

So as usual, Ubuntu installed, booted and worked wonderfully and quickly. So, so pain free and simple compared even just to the XP initial setup, let alone a fresh XP install. My only hold up was wireless, as often encountered. But a quick bit googling quickly found a solution here. Sorted, all working! Updated and installed a few essentials to get started.

On a side note, was a bit pissed off with the insurance company. Made it clear from the beginning that I wanted the old one back if possible. The screen was smashed but I thought I could use it as a little server. They told me no problem on multiple occasions I could get it back.

So I sent it off to be innspected, very time consuming process, as one glance would show how beyond repair it was and got a call back to offer the Samsung. Agreed on the Samsung and asked for the old one to be sent back. 'That'll cost you £100 please'

'Eh?!'

Apparently they failed to mentioned that as soon as I sent it off it became their property and I had the right to buy it back! Maybe this how all insurance companies work, I don't know, it was my first encounter. So I ended up just paying £15 for the HDD! Gits!

Thursday, 10 December 2009

Creating a Simple Subversion Server on Ubuntu

For a while I have been trying to learn some programming skills. It is something I would like to do purely for fun and if I can get to a stage where I have decent programming capabilties then I can enjoy writing applications and perhaps start giving something useful back to the Linux community.

To start with the best intentions, I decided to set up a simple Subversion version control system on my server to allow me to keep control of my programming progress in an orderly manner. This blog entry just simply describes how I went about setting it up.

Subversion is a version control system which one can use to keep track of a project and have the ability to 'check out' stuff to work on then 'check in' the changes, keeping old revisions of work in case you need to revert back to an earlier version. This is great, especially when learning, as you don't need to keep saving new copies of your program as it develops every time you want to try something new in case you mess it up and need to revert back to your previous version.

You work on one file (or multiple) and keep checking in your changes, creating many versions which you can always fall back on, but in your working area, you just see the latest version.

I am sure more experienced users may well spot flaws in my set up, but for now, as a beginner, it works well enough for me.

Firstly, I am using an Ubuntu 8.04 LTS server on a VPS. To set up subversion, I followed the following steps:

Install and Setting up Subversion

  1. Firstly, install subversion, easily done with: sudo apt-get install subversion
  2. Then set up a location where subversion will create and manage your projects. I created a directory in my home directory called 'svn'.
  3. Then create another directory within 'svn' to hold the repositories, e.g. 'svn/repos'.
  4. Then create a group for subversion, in this case I chose 'subversion'. I used the command (as root) addgroup subversion
  5. Then change the ownership of the directory 'svn' and all within to the new group: chgrp -R subversion /path/to/svn
  6. Next add write permissions of memebers of the group to be able to write to 'repos' directory: chmod g+w /path/to/svn/repos
  7. Next, to make sure everything created within svn/ is owned by the group: chmod g+s /path/to/svn/repos
  8. Then add users that you want to allow to use subversion to the group: adduser <user> subversion


Creating Repositories

Now we can add some projects or repositories to subversion to work with. A project can contain a single file or multiple files, so for one of my first projects, I have multiple different programs where I have just been experimenting; they are all under one project or repository.

To create repositories:

  1. Go to the repo directory: cd /path/to/svn/repos
  2. Before creating a repository, set the umask to '002'. This allows the following created files to have the correct permissions: umask 002
  3. To create a repository called 'project1' execute: svnadmin create /path/to/svn/repos/project1
  4. Reset umask: umask 022
  5. Now the new repo is created, go to some location elsewhere (you don't work in the repo directory, this is where subversion keeps all its data) and checkout the initial version: cd /path/to/somewhere/eg/home/user/wip If working locally, i.e. on the server where subversion server is running: svn co file:///path/to/svn/repos/project1 This will check out the current revision of the project, which at this stage is revision 0. It will create a directory named 'project1' wherever you perform the command.
Now you can create or copy existing work into this directory and do whatever you want until it is time to check your work in.

Working with Repositories

As we just checked out the first version of project1 and added some files into it, we now need to check in the work to save it in is current state.

  • Firstly we need to 'add' the files to the project. Working within the working directory: svn add file1 file2 etc This should confirm it has added the selected files to the project.
  • Next we have to 'commit' the changes. This saves the data of the current iteration of the project to the subversion server.
  • svn commit -m "Add a note here to describe your changes" This should confirm to you it is adding files and uploading them and its current revision, in this case, 'revision 1'.

    Now another user (who is in the subversion group) can check out the latest revision somewhere else on the system by performing the same commands and it will create a working directory and copy all the files we initially added for them to work on, at revision 1.

    If someone else does work on the project and updates it with changes, we need to be able to get the latest revision to work on. To update your local working copy to the latest revsion, simply go to the working directory, e.g. /path/to/wip/project1 (not in svn/repos/) and: svn update This will pull down and overwrite the local copies with the latest revision.

    Checking Out Remotely



    More than often, you might want to work on your project on a local machine, i.e. not logged into the server, especially if working on GUI apps. The way I am doing it is via ssh. This means that only users with an account on my server and ssh access can download repos.

    I do this with the following command (after setting up and getting into a suitable working directory locally): svn co svn+ssh://servername.com/path/to/svn/repos/projectname This then prompts me for my ssh password twice and then downloads the latest revison of the project to my local directory.

    I can then use the same commands to add, commit and update this directory.

    Non Standard SSH Port


    One note worth adding, I use a non-standard port for ssh access to my server. To allow for this when using the ssh method I needed to edit ~/.subversion/config

    Find the section titled '[tunnels]' and uncomment/add/edit the line containing 'sshtunnel' within to look like: ssh = ssh -p <your port number>

    This will allow the svn+ssh method to work with your non-standard port number.

    Hope this helps someone and also if more experienced users read this and think I am doing things wrong or giving out misleading information, please do let me know so I can update this information and also my own set up!

    Friday, 4 December 2009

    2012 Panic Article

    A small article from a newspaper (not sure which) that my father sent me highlighting how people can easily get themselves worried about mythological events with no evidence to back them up, yet fail to bat an eyelid at 'real' problems happening around them. i.e. crime, global warming, nuclear war etc...


    Wednesday, 9 September 2009

    Panoramic Photo Stitching With Hugin

    Update 19 September 2013: I have since updated the gallery page. As I am moving away from using Drupal, some or all of the links below may not work any more. I made a simple gallery page which makes use of Brain Maps API to emulate the Zoomify function. I also used the great jQuery Masonry library to layout the gallery page.

    Something I discovered a while back was stitching photos together to form panoramas. I have been trying out a few examples, which are shown in the pano gallery. Not much of a great selection, but I keep meaning to do more.

    Thursday, 3 September 2009

    Customising the Drupal Theme of my Site

    At last I have finally got round to doing a bit of theme development on my site! I have been meaning to get round to this ever since I first installed Drupal and promoted it to being my default website.

    For too long I was stuck with the default Garland theme which everyone knows is just the default theme that comes out of the box with Drupal and looks a bit poor as it means you haven't bothered to change it and make it your own. Not that I am saying 'looks' are what make a good site, obviously content is rather important (and yes, I know mine is still lacking in it, but I am working on it).

    I have had a look at it briefly on and off since getting drupal running, and kept getting scared off by the complexity of the seeming maze of css style sheets and templates, but after deciding to get my head around it finally I found some useful methods for easy theme development... in a very basic way of course.

    Help from the drupal forum and also people in the irc channels (#drupal and #drupal-support on the freenode network) really went far in getting me started. The best bit of advice was to use a nice basic starting theme, which has a very basic layout, giving you an effectively blank canvas, from a CSS styling point of view.

    The theme I started with was the zen theme which has excellent documentation to get you started.

    Then I just changed my 'admin theme' (Administer > Site Config > Admin theme) to my new theme, so that I could play around with it whilst just in the admin pages, leaving the public part of the site in tact until my new theme was ready.

    Then basically I just made good use of the Firefox addon web developer, which is perfect for interrogating a website to find out what CSS style sheet is driving what bit of page, so you can gradually track down all the bits you need to alter and create your own custom style sheets.

    One thing to note was that to control the navigation menu, I had to copy the system-menus.css from /modules/system into my theme directory, rename it and add the entry into my theme.info file to make use of it.

    So I am pleased with myself now. I have learnt a bit more, which is never a bad thing.

    Edit: I don't like the gradient bar at the top at all any more!

    Thursday, 27 August 2009

    My simple Website Backup Method

    Since playing around with this new drupal site, plus I have a lot of my personal photos stored in the gallery I really wanted to have some sort of backup strategy, so for now I am using lftp to send the selected data to a NAS device that is connected to my home network.

    I am using FTP on the NAS device as it means I don't need to have a computer on to send data to it. I like lftp as it lets you write a script of commands as a queue of commands to perform; so you can launch lftp with the -f option and specify a simple text file with all the commands you wish to perform.

    I backup the contents of my /home and /var/www/. Also, before backing this up, I tar up /etc and dump the mysql databases into a directory in home/.

    I put all this into a little script which runs once a week using cron.

    Here is my script:

    #!/bin/bash #Backup script for server #set variable of date for labelling date=`date +%F` cd /home/jonr/backupdata/ #remove oldest etc backup rm `ls -t *etc-backup* | tail -n 1` #Backup latest /etc/ tar -czvf /home/jonr/backupdata/${date}-etc-backup.tar /etc/ #remove oldest mysql backup rm `ls -t *mysql* | tail -n 1` #Dump mysql databases mysqldump --all-databases > /home/jonr/backupdata/${date}_mysql_backup #Backup to home NAS using lftp lftp -f /home/jonr/bin/jcr-lftp-script #Calculate the size of the amount of data sent during the backup from lftp's transfer log. grep $date /home/jonr/.lftp/transfer_log | sed -r s/^.+0-// | sed -r s/\ [0-9].+$// > temp.log i=0 for n in `cat temp.log` do i=`expr $i + $n` done echo $i'b' rm temp.log exit

    Hopefully most of the comments explain what I am doing. Some things to note:

    tar of /etc is being run as user 'jonr', not root, therefore there are some files/directories that jonr does not have permission to tar... I need to sort this out.

    To perform the mysqldump, it requires root permissions, normally on the command line you would enter the -uroot and -p options to act as root, so to avoid using these options in plain text in my script you can create a file called '.my.cnf' in your home directory.

    This simply (in my case) contains this info:

    [client] user = root password = (password)

    So when any mysql command is called without -u -p options, it uses these credentials instead.

    Similarly, for lftp, if I create a file called .netrc in my home directory containing:

    machine server.address.com login jonr password (password)

    ...when lftp is launched it can be requested to connect to 'server.address.com' and will not ask for a user and password as it finds it in .netrc

    Here is the contents of the lftp script I call:

    open server.address.com cd PUBLIC/jcrdev/ mirror -Ren /home/jonr/ home-backup mirror -Ren /var/www/ varwww-backup exit

    Simply, it connects using the above credentials, changes to the appropriate directory, then uses the mirror command to 'put' data on th FTP server.

    The -R option means 'reverse mirror', i.e. 'put' data instead of 'get' data. So put it on the FTP drive, rather than pull it off the FTP drive.

    The -e option deletes files on the FTP drive which are not present in the source.

    The -n option puts only NEWER data on the FTP drive, so only things that have changed basically get transferred.

    This is basically behaving like rsync, only transferring data that it needs to to keep it up to date. I just can't use rsync to an FTP drive.

    Things I need to improve on:

    Don't use FTP (not very secure - SFTP better) Configure certain commands, like tar'ing up /etc to allow root priviledges without transmitting password)

    If anyone spots problems or just wants to feedback some comments/advice, please do, I would appreciate it.