Something I’ve been working on

Lately I have been working on a project using the git distributed version control system and Atlassian’s code hosting service, BitBucket.

The project, known as ‘GC Skype Bot’, whilst still very rough around the edges, is now a public repository so that you can take a peek, here’s a link: Fellow developer ‘MushyBean‘ has also committed some changes in this repository.

As the name may suggest, it is a chat bot for the popular instant messenger Skype, although not a pesky or illegal one – just one that aims to bring extra functionality and entertainment to a specified Skype group chat specifically. Currently it lacks a great deal of features, and the available commands are scarce due to the development of the back-end being more important. There are however already some available commands (known as ‘units’), these are currently:

  • Roll the Dice – rolls a virtual six-sided die.
  • Help – provides help text (such as syntax help) for a specified command.
  • Command List – lists all of the available commands.
  • Quit – exits the bot ‘elegantly’ via a command.

These commands can be triggered using the trigger prefix ! and the trigger, which for these units is, respectively: !rtd, !help <command>, !commands, !quit.

Of course, not all users should be allowed to run all commands such as !quit, that would not be fun, so I have implemented a user flags system, which essentially allows an administrator to flag/tag/denote some permissions (or the opposite) to certain users through a simple and structured XML file. For example, the !quit command will not execute unless it was sent by a user with the ‘master’ flag. There are also some other preventative measures that have been implemented, such as a timeout if the user is trying to execute a command too quickly.

If you’re interested, the source code is available here, it’s written in C# with Visual Studio Express 2013, requires .NET Framework 4.5, and needs the Skype4COM library as a reference (usually found in C:\Program Files (x86)\Common Files\Skype). Please keep in mind this is a very early and experimental project created by amateur programmers with little experience, so compile and use at your own risk!

It is a console application, so to launch it currently you must specify a couple of parameters:

  • -blob <chat blob> (the unique blob of the group chat that you wish for the bot to monitor, you can get this by typing /get uri into a chat)
  • -datadir <path> (an absolute path where data the log files and the users.xml file will be saved, for example C:\GC Skype Data\)

Make sure you include the trailing backslash on the path, otherwise it might wreck some havoc, I’ll commit and push a fix for that later to the repository.

EDIT: (Never fear! Paths are now checked to avoid havoc.)

Thanks for reading.

Getting back into things

I’ve finished my first year at college (out of two), and I’ve got just over two months of time off. I want to get back to work with SnowyCMS, but it’s hard to get back into the mindset after so long of not doing anything with it for such a long time.

Equally, I haven’t blogged in a very long time, so I really want to get back into the habit. I tend to slow down and procrastinate more when I’ve decided to undertake a larger project, such as SnowyCMS, and I think that’s one of the large reasons I haven’t blogged in a while (alongside the fact that college has occupied me significantly). I do still want to give it a go, however, though I also want to consider the possibility that I might just have to leave it for now until I feel more competent in web programming. I don’t want this mere project idea to stop me from advancing just because I don’t want to start other projects while one is ongoing.

A wax impression of the grubz logo.

In other news, here’s a cool wax stamp (in real life, whoa) of the “g” logo. Pretty fancy.

Progress, somewhat!

Two and a half months ago, I of course, ambitious as ever, said I would create a content management system – some blogging software.

Well I haven’t given up, but I have only put in about a days work total. As usual, it was one of those “think of a mildly good idea before falling to sleep” kind of ideas… I had it all planned out in my head, but by the morning it had all gone. All I was left with was the name.

The other day I decided I fancied learning some git – the software version control system. It always sounded interesting when I’ve read about it in the past. I always thought git was some kind of super complicated thing that only the cool programmers use, but no, the main functionality and commands, at least, are extremely easy to understand.

My git repository on Bitbucket.

My private git repository on Bitbucket.

With git, came a renewed excitement towards the project. It made me feel that the project had increased in importance and sophistication, even though it was just a private repository. So, I’ve started working on it again.

I would really like to finish this project off, even if it takes me a half a year, or two years… whatever it is – I just want to do it to prove to myself that I can finish it. Hell, it’s probably not going to be half as good as I want it to be, I’m no PHP master, but if I can finish it to a reasonable standard then I will be happy.

Of course, I want there to be a distinction between what I want my software to be and what I can already go and download right now online. Many modern CMS systems focus on things that I wouldn’t, simply because I find them to be negligible features that do nothing more than be annoying – for my usage scenarios. I currently use WordPress, which has a lot of extensibility and a huge array of functionality for bloggers. For me though, the only plugins I have are security enhancements, and the only functionality I use is the Add Post and Edit Post buttons.

I really have had no idea what my plan for SnowyCMS is. I feel as though I need to reconsider what I actually want from it, so here’s the general idea of what I’m thinking:

  • Lightweight flat file CMS.
  • For experienced/power users who prefer control over usability (not to say that the blog would be difficult to navigate, merely the admin panel would be simple but with advanced capability).

Well, that wasn’t really worth two bullet points. Essentially though, what I’m thinking is, I’d like to make a simple CMS which has less of the automatic features that popular CMS’ tend to. I don’t like it when WordPress does everything for me, creating that giant folder of messy, duplicated thumbnails all over the place. Not to say I want to boot up some image resampling software and downsize my images manually every time, but some extra control would be nice. Perhaps I’m just not cool enough to understand WordPress.

When I blog, I overcome no challenges in actually producing the final post (aside from me being generally bad at writing blog posts, of course). Since I’m a fan of occasionally and spontaneously learning better standards, improving my disappointingly bad knowledge of markup languages, and whatever else – why not just make it so writing a blog post sort of does all these same things at the same time? It would be nice to improve the formatting and structure of my blog and its posts, but I’m not very good at it.

If I had to do it though, it surely wouldn’t take long to learn.

CAPTCHA’s still exist in 2013?

I was thinking last night, as I grew frustrated attempting to solve a text-based CAPTCHA on an online forum – surely there must be a better alternative to defend from the hoards of bots. Surely – by 2013 – some expert would have devised a better alternative to stop bots in their tracks?


CAPTCHA’s attempt to make a challenge that is easy for a human to understand but difficult for a bot. I’d argue that this also isn’t very easy for a human.

Well, it would seem that there is nothing better than the tried and tested text-based CAPTCHA, as the internet giants continue to use them. However, the worlds most popular easy-implement CAPTCHA systems (the Google owned reCAPTCHA, for example) have been demonstratively broken – or at least for 10 minutes, before Google decide to tweak their generator… skewing the text further and further into unreadability.

I would argue that this no longer really qualifies it as a “Completely Automated Public Turing test to tell Computers and Humans Apart” (CAPTCHA), since it’s not very automated if the engineer has to modify it every time a technical paper on OCR gets released… but who am I to say.

reCAPTCHA has undoubtedly been in the firing line by many hacking communities and researchers comprised of very intelligent individuals. From 2009 to 2013, the solve rate of reCAPTCHA by non-human methods (bots) has increased substantially. A small AI start-up in the US, ’Vicarious‘, claims to have success rates on modern CAPTCHA software of >90%… which I genuinely think is probably more than my success rate – and I’m human! Unsurprisingly this report has been met with some skepticism, but the demonstrative video and project seems authentic and undeniably clever.

However, I’m in no position to scrutinise. Text-based CAPTCHA systems – especially Google’s reCAPTCHA – are easy to implement and are far better than no protection at all. Though, it seems that CAPTCHA’s no longer stop bots, merely slows them down.

A team of innovative thinkers have come up with an excellent demonstration of how moving away from traditional obscured-text CAPTCHA’s could be the best solution. From what I gather, their system outputs an ink-blot representation of a 3D object, surrounded with other random similarly-sized ink blots.

It works on a similar principle to images many of us have seen before often in illusions, where initially you cannot see the subject and then suddenly you spot it – and then once you have seen it you cannot see how you missed it before.

Although this phenomenon, originally popularized by the Gestalt school, has been well studied, the exact process of how we perceive such objects is not known.

However, of course spending 10 minutes looking for an illusion wouldn’t be the best solution – so they animate it. Adding animation to the object (and all the random blobs), suddenly makes the subject stand out to humans. Bots, however, performing image analysis on this output, simply track meaningless blobs and get nowhere.

You can read more about their fascinating studies here, which includes a video and their full paper (which is the source for the above quote).

Unfortunately, this isn’t a particularly viable solution at the current time, as implementing a system which could generate animating blob images based on 3D scenes in a web environment would be rather extreme and not very cost effective. However, the study shows and demonstrates a fascinating trait of the human mind which simply cannot be emulated by bots – or at least not for a very long time.

Creating my own blogging software

So recently I came up with the idea of creating my own tiny content management system. Something capable of blogging and creating of static pages, or preferably a bit of the two combined.

WordPress is too big for my personal blog, keeping it updated and ensuring (or trying to ensure) that my install is secure is more tedious than it needs to be for a small site. I want the bare minimum – something simple, literally just login and be presented with a WYSIWYG editor and a big “Publish” button. There are hundreds of open source CMS systems (oh god RAS syndrome alert) that I could use, but I like a challenge. I also love to know the intricate inner workings, how things work behind the scenes, which is why creating my own seems so appealing.

I know a bit of PHP; not a lot, but my ambitious mind tells me should be enough. I also like learning more about security techniques, especially cryptography and hash functions.

So, maybe I’ll give it a proper shot. I’ve already started working on the admin login code, which is about 80% complete. I read up on a lot of advice from the glorious IT Security subsection of Stack Exchange site, especially this amusing discussion. Though really I probably shouldn’t invest so much time on figuring out how to store just one password (for the admin, me), it’s a bit of a pointless exercise because it’s a unique password. I don’t store any sensitive data, if someone took the time out of their day to hack my site I’d actually feel somewhat privileged. Still though, good practice I suppose.

You can follow this project here.

Tackle things in a way that you can understand

It’s been a while since I posted something on here, primarily due to me being caught up with some other things and generally not doing as many technically-interesting things lately. Nonetheless, although not necessarily technical. I have something to write about!

The title may sound like an obvious statement, but it is something I sometimes have to remind myself!

In programming, efficiency is key. Short, clean coding is desirable as a key skill for any programmer. However, if you are still learning like me, it is important to remember that you cannot run before you can walk. It’s a great learning exercise to go back and optimize your code, though not entirely necessary in the learning stages until you are more comfortable.

Some ten months ago I had started becoming interested with procedural terrain generation. It seemed really out of my league. I had only just finished reading one of those “Learn Java 6 in [insert a small amount here] days” books. My only prior experience was playing around with a Pascal-like scripting language, and a small amount of knowledge of Visual Basic.

Nonetheless, I set out to implement the diamond-square algorithm.

I spent numerous days researching, trying to figure out how I’d code it. I understood the concept, but when it came to the programming I was totally stumped. I looked everywhere for code snippets, with the intention of learning from them rather than copy and pasting, since that’s what I relied on when learning from the book. However, I found mostly unintelligible snippets which were jammed full with bitwise operations and other overwhelming aspects. It didn’t read like I had expected it to.

Although my efforts there were futile, it had provided me with the realisation that I did know what I had expected to read. I did have an idea, but I kept it at the back of my mind because no one else seemed to be doing it in the same way. So I simply assumed I was wrong.

So, I began tapping away in Processing. I created some variables that I established would likely be necessary, and began writing some (large) functions that made sense to me. The code was probably ten times longer than it needed to be, but I could understand it. In a couple of hours I had something that vaguely resembled what I was going for, albeit jammed with artifacts that looked a lot like lightning strikes (it was actually a very cool effect, although unintentional). Eventually – after uttering “I give up” too many times – I had fixed most of the bugs and learnt some debugging along the way.

I (sort of) documented this here. Now that I look back I can see many things that I couldn’t before. I realise now how incredibly roundabout my methods were, and how I could write it better, shorter, and simpler now. A lot of this knowledge was gained from writing it (‘poorly’) in the first place.

The moral here (if you can call it that) is a simple one. There is no right or wrong way to create a program; as long as it meets your expectations. Short, optimized code is the best, but while you’re learning it does not matter how ridiculously long and unoptimised your code may be.

With time and experience, you’ll learn to write it better; in the meanwhile, slow code is better than no code at all!

How to learn programming with less boredom

From my experience, traditional learning techniques get boring fast. A lot of learning on their own start by reading a how-to book. Books are excellent resources to get the ball rolling.

The trouble is, it just doesn’t stick.

I found books quickly demotivated me, my enthusiasm towards learning would quickly diminish. I’d still finish them, but with much reluctance.

Common tasks found in beginners books are to create things like Fahrenheit to Celsius converters. As you woefully tap away at your keyboard, copying the code letter for letter because the book tells you to, you begin to question how the universe even came to be, and why it has lead you to this moment.

Well, maybe I’m exaggerating. Though, learning to create something so distinctly uncreative is a frustrating experience. No one enjoys making a program so simple that the solution could be reached much more efficiently using any of the many devices that surround us in our daily lives.

For me, programs are much more exciting to create when they are unique each time they are ran. It gives a real sense of excitement when you hit compile and you have only a vague idea of what to expect. Sometimes the output will be bad, not what you anticipated and less than exciting. Other times however, it will just piece together by chance and your own skill to create something wonderful.

Something fun to try could be to tell a story that is different every time based on user input, using arrays, a loop or two, and a randomiser. An awesome, humorous, advanced example of this can be seen here.

So, I suggest if you are struggling, take a break, think outside the box a little. Don’t worry if your code doesn’t work, just read some more and I’m sure you’ll figure it out.

Host migrated (and a lesson learned)

I just finished migrating web hosts, the site seems to be fully functioning… and smoother!

I previously hosted this site with a company in the USA, because it was what I believed to be the most affordable package. Unsurprisingly; because I live in the UK, I encountered substantial latency when I wanted to view my site. The lag was most noticeable when I moved around directories using an FTP client.

I found that pretty agitating really, but I could just about bare with it because I had a clone of the site on my local computer that I could edit and toy around with and then just drag it into the FTP client. That obviously helps reduce the noticeability of latency.

However. Then came the first crash.

I opened up the live chat and asked the support representative why the IP address was unreachable. They responded plainly with the obligatory thank you message (and sadly without the use of grammar or punctuation). They then proceeded to leave me hanging for 15 minutes without uttering another word.

Finally, they responded telling me that the node had been shut down due to a suspected DDoS attack on a website in the node.

“Oh…” I typed, trying to coax out some more information as to when it would be resolved.

The support representative once again was silenced for at least another 10 minutes. Once he returned, he simply responded saying that he wasn’t sure when it would be resolved.

Somewhat infuriated, I decided to close the chat.

Eventually, after about 5 hours, the site was back up and running again. My previous anger had diminished by that time, and so I decided to not cease the recurring monthly payment for the hosting.

And then, a mere two days ago, it happened again (or so I thought). The site was inaccessible. This time, I wasn’t really up for contacting support again, I decided it was time to get some new hosting.

I contacted a friend on Skype who hosts a couple of small scale websites and asked what host he uses. He showed me. It’s based in the UK, nice and cheap, looks very professional. I created an account and paid the bill!

Now, I figure it’s time to move all the files to the new host. I try to login to my downed website (forgetting the flaw in my logic there) via FTP, it connected. I then proceed to realise what just happened, and check the site in my browser. However, it still appeared to be down…

I delve a little deeper and discover a flaw in one of my PHP scripts was causing the problem. Well, that’s embarrassing! Turns out this time it wasn’t their fault!

So, now I’ve paid for the new hosting but it turns out that the old one wasn’t broken. I decide to explore the new server (which was setup in about a minute of my payment). I click around in the default directory structure in my FTP client, and the ping is just phenomenal, almost instantaneous!

It turns out that the bill is just cheaper than the US host, too!

So that’s my story on how I decided to migrate my website to a new server! (Also, wow! This post is far longer than I anticipated!)

Theme redesign in progress

EDIT: I have uploaded my theme (24/04/13). Some browser inconsistencies remain, but it currently looks good on modern browsers. I will work on fixing it for older browsers.

The current theme design (as of 18/04/13 and prior) for the blog is slightly modified version of “Twenty Twelve”, WordPress’ default theme. It is widely used across websites running WordPress and isn’t very unique.

I recently stumbled upon SVBTLE, a private blogging network filled with excellent writers and bloggers. The style of the site is beautifully hand crafted, solid, minimalist, and intuitive. It inspired me to redesign my own.

I felt that I needed to learn more about CSS anyway, so I set off to create my own stylesheet from scratch. It’s not as beautiful as svbtle, no. If I wanted to rip off svbtle, I could just download the open-source (recreated) wordpress theme, wp-svbtle.

My intention is to make everything that isn’t the content as unintrusive and unobstructive as possible. Removing the large header for example, allows for immediate viewing of the content without having to scroll down. Sure, I enjoyed designing that header; but it’s bulky and sticks out like a sore thumb.

The new theme, styled from scratch with CSS.

The new theme in development (as of 18/04/13), styled from scratch with CSS.

Old (removed as of 24/04/13) theme for comparison.

I’m still ironing out some kinks, notably cross-browser compatibility. It’s a small CSS stylesheet, with only 40 rules, 280 lines, and 4.63KB (no compression, highly readable). The reason it’s so small is because I have only styled the things I can see currently on the blog. Things I don’t commonly use, or haven’t yet used; I don’t style. In the future, If I include something in a post that is unstyled, I’ll simply load up the stylesheet and style it.

Pretty renders using terrain generator and Blender

I fixed the problem with my heightmap generator and uploaded version 0.20, here are some renders I created to show off the outputs from it.

I imported the heightmaps to Blender and used its beautiful rendering engine “Cycles” to create the images.

Large Landscape rendered in Blender. Terrain rendered in Blender. Green (velvet material in Cycles) terrain rendered in Blender.

Hopefully this will be my final post about the heightmap generator, since it has been the overruling topic of the blog thus far.