Posts

Showing posts from 2013

Three.js Tutorials

Image

Three.js - 2 - Getting Started Part 2

Image
Three.js - 2 - Getting Started Part TwoTHREE.JS TUTORIALS
VIEW THE DEMO

DOWNLOAD THE SOURCE CODE Introduction In the last tutorial we got a very basic three.js application up and running. This tutorial will continue on from that, adding a stats counter and dealing with window resizing. Stats Counter A number of the example three.js applications have a neat little stats counter showing the number of frames per second, and displaying a graph of the frame rate over the last few seconds. This information is invaluable when testing the performance of your 3D application.
The JavaScript library responsible for this stats counter is not actually part of three.js. It is a separate library that can be found on GitHub at https://github.com/mrdoob/stats.js/. The file that we need to include in our project can be found at https://github.com/mrdoob/stats.js/blob/master/build/stats.min.jshttps://github.com/mrdoob/stats.js/blob/master/build/stats.min.js. This JavaScript file is included lik…

MinHash for dummies

Duplicate document detection is becoming increasingly important for businesses that have huge collections of email, web pages and documents with multiple copies that may or may not be kept up to date.

MinHash is a fairly simple algorithm that from all my Googling has been explained very poorly in blogs or in the kind of mathematical terms that I forgot long ago. So in this article I will attempt to explain how MinHash works at a practical code level.

Before I start, please take a look at http://infolab.stanford.edu/~ullman/mmds/ch3.pdf. That document goes into a lot of theory, and was ultimately where my understanding on MinHash came from. Unfortunately it approaches the algorithm from a theoretical standpoint, but if I gloss over some aspect of the MinHash algorithm here, you will almost certainly find a fuller explanation in the PDF.

I'll also be using pseudo Java in these examples instead of traditional math. This means when I use terms like Set, I am referring to the group of …

Three.js 1 - Getting Started

Image
Three.js - 1 - Getting StartedTHREE.JS TUTORIALS

VIEW THE DEMO

DOWNLOAD THE SOURCE CODE
Introduction After Apple's war on Flash, relying on plugins in your web pages is just not a viable option. Flash (and maybe, thanks to Netflix, Silverlight) were the last of a dying breed of browser plugins. In their place are a host of new technologies being standardised as part of HTML5.

WebGL is one of these technologies, and is supported by all major browsers. Microsoft is even getting on board with IE 11. Combine that with the ever increasing performance of JavaScript engines and it is now possible to create some impressive 3D applications in a web browser without the aid of plugins.

Three.js is one of the more powerful and mature JavaScript 3D engines available. This article will show you how to get a simple 3D application running with three.js.
What to download Using three.js requires only a single JavaScript file called three.min.js. You can grab the latest version of file from GitHub.
T…

Stopping emails in the new Gmail tabs from showing up in new mail counts

Image
I love the new tabbed interface in Gmail. To be blunt, email clients have done a very poor job of dealing with the increasing volume and variety of email that people get nowadays, and it is nice to see Gmail implementing simple and effective solutions.

The one problem I have with the new interface is that email that was simply going to spam is now being categorised and filed under these tabs, and their existence is contributing to the number I see in my Chrome Gmail monitoring extension. It became impossible to know when I have mail that I was actually interested in, because the little icon in my browser was always showing 100+ new emails.

I initially tried to setup a filter, but nothing I could type into the new filter dialog would allow me to set emails sent to the categories to be marked as read.

But I soon tweaked that you can create a filter from a search, and you can search based on categories.


And with that, any email sent to one of the new tabs can be marked as read, leaving y…

Exporting from MySQL to H2

Image
When it comes to testing, you can't beat the convenience of an embedded database. It can be created, populated and cleaned up without any dependencies on outside infrastructure, making it ideal for self contained test suites.

However, there is a very good chance that you don't use an embedded database in your production environment. In my case, I have a MySQL database in production, and want to use H2 in testing.

Getting data from MySQL into H2 is not as straight forward as you might think. You might have some luck with CopyDB, Scriptella, or OpenDBCopy. But in the end I simply used mysqldump and a couple of hacks to get data from MySQL to H2.
Dump the dataDump the data from MySQL with the following command:

mysqldump --compatible=ansi,no_table_options,no_field_options,no_key_options --hex-blob --skip-opt -uroot -p Database > importansi.sql

This will strip out most of the MySQL specific syntax and give you something that you can clean up for H2 to import.


Fix up single quotes…

Setting up a MariaDB Galera cluster in Centos 6

Image
SynopsisOne of the big draw cards of MariaDB over MySQL is open source support for clustering. While the open source version of MySQL allows for replication amongst a number of read only nodes, MariaDB has true multi-master replication.

If you have read the documentation at https://kb.askmonty.org/en/getting-started-with-mariadb-galera-cluster/, you could be forgiven for believing that setting up a cluster is a trivial process. Unfortunately those instructions leave out a few vital details that will prevent your cluster from working. These are the steps I used to get a MariaDB Galera Cluster running in Centos 6.


Configure the YUM repo
Go to https://downloads.mariadb.org/mariadb/repositories/ and select Centos as the OS, and 5.5 as the version. Galera (the clustering component of MariaDB) is only available with version 5.5 at this time.

I have the 64 bit version of Centos, so the resulting file looks like this:

# MariaDB 5.5 CentOS repository list - created 2013-07-03 04:40 UTC
# http://m…

Emscripten - the saviour we have been waiting for?

Turn the clock back a few years and listen to the promise of this new language called Java. "Write once, run anywhere" was going to change the way developers wrote applications. It didn't matter what OS, browser or device you were using, Java was going to be there.

It didn't quite work out that way. Most mobile devices don't run the garden variety of Java (Android certainly relies on Java, but much to Oracle's disgust, it is not their Java), I haven't seen an applet based website in years, and even desktop Java applications are hard to come by if you are not a developer.

It was JavaScript that won the battle for the ubiquitous development platform. Speed and functionality still varies between devices, but if you want to write code that at least has a chance of running everywhere, JavaScript is your best choice.

The problem with JavaScript is that it lacks a lot of the libraries that other languages have had years to build up. This void is something that e…

The day I left "mainstream" news forever

news.com.au (NCA) is a news website run by News Limited (part of the same group of companies now well known for hacking famous voice mails), and was my last tie to the world of traditional news.

It was a little guilty pleasure. Their focus was solely on catchy headlines and simple pieces of reporting that worked well for those like me looking for a five minute break. And their penchant for attaching bikini shots to any story even remotely related to the human body was also quite entertaining.

Then one day NCA decided to fill the space that bordered the central main content column with ads. That in itself was not unlike a lot of big web sites. But they also chose to open the ad when you clicked anywhere in that border, even if you had scrolled down well past the actual ad content and the border  just displayed white space. It was a devious tactic, as I found that I usually switched back to a browser window not by clicking the window's title bar, but by clicking in some white space …

Ubuntu phone - the first truly unified platform?

The Ubuntu phone OS has been announced, replacing the old "Ubuntu for Android" initiative that seems to have been all but abandoned. Frankly I'm not surprised that Ubuntu for Android didn't gain much traction, as the concept had a number of limitations that made it a burden instead of adding value. But the Ubuntu phone OS is another story.

From the information made available in the Canonical press release, it seems that the Ubuntu phone OS is a fully fledged version of Ubuntu that can be installed directly onto a smartphone. It is a single set of apps and single configuration that presents a tailored interface depending on whether your phone is docked or standalone.

It's no stretch to say that the current computing experience provided across desktops, laptops, tables and smartphones is disjointed at best. What you do on a particular device is still determined more by the OS it is running and the configuration that you have taken the time to (re)implement than the…