Archive

## Tag Cloud

3d account algorithms android announcement architecture archives arduino artificial intelligence artix assembly async audio bash batch blog bookmarklet booting c sharp c++ challenge chrome os code codepen coding conundrums coding conundrums evolved command line compilers compiling compression css dailyprogrammer debugging demystification distributed computing documentation downtime electronics email embedded systems encryption es6 features event experiment external first impressions future game github github gist graphics hardware hardware meetup holiday holidays html html5 html5 canvas infrastructure interfaces internet io.js jabber javascript js bin labs learning library linux low level lua maintenance manjaro network networking node.js operating systems performance photos php pixelbot portable privacy problem solving programming problems project projects prolog protocol protocols pseudo 3d python reddit reference release releases resource review rust secrets security series list server software sorting source code control statistics storage svg technical terminal textures three thing game three.js tool tutorial tutorials twitter ubuntu university update updates upgrade version control virtual reality virtualisation visual web website windows windows 10 xmpp xslt

## Page Position Bookmarklet

Hello!

Today I have a trio of related javascript bookmarklets for your browser. They allow you to save / restore / clear your position on any web page. It persists across sessions / reboots / page navigations too. It does this by saving the position in your local storage for each path at each domain. This means that you can save your place on multiple pages (even on the same domain!) and they will all be saved until you use the clear bookmark on each page you saved it on or clear your local storage.

I will probably come back and write an upgraded version of these later, but for now they only save one position per page. It would be neat if the saved positions acted like a stack, so you could save multiple positions on each page.

## Windows 10: My thoughts

Welcome to another review post here at starbeamrainbowlabs.com. Sorry for the lack of posts lately, I have been busy with my Programming 2 coursework (there will be a post about this soon!). This post, however, is going to be all about my thoughts on Microsoft's new operating system, Windows 10. Brace yourselves: this might be a long post.

Recently I have obtained a copy of Windows 10 though Microsoft's DreamSpark program for university students. After a managing to download it (I had at least 1 failed attempt), I had to try it out in a virtual machine and write this blog post.

### Positives

Lets start with the good aspects of Windows 10. After using Windows 8, the ability to use the 'metro' apps (Yes I do know that they changed the name, but I don't know what they changed it to) in the windowed mode is really nice. Even though I liked the idea of using them in full screen mode, it got confusing quickly when multitasking.

I also noticed the new "Storage Spaces" option in the Control Panel. It look like you can pool the storage space on multiple drives to create one larger drive. I think it's a nice idea to make an interface to allow the average user to create RAID setups. It is also intelligent enough to put the most frequently used files on the SSDs in a setup, which is awesome.

The new (returning!) start menu is also a huge improvement. Although I haven't used it enough to know if your most frequently used programs appear at the top of your start menu (it really should), it still looks cool.

The other cool thing are the multiple desktops. You can create and remove desktops at will by pressing WIN + TAB. In this menu you can also manage the programs that you have open, just as you could before. Linux has had this feature for ages - it is good to see it finally landing in Windows 10 too.

### Negatives

Now that I have talked about the positives, I would also like to mention the negative things about windows 10. Sadly, this list is rather longer than the list of positives.

Firstly, when freshly installed, Windows 10 takes up about 10.1GB of space. I wanted to include this - I don't really know if this is better or worse than Windows 8.1. The first real bad thing about Windows 10 that I found was that the operating system's interface looks even flatter than the interface of Windows 8.1. What I mean by this is that the number of colours that have been used in the interface has been reduced again. Although it gives it more of a 'minimalist' feel, I don't think they have got it quite right. Google have it right with Chrome, but I think that Windows 10 takes it just a bit too far. That is just my opinion though.

The search box takes up a lot of valuable space on the taskbar, leaving less room for the program I have open. This shouldn't be a huge issue for those with large wide-screen monitors, but many of us (myself included) don't have one so quickly find that we have run out of room on our taskbars. The search box, in my opinion, belongs in the start menu and not the taskbar.

Another small tweak I found most annoying is that I couldn't set windows update to check for update but let me choose when to download and install them. You see, I prefer to check what is going to be installed before it happens - that way I can check on the internet to make sure that there aren't any major bugs in the updates that I am about to install. There is a workaround for this - you can set your internet connection to be a "Metered Connection" (another new feature of Windows 10), but that feels clunky and makes the metered connection setting feel useless to me.

The Apps, though improved, also have several issues associated with them. I would like the option to choose which apps I install at first during the setup - I found that a lot of (for me) useless apps got installed when I first installed Windows 10. That way I can save on hard drive space.

It would also be nice if your installed apps were shown in the "Programs and Features" section of the Control Panel (currently they are not shwon there). That would provide an easy mechanism with which I can remove the ones I don't want.

The apps don't freeze / hang as much as they did in Windows 8, but I still feel like they are a little bit too unstable - they can take a long time to load. This loading time feels even longer without a determinate progress bar to show that the app hasn't crashed. I feel that it is important to let your user's know that your program (and operating system!) is actually doing something. Advanced users may also like it if the operating system told you what is doing in addition to the fact that it is doing something.

I found that I couldn't remove OneDrive app (I assume that it's one). Since I don't use OneDrive (I have a different backup system in place), I didn't want OneDrive starting every time Windows started. I did (eventually) find that you can actually prevent it from starting with the operating system through the "Start up" tab of the task manager.

This leads me into the final point I wish to make: I think that they have tried too hard to make it 'integrated' with their other services such as their Microsoft Accounts and OneDrive. This reduces the number of choices that the user has and make the user feel as though they are forced into something that they perhaps do not want.

### Conclusion

All in all, Windows 10 looks like a definite improvement on Windows 8.1, but it still isn't quite right. I feel as though Microsoft isn't providing it's users with the choice that it used to - this is one of the key reasons I am using a Windows operating system now (I find Windows 7 to be both easy to use and flexible). For most purposes, Windows 10 will be a splendid operating system for the average user. I feel that advanced users will begin to grow frustrated by Microsoft's new operating system due to the lack of choice that is beginning to creep in.

Wow. That was a long post! Anyway, in the next post I will (hopefully) be releasing both the code and the binaries behind the coursework I have recently done.

## Mobile Network Types

At the moment I am rather busy with my coursework, but I still have some time to make a quick post.

This is just a small post to tell you about a quick reference I put together in 5 minutes. It tells you what the different types of mobile network are (like HPSA and EDGE) and how fast they should be.

I have also been looking at Windows 10 in a virtual machine, so I will have a (long!) post coming out soon all about my thoughts and suggestions.

## Upgrading to Ubuntu 15.04 Vivid Vervet

Hello!

Yesterday you probably noticed some downtime. This is because I was upgradting this server's operating system from Ubuntu 14.10 to Ubuntu 15.04! Since I noticed a few things that you should watch out for when upgrading, I thought that I would make a post about it.

For the most part the upgrade went smoothly, but I did hit a few snags. Firstly, if you have got any custom ppas set up for apt-get, you will want to make a list of them (they are located in /etc/apt/sources.list.d) because the upgrade will annoyingly disable them all :( It's not too much trouble to fix but it is annoying.

Secondly, there are two new mime types that have been added /etc/mime.types. If you have made any customisations to this file (I have added text/x-markdown), then you will want to make a note of them and re-add them afterwards. Don't forget to restart your http servers after changing it!

There are some changes that require the ssh daemon to be stopped, so make sure you don't do the upgrade over ssh.

You will get asked which interfaces DCHPv6 should listen on / send requests to. If you use your linux box as a router and have it handing out IP addresses, then you will need to take note of which interfaces you have on your box and which one is which.

By far the biggest problem for me though was the switch from upstart to systemd. This server is hosted by OVH under one of their VPS hosting plans (which are great by the way!), which means that it is virtualised using OpenVZ. It also means that I can't choose my kernel :( I suspect that this is the reason that I can't use systemd, though if anyone has any other ideas, I would love to hears them - leave them in the comments below. When it has finished the upgrade, it couldn't reboot, instead telling me that it couldn't find an alternative telinit implementation to spawn. The solution to this is simple though (don't forget to run as root):

apt-get install upstart
apt-get remove systemd
apt-get install upstart-sysv

The last package in the above (upstart-sysv) should be install automatically, but you should make sure that it is installed - it is the package that prevents it from automatically trying to switch you back to systemd at the next available opportunity.

## Jabber & XMPP: A Lost Protocol

Welcome to a special tutorial post here at starbeamrainbowlabs.com. In this post, we will be exploring an instant messaging protocol known as XMPP.

Today, you will probably use something like Skype, Gmail, or possibly FaceTime to stay in touch with your friends and family. If you were to rewind to roughly the year 2000, however, you would find that none of the above existed yet. Instead, there was something called XMPP. Originally called Jabber, XMPP is an open decentralised communications protocol (that Gmail's instant messaging service uses behind the scenes!) that allows you to stay in touch with people over the internet.

### Identifying Users

There are several programs and apps that have XMPP support built in, but first let's take a look how it works. As I mentioned above, XMPP is decentralised. This means that there is no central point at which you can get an account - in fact you can create your very XMPP server right now! I will go into the details of that in a future post. Having multiple servers also raises the question of identification. How do you identify all these XMPP users at hundreds, possibly thousands of server across the globe?

Thankfully, the answer is really quite simple: We use something called a Jabber ID (JID), which looks rather like an email address, for example: bob@bobsrockets.com. Just like an email address, the user name comes before the @ sign, and the server name comes after the @ sign.

### Connecting People

Now that we know how you identify an XMPP user, we can look at how users connect and talk to each other, even if they have accounts at different servers. Connecting users is accomplished by 2 types of connections: client to server (c2s) and server to server (s2s) connections, which are usually carried out on ports 5222 and 5269 respectively. The client to server connections connect a user to their server that they registered with originally, and the server to server connections connect the user's server to the server that hosts the account to the other user that they want to talk to. In this way an XMPP user may start a conversation with any other XMPP user at any other server!

Here's an example. Bob is the owner of a company called Bob's Rockets and has the XMPP account bob@bobsrockets.com. He wants to talk to Bill, who owns the prestigious company Bill's Boosters who has the JID bill@billsboosters.com. Bob will log into his XMPP account at bobsrockets.com over port 5222 (unless he is behind a firewall, but we will cover that later). Bill will log into his account at billsboosters.com over the same port. When Bob starts a chat with Bill, the server at bobsrockets.com will automagically establish a new server to server connection with billsboosters.com in order to exchange messages.

Note: When starting a conversation with another user that you haven't talked to before, XMPP requires that both parties give permission to talk to one another. Depending on your client, you may see a box or notification appear somewhere, which you have to accept.

Now that we have taken a look at how it works, you probably want your own account. Getting one is simple: Just go to a site like jabber.org and sign up. If you stick around for the second post in this series though I will be showing you how to set up your very own XMPP server (with encryption).

As for a program or app you can use on your computer and / or your phone, I recommend Pidgin for computers and Xabber for Android phones.

Next time, I will be showing you how to set up your own XMPP server using Prosody. I will also be showing you a few of the add-ons you can plug in to add support for things like multi-user chatrooms (optionally with passwords), file transfer proxies, firewall-busting BOSH proxies, and more!

## Voronoi Diagrams

This post was meant to come out on the 15th April... but I forgot to upload it to the server - I am posting now instead.

Today I bring you another experiment with the HTML5 Canvas - Voronoi diagrams. A Voronoi diagram is an image where you scatter a bunch of points across an image, give each point a colour, and then colour each pixel according to which point is closest.

You can find my implementation here: Voronoi Diagram Generator

Initially I had trouble implementing this algorithm as I was trying to draw the outline of each of the cells first, but the explanation on it's Wikipedia article helped me to realise that there was a much easier way to do it :)

Next time I am trying to implement something that looks rather complicated and difficult I will definitely look for an alternative way of thinking about it.

For those of you who are interested, I used a technique called 32 bit canvas manipulation when writing this one. In a nutshell, this is a way of setting the red, green, blue, and alpha values of a pixel all at once, instead of in 4 separate operations - speeding up the whole rendering process.

## SVG and CSS

Recently someone mentioned that they knew someone else who had just brought a duvet cover that has "Huge purple flowers" on it. This gave me a most interesting mental picture - and I recreated in Inkscape (which has just been updated!) for you to see - the result is shown above. Note that those plants would be at least 3 times your size.

Anyway, I also learned that you can mix SVG with CSS (and Javascript, but I haven't got to playing with that yet). as a test, I created a quick square in Inkscape and then opened the resulting file up in my favourite text editor and plugged in some CSS animations. This is what I came up with:

The square above is actually black and set to have a low opacity, to it sets on the colour anything that is behind it. It is also done in percentages, so you can set the width and height of the containing <img /> tag and it should scale accordingly.

I might do some more of this in the future - it looks to me like a wonderful way to create a nice little self contained widget that you can use anywhere.

## Happy Easter!

This is a short blog post to wish you a happy and peaceful Easter!

Posts might be a bit few and far between over the next few weeks due to coursework, but I should be able to post at least once a week.

## IP version tester

You may have heard already - we have run out of IPv4 addresses. An IPv4 address is 32 bits long and looks like this: 37.187.192.179. If you count up all the possible combinations (considering each section may be between 0 and 255), missing out the addresses reserved for special purposes, you get about 3,706,452,992 addresses.

The new system that the world is currently moving to (very slowly mind you) is called IPv6 and is 128 bits long. They look like this: 2001:41d0:52:a00::68e. This gives us a virtually unlimited supply of addresses so we should never run out.

The problem is that the world is moving far too slowly over to it and you can never be sure if you have IPv6 connectivity or not. I built a quick IP version tester to solve this problem. I know there are others out there, but I wanted to build one myself :)

You can find it here: Ip Version Tester.

## Language Review: Lua

I have recently tried writing a bit of Lua. I ported an implementation of a maze generation algorithm I came up with from Python to try it out:

-------------------------------------
-- Maze generation script
-------------------------------------
-- A test by @Starbeamrainbowlabs

---------------------------------------------
-- Intelligent table printing function
---------------------------------------------
-- From http://coronalabs.com/blog/2014/09/02/tutorial-printing-table-contents/

function print_r ( t )
local print_r_cache={}
local function sub_print_r(t,indent)
if (print_r_cache[tostring(t)]) then
print(indent.."*"..tostring(t))
else
print_r_cache[tostring(t)]=true
if (type(t)=="table") then
for pos,val in pairs(t) do
if (type(val)=="table") then
print(indent.."["..pos.."] => "..tostring(t).." {")
sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
print(indent..string.rep(" ",string.len(pos)+6).."}")
elseif (type(val)=="string") then
print(indent.."["..pos..'] => "'..val..'"')
else
print(indent.."["..pos.."] => "..tostring(val))
end
end
else
print(indent..tostring(t))
end
end
end
if (type(t)=="table") then
print(tostring(t).." {")
sub_print_r(t,"  ")
print("}")
else
sub_print_r(t,"  ")
end
print()
end

if arg[1] ~= nil then
width = tonumber(arg[1])
else
width = 36
end
if arg[2] ~= nil then
height = tonumber(arg[2])
else
height = 16
end

----------------------------------
-- function to print out the world
----------------------------------
function printspace(space, w, h)
for y = 0, h, 1 do
local line = ""
for x = 0, w, 1 do
line = line .. space[y][x]
end
print(line)
end
end

-- Initialise the world
start_time = os.clock()
math.randomseed(os.time()) -- seed the random number generator with the system clock
world = {}
for y = 0, height, 1 do
world[y] = {}
for x = 0, width, 1 do
world[y][x] = "#"
end
end

-- do a random walk to create pathways
nodes = {} -- the nodes left that we haven't investigated
curnode = 1 -- the node we are currently operating on
cx, cy = 1, 1 -- our current position
table.insert(nodes, { x = cx, y = cy })

world[cy][cx] = " "
while #nodes > 0 do
io.write("Nodes left: " .. curnode .. "\r")
--print("Nodes left: " .. #nodes)
--print("Currently at (" .. cx .. ", " .. cy .. ")")

local directions = "" -- the different directions we can move
if cy - 2 > 0 and world[cy - 2][cx] == "#" then
directions = directions .. "u"
end
if cy + 2 < height and world[cy + 2][cx] == "#" then
directions = directions .. "d"
end
if cx - 2 > 0 and world[cy][cx - 2] == "#" then
directions = directions .. "l"
end
if cx + 2 < width and world[cy][cx + 2] == "#" then
directions = directions .. "r"
end
--print("radar output: '" .. directions .. "' (length: " .. #directions .. "), curnode: " .. curnode)
if #directions > 0 then
-- we still have somewhere that we can go
--print("This node is not a dead end yet.")
local curdirnum = math.random(0, #directions)
local curdir = string.sub(directions, curdirnum, curdirnum)
if curdir == "u" then
world[cy - 1][cx] = " "
world[cy - 2][cx] = " "
cy = cy - 2
elseif curdir == "d" then
world[cy + 1][cx] = " "
world[cy + 2][cx] = " "
cy = cy + 2
elseif curdir == "l" then
world[cy][cx - 1] = " "
world[cy][cx - 2] = " "
cx = cx - 2
elseif curdir == "r" then
world[cy][cx + 1] = " "
world[cy][cx + 2] = " "
cx = cx + 2
end

table.insert(nodes, { x = cx, y = cy })
else
--print("The node at " .. curnode .. " is a dead end.")
table.remove(nodes, curnode)
if #nodes > 0 then
--print("performing teleport.");
curnode = math.random(1, #nodes)
--print("New node: " .. curnode)
-- print("Nodes table: ")
-- print_r(nodes)
cx = nodes[curnode]["x"]
cy = nodes[curnode]["y"]
else
--print("Maze generation complete, no teleportation necessary.")
end
end
--printspace(world, width, height)
end

printspace(world, width, height)
end_time = os.clock()
print("Generation completed in " .. (end_time - start_time) .. "s.")


I originally wrote it in Python 3 (I might post about the game it is part of at some point). After trying Lua for a bit I thought it would be a good idea to write up a language review about it.

Firstly, it is really easy to get started with. I was able to compile Lua from source using my MinGW on my Windows 7 machine. Lua is also really lightweight (500kb in total!).

The problems begin when you start looking at Lua's equivalent of arrays: tables. I found that they feel clunky and outdated as there appears to be a lack of manipulation functions. Those that do exist (table.insert() and table.remove() use a lot more characters to use than the equivalent in other languages, such as Javascript (e.g. table.insert(tablename, "somestring") is 40 characters, compared to Javascript's tablename.push("somestring"), which is only 28 characters - a 30% saving!)

Lua's tables also start indexing from 1, not 0 - I found this to be a source of much confusion when I was experimenting with it.

The other thing I found annoying is that strings in Lua are immutable - which means that you can't change them once you have declared them. This can lead to lots of nasty performance issues in programs that do a lot of string manipulation if you are not very careful since every time you re-set a string variable's contents, you are creating more work for the garbage collector.

All in all, Lua looks like an interesting language to learn for fun - you should definitely check it out, if only to see how odd a language it is. I love how lightweight it is. I also managed to build the Lua interpreter from source too, which is always a plus. I can't see myself using it for any real project any time soon though - it just feels too clunky to work with for my purposes, although this is probably more down to my lack of experience and the other languages that I know than the design of the language itself.

Art by Mythdael