Perl and OpenGL on Ubuntu

Want to write a Perl program that uses OpenGL for graphical output?  Running Ubuntu?  Can’t work out how to install what you need to get even a basic program working?  This is your lucky day.  Read on.


Perl is the duct tape of the Internet.  Most folk think you’re restricted to using Perl on the command line — and don’t know that it can quite happily drive a graphical user interface.  Even fewer realise that you can build high FPS OpenGL applications using it.  Better yet, you can develop it all on Ubuntu (or any Linux distro for that matter) and fully embrace Free and Open Source Software (FOSS) in the process.

For someone new to the scene, however, setting your system up so that you have the right toolchain in place can be a bit daunting.  The same applies to those who have been away from the scene for a while and are a bit rusty.  This post is for you.

What follows is a step-by-step guide for installing everything you need onto a regular Ubuntu system so that you can start developing OpenGL applications with Perl.

I can verify that this process works on Ubuntu 16.04 (which includes Perl 5.22).

Let’s get cracking…

Mesa implements a translation layer between a graphics API such as OpenGL and the graphics hardware drivers in the operating system kernel.

$ sudo apt-get install build-essential libgl1-mesa-dev

One or more of these — GLEW, SDL2, GLM, FreeType — will probably come in handy down the line, so may as well install them now.

$ sudo apt-get install libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev

cpanminus is a standalone, minimalist, dependency-free, zero-config script to get, unpack, build and install modules from CPAN.

$ sudo cpan App:cpanminus

OpenGL::Modern provides Perl bindings to the OpenGL graphics APIs using the OpenGL Extension Wrangler (GLEW) library.

$ sudo cpanm OpenGL::Modern

Note:  All of the remaining steps can be completed with a single, convoluted, one-line command.  That command will be given at the end.  You’ll need to verify and update it though, so keep reading.

The Graphics Library Framework (GLFW) is a lightweight utility library that gives programmers the ability to create and manage windows and OpenGL contexts, as well as handle joystick, keyboard and mouse input.  Hover over the “Source Package” link on the GLFW download site and make sure that the version number and URI are up-to-date before executing the following commands.

$ wget

Unpack the archive and enter the directory that gets created.

$ unzip
$ cd glfw-3.2.1

The GLFW author uses CMake because it makes his job easier, so we need to install that and some other packages to proceed.

$ sudo apt-get install cmake xorg-dev libglu1-mesa-dev

Use CMake and make to build and install the GLFW.

$ sudo cmake -G "Unix Makefiles"
$ sudo make
$ sudo make install

That’s it!

Now, you’ll notice that you have to type in the version number a few different times.  We can set the number in a variable and then reduce the last 7 steps into a one-liner.  Here it is for your copying and pasting pleasure (but remember to check the version and URI first):

version="3.2.1" && wget "${version}/glfw-${version}.zip" && unzip glfw-${version}.zip && cd glfw-${version} && sudo apt-get install cmake xorg-dev libglu1-mesa-dev && sudo cmake -G "Unix Makefiles" && sudo make && sudo make install

Assuming everything went according to plan, right towards the end a small window titled “Simple Example” should have popped up briefly on your screen with a rotating OpenGL triangle in it.  That’s the sign that everything is working.



Finally, the purpose of this post is not to try teach you how to program in Perl or OpenGL.  There are millions of other web pages out there that can help you do that.  I personally, however, appreciate having a simple little skeleton of a program to get me started.  Figuring that you might appreciate one as well, I prepared one for you.


use OpenGL::GLFW qw(:all);
use OpenGL::Modern qw(:all);

my $errorCallback = sub {
    my ( $error, $description ) = @_;
    print STDERR "Error $error: $description\n";
glfwSetErrorCallback( $errorCallback );

glfwInit() or die "glfwInit failed, $!\n";

my $window = glfwCreateWindow(960,540,"Blank Slate",NULL,NULL);
unless ( defined $window ) {
    die "glfwCreateWindow failed, $!\n";
glfwMakeContextCurrent( $window );

my $keyCallback = sub {
    my ( $window, $key, $scancode, $action, $mods ) = @_;
    if ( $key == GLFW_KEY_ESCAPE && $action == GLFW_PRESS ) {
        glfwSetWindowShouldClose( $window, GLFW_TRUE );
glfwSetKeyCallback( $window, $keyCallback );

glewInit() == GLEW_OK or die "glewInit failed, $!\n";

glfwSwapInterval( 1 );
glClearColor( 0, 0.5, 0, 1);

while ( !glfwWindowShouldClose( $window ) ) {
    glClear( GL_COLOR_BUFFER_BIT );
    # draw stuff here
    glfwSwapBuffers( $window );

glfwDestroyWindow( $window );

Copy and paste it into a file using your favourite editor, save and close it, chmod+x it and then run it.

All that the program basically does is:

  • set an error handler so that if anything goes wrong you get some feedback
  • initialise a bunch of stuff
  • create a window that can be moved, resized, maximised and minimised
  • bind a callback to the window to trap key presses
  • enter a loop that just continuously clears the (double-buffered) window until either the ESC key is pressed or the window is closed
  • clean up


It took me about nine hours to go from zero to having a basic working program.  There seemed to be no “Perl and OpenGL on Ubuntu” quick start guide on the Web for complete noobs like me.  Working out the steps required was a frustrating process.  Hopefully this guide will make your life a little easier.


PS:  Getting up to speed would have been a lot harder without the help of Chris Marshall on the Perl OpenGL mailing list on SourceForge, and the great folks on StackOverflow.  Cheers!

Posted in Stuff | Tagged , , , , , , , | Leave a comment

Chassis Intruded! Fatal Error… System Halted.

Got an ASUS motherboard?  Are you having problems booting sometimes?  Do messages regarding ‘chassis intrusion’ get displayed on your screen, and stop the boot process, even though no-one has opened the case?  There might be a simple solution.

Chassis Intruded!
Fatal Error... System Halted.

The first time I got the above message I was a bit surprised.  I’m the only one that uses my computer, there are no kids in the house, and the case hadn’t been opened for months.  Pressing the Reset button resulted in a clean boot, so I wasn’t worried.  Computers do strange things sometimes and reboots make most of the problems go away.

But, it happened again a few weeks later, and again, and again…  Ultimately, a pattern emerged:  Whenever the power was cut to the computer for an extended period of time, the intrusion message would come up.

Sometimes I power off my computer from the wall for a few hours when a thunderstorm is rolling through.  Sometimes the LEDs on my stupid Steelseries keyboard will stay on even after the system has shut down, so I terminate power using the switch on the Power Supply Unit (PSU).  Sometimes I turn off power at the PSU when cleaning coolers and fans, installing solid state drives, and otherwise maintaining or tweaking the system.  Sometimes I go camping and power down the whole house (except the fridge) from the fuse box.

Opening the case wasn’t causing the error.  Physically cutting off power to the system was.


The only hunch I had was that it might have something to do with the battery.

Every motherboard has a small clock in it that keeps track of the time.  When the computer is connected to an AC outlet on a wall, the clock is powered by that.  When the power is physically cut (by turning it off at the wall or on the back of the PSU) then the clock is powered by a small battery on the motherboard instead.  If the battery is nearing the end of its life, and there isn’t enough power to keep the clock running, the clock will drift or reset, and when your computer starts up you are greeted with an operating system message telling you that your clock may be incorrect.  I’ve seen that happen many, many times over the years.

Even though I wasn’t seeing any clock symptoms here, I reasoned that something like a chassis intrusion system would need to monitor at least something while the power was disconnected, and if the battery was weak there may not be enough power for that circuit to operate properly.  Enough power for the clock, yes, but not enough for intrusion detection.  (Or it could be some obscure but related value stored in CMOS that was being wiped.)

So, whilst driving past Bunnings one day I popped in and picked up a pack of four CR2032 3V Lithium batteries for about $6.  When I got home I popped the case open, replaced the old battery with a new one, and closed it back up.  Only took a few minutes.  That night I shut down and terminated power to the system completely using the switch on the PSU.  The power was completely cut for over eight hours overnight.

In the morning I reconnected the power and booted the machine — everything worked perfectly.  No error message.  Nor has there been an error message for the days weeks months since (even though I’ve had to cut power a number of times for various reasons).

Problem.  Solved.  🙂

If you are in the same situation — getting chassis intrusion messages when you boot, or clock errors, or any other symptom that seems to occur after cutting power to your system — then spend a couple of bucks and replace your motherboard battery before trying anything else.  It could be the fastest and cheapest hardware fix you ever get to perform.

Happy booting!

PS:  My motherboard is an ASUS Maximus IV Extreme-Z and was purchased in 2011.  Lots of other ASUS motherboards have the chassis intrusion feature, so I suspect will behave the same way when the battery starts to die.  Also, motherboards from other vendors like MSI, ASRock and Biostar probably have a similar feature on at least some of their boards.  I don’t consider this problem/fix to be motherboard-specific, or even vendor-specific.

PPS:  Motherboard batteries should last at least 3 years in a typical system that spends the vast majority of its time plugged into an AC outlet.  They will discharge faster in systems that are physically disconnected from external power frequently and/or for extended periods of time (e.g. because you use one of those ‘energy saving’ powerboards that cut power off completely when you press a button on a remote, or you’re in the habit of turning off your system at the PSU because it’s the only way you can get all of those motherboard LEDs to turn off at night so you can get to sleep, or the system is put into storage due to changing circumstances).  I’ve had batteries last over 8 years in servers that are continuously powered and running.

PPPS:  I tested the old battery with a multimeter.  The voltage of the cell was 2.26V.  This is well below the 3.0V ‘normal’ level, and getting quite close to the 2.0V threshold at which the performance of a CR2032 cell falls off a cliff.  It would seem that 2.26V is still enough for the clock circuitry to function normally, but not enough for the intrusion detection circuitry.

Posted in Stuff | Tagged , , , , , , , , | 2 Comments

Syntax Highlighting in nano

Trying to edit certain files using nano?  Looking for better syntax highlighting?  Been advised that you can clone a github repo and ‘just’ install it?  Not sure how to proceed?  Read on.

The GNU nano text editor is installed on a staggering number of Unix-based systems.  It’s light and friendly.  It’s also smart enough to highlight the syntax in a wide array of different types of files.  This makes life easy.  We like easy.

Unfortunately, developing your own syntax files is not easy.  So we search the web looking for an easy way to give us more syntax highlighting options.  Maybe you came across this article on Linux Magazine like I did?

If you find the syntax highlighting functionality in the nano text editor lacking, you will appreciate a collection of .nanorc files in the nanorc GitHub repository.

Here, you’ll find a selection of definition files for a broad range of programming languages: from Python and HTML, to Lua and Markdown. To add all this goodness to nano, clone the GitHub repository using the git clone command, and then install the files by running the make install command. That’s all there is to it.

Some comments were:

C1:  Nope, not that simple. Good post but linux newcomers like me, need a little more than explanation than this. By default there is no .nano folder in the user home directory for Ubuntu 14. So not quite as straightforward as I hoped.

C2:  100% agreed.

So, for the benefit of all the “Linux newcomers” out there, I thought I’d just document an exact, step-by step process, that you can follow to clone the github repository and install the nano syntax highlighting files on your system.  For a ‘typical’ system, I’ll use Ubuntu 16.04 — your system can, and probably will, be different, but this will flesh things out nonetheless and should help you on your way.


Step 1 — Right click your desktop and select ‘Open Terminal‘ from the pop-up window.  Enter the following commands at the command prompt (probably a ‘$’):

Step 2 — $ sudo apt-get install git

sudo means “superuser do” and is a way of running a command with elevated privileges.  You will be prompted for the superuser password.  Enter it to continue.

apt-get is part of the Advanced Packaging Tool suite of programs that Ubuntu users commonly use to install software on their systems.  It makes installation easy.

install instructs apt-get that you want to install a package.

git is the name of the package you want to install.  git is a package that makes installing software from github easy.  git is not installed by default on 16.04.

Step 3 — $ mkdir ~/git

If you’re relatively new to the whole Linux thing, you probably haven’t developed a sense for organising the file system yet.  Now that you’ve got git installed, and once you see how easy it is to use, you may be tempted to download and use a whole lot of software with it.  That software has to go somewhere.  If you create a git directory in your home directory, you can put all of that software in one place (instead of scattered all over the place).  A little bit of organisation goes a long way towards staying sane.

Step 4 — $ cd ~/git/

By default git will save the software in the current directory so, having created a directory for git, you now change into it.

Step 5 — $ git clone

git is the software you installed in Step 2.

clone means you want to make an exact copy of something that is on github and save it on your computer. is the location of the github repository that you want to download.  Every ‘repo’ has one.  If you go to, for example, you’ll see a green button marked “Clone or download”.  Click it to get the URI for the repo.


(Note: If you don’t have a github account, you’ll see something slightly different.  The button is still there, though.  You do not need to create a github account.)

Upon executing the command, git will connect to github and download all of the software required for nanorc.  Since the name of the repository is ‘nanorc’, git will automatically create a new directory (within the current directory) called ‘nanorc’ and put all of the software inside of that.

Step 6 — $ cd nanorc/

Change into the directory git just created.

Step 7 — $ make

make is a program that looks for a ‘Makefile’ in the current directory.  The Makefile contains instructions on how to build/assemble/compile the source software into binaries/executables/programs/etc.

Step 8 — $ make install

install tells make to actually move the things that it created in Step 7 into the right place(s) on your system — to install them.

Step 9 — $ ls -l ~/.nano/syntax/

Gives you a listing of the directory where your new syntax highlighting files were installed.

Step 10 — $ nano ~/.nanorc

The default location for syntax highlighting files (on Ubuntu 16.04) is /usr/share/nano/ but now that you have a new set installed, you need to tell nano to use those instead.  Add the following line to nano’s configuration file:

include ~/.nano/syntax/*.nanorc

The ‘*’ means to use all of the syntax files in that directory.  So you’re switching from using all of the default syntax files already on your system to all of the new syntax files from the nanorc repo.

You don’t need to do that, if you don’t want to — you can specify individual syntax files on separate lines if you want:

include ~/.nano/syntax/xml.nanorc
include ~/.nano/syntax/ruby.nanorc
include ~/.nano/syntax/lua.nanorc
include /usr/share/nano/c.nanorc
include /usr/share/nano/java.nanorc
include /usr/share/nano/python.nanorc

Mix and match the old and the new as you please…

That’s it.  You’re done!

Start editing files and trying out the new syntax highlighting and, if you like it for a particular type of file, use it.  If not, go back to the default for that particular type, or maybe hunt down another source of syntax highlighting files (from github or elsewhere) and give them a go.

I hope this has been helpful — enjoy!

Posted in Stuff | Tagged , , , , , , , , , , | Leave a comment

How to prevent Google profiling you and censoring what you see

Concerned about having your privacy invaded?  Concerned about being profiled by companies such as Google?  Don’t want algorithms to analyse your preferences, assign a label to you, then treat you differently based on corporate agendas?  If you watch YouTube, here’s one more thing you can do.



It all started when I built a new Linux system a while back.  Apart from a new video card, the hardware was the same, but the operating system was new, all of the applications were new, and I hadn’t even had a chance to transfer any data yet.  A pristine copy of Mozilla Firefox (with no add-ons) was installed so I was using that to hunt down some video drivers.

Now, as a long-time user of Adblock Plus (ABP) you get used to experiencing a relatively ad-free version of the World Wide Web.  You don’t get to see how truly horrendous it has become — because of all of the advertising — until you switch to a new browser without an ad-blocking add-on/plug-in/extension.  Oh my!

Then some creepy stuff started to happen.  Advertising started appearing on some of the sites I visited suggesting products that I had recently purchased.  The products in question (some Noctua CPU coolers and case fans) are pretty obscure — not mainstream at all.  Yet there they were, down to the exact model number.  It didn’t stop at products, though.  YouTube videos started being recommended to me on channels that I was subscribed to.

Keep in mind that this was a brand new system with a pristine browser.  I had not yet signed into Google/YouTube (or any other website for that matter).  The advertising was too specific, too targeted, for it to be random coincidence.

Ok, well, we know that Google is evil and uses a lot of different ways to track you (with browser fingerprinting being especially devious and probably what they used in this case), so I installed ABP and made all those annoying ads go away again.  Out of sight, out of mind, right?

Roll on a few months and I recently noticed that the suggestions on YouTube changed over the course of a single week.  I’d been researching an “issue” lately (won’t say which one) and had been watching lots of videos related to it.  The issue is historic (i.e. dated) so no new videos regarding it were being made — pretty much everything was over two years old.  When I started researching it I was presented with a pile of relevant-sounding suggestions.  As I watched the videos, and clicked the usual ‘like/dislike’ buttons, the suggestions changed.

Now, you might think that this is predictable, and that maybe Google/YouTube was ‘refining’ the results to show more videos that I would be interested in, but in this case the opposite was true.  The videos with the information I was actually after were dropping out of the suggestions list.  The more I ‘liked’ the videos that interested me, the fewer of them appeared in the suggestions list.

If I had watched them slowly, over time, I probably wouldn’t have noticed the change in suggestions, but I was doing this quickly, over a short period of time (kind of like binge-watching entire seasons of a particular show), and it was blatantly obvious.

Suspecting that I may be researching a topic that Google/YouTube had decided to censor, I used my search history to backtrack over the videos I had watched, unchecked the ‘like’ buttons for all (~20) of them, blew my cookies and browsing history away, rebooted, and then pursued the same line of research again using the same search terms (and started watching the videos in the same order).  Bang!  The original suggestions came back.

More importantly:  I let the videos play all the way through (in a background tab, muted) did not click the ‘like’ button for them, and the suggested videos did not change significantly.  Relevant videos were still being suggested at the end of the batch.


  • ‘liking’ YouTube videos has an impact on what future videos will be suggested
  • if Google/YouTube is censoring a particular issue…
    • …and you ‘like‘ a video that disagrees with their position on that issue…
      • then you’ll see fewer relevant videos in the suggestions list
    • if you neither ‘like’ nor ‘dislike’ a video, it seems to make no difference to what videos will be suggested
    • merely watching a video doesn’t seem to change the suggestions list

(Note: I did not test to see if ‘disliking’ videos affects suggestions, so I don’t know if the opposite of the above is true.)

As far as I am concerned, my experience (and test) clearly supports the hypothesis that Google/YouTube is actively censoring certain points of views on certain issues based on users clicking the ‘like’ button in YouTube.

As I want to have access to all sides of all issues, and not have a small number of people within Google manipulate what I think, I tried to come up with a way to stop Google from profiling me and then using that profile to censor what I see.

Unfortunately, I clear my browser history every-so-often, so it’s not possible for me to go back to the date I created my Google/YouTube account and delete all of my ‘likes’.  Even if I had my entire history, it wouldn’t be practical to do so.  As far as I can tell, there’s no way to mass-clear ‘likes’ within YouTube, either.

One option would be to delete my YouTube account and create a new one.  Given that Google can track me across a brand new system install, I’m not sure how well this would actually work.

The final option is to simply accept the damage done so far, and prevent further damage from occurring.  This is the route I chose.  I decided to simply stop clicking the ‘like’ button.

After a few days, and having failed to control myself adequately (it’s so.. damned.. hard.. to resist.. clicking… — a real testament to how well we have been conditioned), I decided to try again and solve the problem a different way.  If I couldn’t consciously stop myself from clicking the ‘like’ button, then I’d use my ad-blocker to hide the buttons themselves.  If the buttons aren’t there, then regardless of what I think or want I simply can’t click on them!

So, about three minutes later, I had ABP blocking all of the ‘like/dislike’ buttons on YouTube and I haven’t been able to click anything since.

Problem solved!

  • Google/YouTube aren’t getting any more ‘likes’ from me
  • that will make it harder for them to profile me
  • that should mean I appear ‘neutral’ on issues Google/YouTube is censoring
  • that should mean I get to see more/all of the content
  • that should make it harder for Google/YouTube to manipulate what I am thinking

It’s a bit strange to not have those buttons there any more, but I’ll get used to it.

Since YouTube changed the payment formula a couple of years ago — to greatly diminish the value of ‘likes’ and make it virtually entirely dependant on ‘minutes watched’ — I’m glad this solution doesn’t meaningfully penalise content creators.  In fact, now that I’m likely to watch more videos, creators (that are being censored) might actually get more income.  (Maybe.  Assuming their videos haven’t been demonetised already.)

Summary:  If you want to make it harder for Google to profile you and manipulate how you think, and don’t have the willpower to avoid clicking ‘like’ buttons, then use an ad-blocker to get rid of the ‘like’ and ‘dislike’ buttons on YouTube.

Posted in Stuff | Tagged , , , , | Leave a comment

Bitcoin and cryptocurrencies

Bitcoin (and many other cryptocurrencies) have been making headlines lately.  Their prices seem to be going through the roof.  Some people even claim that they are long-term ‘investments’.  What’s really going on?  Should you buy some?


To start the ball rolling let me first say that I do not own any Bitcoin.  I do not own any Ethereum.  I do not own any cryptocurrencies at all.  I have nothing to gain or lose whether you buy cryptos or not.  That stands in stark contrast to most of the people who are pumping cryptos, who own cryptos, and who stand to financially gain if they can convince you to start buying cryptos.

If you are new to cryptos, you would have read a lot about how they are anonymous and secure, can’t be tracked or traced, cannot be manipulated by governments or central banks, greatly lower the cost of transactions, cannot be devalued by inflating the supply, and so-on and so-forth.  That was the great promise of cryptocurrencies… but those folks paying attention to developments over the last few years know that every single one of those claims is either blatantly untrue, or not as black-and-white as the pumpers would have you believe.

The ‘appeal’ of cryptos for many, many people is that they seem (at first glance) to be a viable alternative to the corrupt financial system that we’re all trapped by.  Buying some cryptos will let you break free of that, right?  Well, unfortunately, no.

The word cryptocurrency is made up of two parts — crypto and currency.  Crypto describes ‘how it works’ and currency describes ‘what it does’.  Cryptocurrencies like Bitcoin were designed from the ground up to act as a currency — to be a unit of exchange, to solve the ‘coincidence of wants’ problem, to let you buy stuff without having to use legal tender (i.e. government-approved money), to let you bypass ‘the system’.

That last point is where it all comes crashing down.  The government doesn’t want you to bypass the system.  They’ve spent hundreds of years developing that system — a system that is strictly regulated and which forces you to transact using a very limited number of financial instruments that they ultimately control.  Every time you transact within the system, the government is able to tax the transaction.

Tax revenues are the lifeblood of government.  If you are able to freely transact outside the system, in a way that prevents government from tracking and taxing your transactions, you are depriving them of tax revenues.  If enough people do it, government will no longer have enough tax revenue to operate and will fall apart.

Do you really think they are going to let that happen?  Really?  Governments have gone to war and sacrificed millions of their own citizens over petty issues — how do you think they will react to an existential threat?

If you approach the whole issue of cryptocurrencies from the government’s point-of-view, the whole thing becomes very clear indeed:  Unregulated (uncontrolled) currencies threaten the tax base so either have to be regulated, controlled, or outlawed.  Simple as that.  There are no other options.

If a cryptocurrency is regulated or controlled, it will end up with properties similar to current legal tender (trackable/taxable) and, in that case, why bother owning it?  If it can’t be regulated or controlled then it will be outlawed, anyone transacting with it will face prison time and, in that case, why bother owning it?  So regardless of what happens, there’s no point owning it in the long term — it will either become ‘just as bad’ as legal tender, or it will become illegal.

Technical arguments are irrelevant.  The ‘crypto’ part can not save the ‘currency’ part.

Already in 2017 we have seen governments (e.g. Russia, China, South Korea) ban ICOs and cryptocurrency exchanges because they don’t want to let their citizens be sucked in by the hype and throw ‘good’ money into a system that is doomed to fail.

Now, to be clear, you might be able to make a bit of money speculating on some cryptos in the short term, but that’s a very, very risky proposition and not at all an ‘investment’.  Non-government-controlled cryptos will all approach their intrinsic value of $0 in the long term.

Finally, it’s worth mentioning that governments have already looked hard at the technology underlying cryptocurrencies, and many will undoubtedly launch their own form of digital currency — because that would allow them to ban cash and force their populations into using a centrally-controlled system that has tracking and denial-of-funds features inbuilt.  Having such a system would also then allow central banks to drop interest rates into negative territory to have wealth confiscated directly from the entire population — with no way for regular folk to escape.  In this respect, the crypto community has voluntarily developed and freely handed government the very tools that will be used to financially enslave them in the future!

So, to summarise:

  • technical arguments are irrelevant
  • cryptocurrencies threaten tax revenues
  • if they can’t be regulated or controlled they will be outlawed
  • the technology will be used to further financially enslave the populace
  • the long-term intrinsic value of all non-government-controlled cryptos is $0
  • short-term speculation may still yield profits
  • beware of biased pumpers
  • if it seems too good to be true, it probably is

Take care out there.

Posted in Stuff | Tagged , , , , , , , , | 2 Comments

Curvature of the Earth

We all know that the surface of the Earth is curved, but exactly how ‘curvy’ is it?  At what scale do you actually need to start compensating for it in a construction project?  Let’s do some easy math and find out…

The Earth is not a sphere — it’s actually an oblate spheroid — but since oblate spheroid math requires a university degree to understand, we can simplify things by treating the Earth as a sphere.  That makes the calculations understandable by anyone who has passed, say, Grade 10 or 11 high school math.

The mean radius, r, of this simplified Earth sphere is 6,371,008m.

Let d be a straight-line distance that you project at a tangent from any point on the Earth’s surface:

Application of Pythagoras’ Theorem gives the following:

c² = a² + b²
(r+h)² = r² + d²
r+h = √(r² + d²)
h = √(r² + d²) – r

…where h is the height of the end point of that line above the surface of the Earth.

A distance of 1,000m is something that most people can relate to, and is probably near the upper limit of what you would use for large-scale projects, so I’ll use that distance to calculate the magnitude of curvature of the Earth.

Solving with d = 1,000m we get:

h = √(6371008² + 1000²) – 6371008
h = 6371008.078480516 – 6371008
h = 0.078480516m
h ≈ 78mm

So, to put this in a way that I hope everyone can understand:

The surface of the Earth is not now, nor has it ever been, flat —
it falls away from a perfectly straight line at the rate of 78mm every 1,000m.

Thanks to similar triangles and the metric system, you can interpolate easily from that number:

78mm @ 1,000m  ≡  7.8mm @ 100m  ≡  0.78mm @ 10m  ≡  0.078mm @ 1m

So, if you built a house that was 10m long on top of a perfectly flat concrete raft, and placed it on the surface of a perfectly spherical Earth, the curvature of the Earth would result in a 0.78mm gap under one edge of the raft.  It would take 8 sheets of 75gsm photocopy paper or 1 grain of coarse sand to fill that gap.

If a 0.78mm fall over 10m (or any of its equivalents) does not compromise the integrity of your construction, then you can safely ignore the curvature of the Earth — pretend that the Earth is flat* — and just build it.  No-one will suffer.

Now you know.   Happy building.  🙂

* Treating the Earth as flat for small-scale construction projects is perfectly fine.  However, believing that the Earth is flat means you’re joining the ranks of a bizarre religious cult — and that’s not a good idea.  The curvature of the Earth is hard to see with the human eye, and hard to measure with the sort of measuring devices ordinary folks can buy at a hardware store.  Just because it looks flat doesn’t mean it is.  The challenge folks have in measuring that curvature at small scales is due simply to a) the lack of precision and accuracy of their instruments, and/or b) their lack of mathematical skill.

To be fair, very few of us construct things on a scale where we need to factor in curvature of the Earth, so we can happily go through life ignoring its existence.  That doesn’t mean curvature doesn’t exist — it just means ordinary folk don’t need to calculate it, compensate for it, or even worry about it, in their day-to-day lives.  Rest assured, however, that every modern engineer that signs off on a bridge, stadium, dam, airport runway or terminal, canal, supertanker, cruise liner, cargo ship, hospital, aircraft carrier, freeway intersection, railway station, shopping mall, or tunnel has obtained super-accurate measurements and crunched the numbers to compensate for curvature of the Earth — to ensure that their constructions don’t fail and that people don’t die.

Posted in Stuff | Tagged , , , , | 2 Comments

Free Dehumidifier

Air too humid inside your house?  Got mould problems?  Clothes take ages to dry inside during the wet season?  How does a free dehumidifier with zero running costs sound?

Most folks don’t know that their ‘frost free fridge’ can easily be hacked to act as a dehumidifier.  As it runs continuously, it can be used to suck moisture out of a humid house all.. year.. long.

Frost free fridges actually have a heating element.  This heating element comes on every-so-often to thaw out the cooling plate.  Any frost/ice that has formed on the cooling plate melts, drips into a plastic trough, drains to the bottom-rear of your fridge via a small tube, and then ends up in a plastic bowl located on top of your compressor.  The compressor, as it works to pump heat out of your fridge and into the surrounding air, heats up.  Heat from the compressor warms the bowl and evaporates the water, returning the moisture back to the air where it originally came from.  So, under normal circumstances, this operation is humidity-neutral.

Assuming that your fridge is against an external wall, or above an accessible basement, or near a drain, you can get a short piece of scrap tubing, attach it onto the end of the drain tube (just above the bowl), and instead of the water ending up in the bowl, it can be redirected outside, into a container or into a drain.  In any case, since it is no longer being heated and evaporated back into the air, it is effectively removed from the humidity equation and your internal air becomes drier.

Depending on how easy it is to access the back of your fridge, this hack takes mere minutes.  I think it took me all of 5 minutes to do mine — and I chose to drill a hole into our back wall so that the water would go to plants outside.

It doesn’t take any extra electricity, and doesn’t harm your fridge in any way.  It’s just the free 24/7/365 dehumidifier that you all have in your kitchen but weren’t aware of.


Posted in Stuff | Tagged , , , , , , | Leave a comment