Using Giphy to generate random numbers

While talking on Slack one day, we were discussing generating random numbers with Python, and how we might go about doing it without the random module (or os.urandom()). Of course, there are many possible ways to achieve this, but Matthew Nunes jokingly suggested using Giphy as a source of random data.

I decided to give this a bash — it seems to work! Obviously, it’s very silly and shouldn’t be used for anything at all important. It was more of a “just because” exercise…

Introduction to virtualenv

Keeping track of  Python package dependencies can be a tricky task, especially when you’ve already got multiple packages installed and you’re not sure what your project is/isn’t using. Thankfully, a tool called virtualenv exists which helps keep track of your packages and lets you isolate installations.

Installing virtualenv is easy – it’s a Python script, and can be obtained by running pip install virtualenv.

Once virtualenv is installed, you can create your virtual environment by running virtualenv my_env_name. This will copy your system’s Python binary (you can specify a custom version by passing the --python=/path/to/your/desired/python flag), and install both pip and setuptools to the my_env_name folder. It also creates an activation script, which you can call by running source my_env_name/bin/activate. Activating your virtual environment will update your PATH to use the newly copied Python, as well as the new packages folder and pip install.

Now that your newly create virtual environment has been activated, any calls to Python, easy_install or pip will be passed to your newly created Python install. This means that pip will install packages to your virtual environment rather than to your system install, and that any system packages that you had previously installed are no longer accessible. A useful side-effect of running under a virtual environment is that both pip and easy_install no longer require special write privileges – you’ll no longer need sudo/root privileges to install packages.

Another handy use of virtualenv is to generate a list of requirements for your project – running pip freeze > requirements.txt will create a pip install -r compatible requirements.txt file for you, allowing you to easily distribute and keep track of project dependencies.

virtualenv can be de-activated by running deactivate from your shell, which restores your environment to its former self.

VPS Wiki

I have recently started work on what is currently called “VPS Wiki”.

The aim of the Wiki is to provide a centralised location for information about using Linux, performing general sysadmin duties, as well as some programming basics. I think the site will naturally change in time – It might lean more strongly towards a particular topic. If that happens, then I will rename the site – I thought “VPS Wiki” was a good starting point, especially given my recent venture.

Some people might think “What’s the point in this – can’t people just google for the answer?”. However, Because technology is rapidly changing, I find that it can be difficult to find relevant, up-to-date solutions to problems that I encounter. I think having a central database of of useful content could be very handy.

I’d really appreciate any contributions towards the wiki – at the moment, you need an account to edit/create pages. You can check the Wiki out here.

Customer Portal Development

So far, it’s been a pretty busy summer. I have spent some time transferring the Modern Glass website over from Drupal to WordPress – mostly for ease-of-use in terms of updating. Along with it have come some speed increases, and SEO optimisations.

This was not a major undertaking – however, the Customer Portal which came with it was getting close to being!


The system was created to allow customers to easily access  and comment on quotes. At Modern Glass, once a quote has been entered into the main computer system, it is saved as a PDF. The Customer Portal which I have created allows the PDF and design files to be uploaded to the site, where the files are turned into thumbnails. Once the quote and all of it’s attatchments are uploaded, the user will recieve an email to tell them that a quote has been added to their account. When they click on the link to view the quote, the time and date at which the quote was viewed is recorded and sent by email to Modern Glass. The customer has the option of adding a comment to the quote – this comment can be replied to by a member of staff.

There are other interesting projects going on this summer – including an automated booking system allowing customers to charter a yacht! I update this blog with my progress.

My plans for rsync

If all goes well with my A-Levels, I will be going to either Cardiff university to study for a BSc Computer Science, or Aberysywyth University for an MEng in Software Engineering – During which time, I will (hopefully) be producing lot of work! At the moment, I do not own an external hard drive… and finances are pretty tight, so I wont be able to invest in one until I have some spare cash. If this does not happen before going to uni, I have decided to rsync all of my work to the home server which I talked about in my last post.

Hopefully, as a client machine on the universities network (which should be plugged into the JANET backbone), I will have a pretty fast upload speed. If this is the case, then I should be able to upload files to my home server at around 850KB/s – and since rsync will only copy new/modified files, this should mean that I only have the one time-consuming backup… the rest should just take a minute or two.

I will let you know how I get on with that… I’m sure that you will all be sitting on the edges of your seats!