Jamie Balfour BSc

Welcome to my personal website!

Technology enthusiast

I am very interested in technology, particularly relating to computer science. I am most interested in web design and development.

My main hobby is programming. One of my most well known products from this is ZPE. I also am the sole creator of BalfBlog, BalfBar and BalfSlider.

A little bit about me

In 1997, when I was six years of age, I got my very first computer. I was always very interested in the ins and outs of it and dismantled it to see how it worked.

Years later, in 2016 I received my BSc (with honours) in Computer Science, obtaining a First class degree.

I'd like to welcome you to my website and hope you enjoy using it as much as I have enjoyed building it!

Google Plus
Jamie Balfour BSc
Full stack developer

Personal Blog

Whilst I'm not the biggest user of Bash, I do use it at least everyday for lots of jobs. I learned a lot from a friend but also from experimenting a lot whilst being an OS X user. In this post I'm going to discuss the main benefit of Bash for me. 

The first notable benefit of Bash is automation. Since Bash is relatively easy to access and will not need compiled it's easy to automate certain things. One of the things I use Bash for is it's find command. This allows me to list all files which match a certain name. Using this command I can run an exec command on it and do things like move them or delete them.

But, you ask, I've got a Mac with a graphical interface so why do I not just search using the Finder search tool? This is very true but I'm not able to do that on my Raspberry Pi which is not connected to any display am I? No. What I do here is the second notable benefit of Bash - remote login. 

Remote login is generally handled by SSH for me. This fantastic tool lets me manage my Raspberry Pi remotely from my Mac but it also gives me access to the server from which this website is being hosted on. Couple the two aforementioned features of Bash and I can manage my website server using my Mac remotely. Not only does this give me more access around the server but it gives me speed.

Say I want to delete 1,000 files which are in a directory of directories, I would need to recursively delete them. With FTP, I would request the deletion of the whole directory and my FTP client (FileZilla) would send a REMOVE command to the server. However, before it can do that it would need to go into each sub directory, recursively (meaning it would need to visit each sub directory of that sub directory too) and send a REMOVE command on each file inside of it and then on the empty directory itself. The FTP client needs to check each directory out for any files which it requests from the server each time. This is a long and cumbersome task. For me it takes no time though, because I know Bash. 

Using Bash the deletion of remote files can be sped up considerably. Once I've SSH'ed into my server and I wish to remove a directory and it's contents it's fairly simple:

rm -r test_dir

In the above example I'm removing the test_dir directory and it's contents. Since Bash sends a single one line command to the server which the server then interprets and executes using its own Bash interpreter, the execution time for the above example is less than one second. This is an astronomical improvement over the FTP client. 

So there you have it. My favourite reason for using Bash. 

I will criticise Bash over one thing however, and I guess I think of myself as a bit of a snob when it comes to programming languages since I feel that a lot of languages have ugly syntax and I do not feel that Bash is any different. For example if statements do not use the normal < or > signs to represent their comparators. No, in Bash this is done with the -lt and -gt words. Then you've got the whole thing with variables where instantiating a variable does not require a $ but referencing one does. 

This ugly syntax has often deterred me from using Bash to do something. My own ZPE aimed to fix a lot of this and has, just without the horrid syntax of Bash. It's worth a look if you want a simple scripting syntax and powerful language all in one. 

For the very first time since buying my 2012 Mac Mini in 2014 I have reformated it with a fresh OS X install. There was no particular reason for this other than wanting a fresh install of OS X with the very minimal install again - too many files on my system were taking up my drive, so it was just time. The system was still running absolutely as it was when I bought it, so it was nothing related to that. Just saying, Macs don't need that kind of reformat anyway.

Anyway, since this is the first reinstall of OS X on that machine, I thought I'd give my configuration script a try. It really is wonderful, and it's really all thanks to my friends Ben and Merlin that it's as good as this.

The script looks like:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install rlwrap
brew install Caskroom/cask/smlnj
brew install Caskroom/cask/osxfuse
brew install sshfs
brew install python
brew install homebrew/x11/swi-prolog
echo "Insert Dropbox path:"
read input_variable

echo "export $DROPBOX=" >> ~.bash_profile
echo "$input_variable" >> ~.bash_profile
if [ ! -d ~/Pictures/Screenshots ]
    mkdir ~/Pictures/Screenshots

rm ~/Library/Preferences/com.apple.dock.plist
rm ~/Library/Preferences/com.apple.finder.plist

sudo cp "$DROPBOX/Mac configurator/configuration/com.apple.dock.plist" ~/Library/Preferences/com.apple.dock.plist
sudo cp "$DROPBOX/Mac configurator/configuration/com.apple.finder.plist" ~/Library/Preferences/com.apple.finder.plist
defaults write com.apple.screencapture location ~/Pictures/Screenshots;
killall SystemUIServer

So once I got my Mac up and running and Dropbox installed, I run this script to copy all the necessary files across to their places, which restores my Mac to how it should look (i.e. it makes Finder and the Dock identical across my Macs). I've highlighted line 12 because it is where my Dropbox directory is put into my Bash profile so that I can reference it from any script easily.

By the way, this is not me saying that Bash is beautiful, because the syntax is horrible. All I am saying is it is a pretty powerful little shell scripting language.

Site accessibility

A lot of the original functionalities that once existed here have been removed.

This page was generated in 0.26 seconds using 2097152 bytes. Slow? Let me know.

To use project mode, the window must be greater than 920 pixels in width.
Click here to disable Project Mode.
This site uses cookies to deliver its services, to personalise ads, to store preferences and to analyse traffic. Information about your use of this site is shared with other companies. By using this site, you agree to its use of cookies.
Contact me
Contact Jamie Balfour

Get in touch with me via this form.