Speed Reading

There has been a lot of forum buzz about a new speed reading app which is getting built into the new line of Samsung Phones (the upcoming Galaxy S5 etc) named Spritz. Given the fact that Reuters estimated that the marketing budget for Samsung was $14 billion in 2013 (although one can never trust such sensational figures) it is not so far fetched to believe that some of this buzz is down to viral marketing.

That said, it’s a neat little demo page (Spritz Inc) they’ve set up for it (go try it out now!) and it seems they are intent on spreading their product around with their dev kit package including SDKs and APIs for Android, iOS, and JavaScript. The phone depicted in the main banner also appears to be a HTC One:


So: to the functionality!

They claim that there’s a lot of people ‘spritzing’ at over 1000wpm already but the maximum value available on the site is 600wpm. I can manage the 600wpm setting well enough, although the sample text isn’t really enough to get a feel of what its like to read like this for long periods of time, and my suspicions are aroused by their >1000wpm claims since at The World Championship Speed Reading Competition the top contestants usually clock in at about 1k-2k wpm with only ~50% comprehension. According to a study in The Journal of Behavioral Optometry the average person with a spot of training can identify an image that flashed on a screen in about 2 ms which translates to about 500 words per second, or 30k wpm. I doubt this translates well for series of words but the potential is there I suppose.

    Reading Reimagined™

Except not really. My dad is a speed reader and I asked him what he thought of this and he told me its an old concept called ‘Meta Guiding’ and says there have been various software and hardware solutions that aim at a similar effect. In fact it turns out that there are two main speed reading training strategies in use today, Subvocalisation and Meta Guiding.

Subvocalisation is the practice of repressing the instinct to ‘say’ the words in your head as you read and examine each one, speed readers claim internally pronouncing the words takes up time and ‘processing power’.

Meta Guiding is basically directing the eye at what to look at, and is tied up closely with the history of devices used to aid speed reading. It began in the 1950s with Evelyn Wood who realised that using her hand as a guide in a sweeping motion allowed her to read significantly faster.

Caveats aside, I think the idea is captivating and I look forward to trying it out on higher speeds and for longer periods. I might knock an android app together to replicate the functionality. The mechanics of it shouldn’t be too complicated (spitting out a text file, word by word to a center aligned text view with various thread.wait values should be good enough to try it out for longer periods)

OK, signing off. Have fun with the demo, let me know if you want to try out the homebrew version.


Generating Lists of unique random Integers in a range (Java)

In a recent project it was required to generate a list of random Integers in a range (in our case the Integers had to have a value of less than 100,000 such that they were a maximum of 5 digits).

While the java.util.Random class will return random integers in a range with a method call with an argument of the maximum value you want (eg. Integer randInt = rand.nextInt(100); will return an integer in the range 0..99 inclusive, where “rand” is a previously declared instance of the Random class) and these integers will have an approximately even distribution, they will not be unique. ie. some numbers will be repeated.

It was initially tempting to use an array of integers and use the random values to pull those integers out replacing them with a dummy value which would indicate that they had been used but, thinking about it a little more, I decided that there was a more efficient way to do it: take a look!

import java.util.*;

public class Uniques {
	private final int MAX = 1000;
	private Random rand = new Random();
	private boolean [] bools = new boolean [MAX];
	private Integer placeholder;
	public List<Integer> uniqueRandomList =  new ArrayList<Integer>();
	public Uniques()
		for(int i = 0; i < 200; i++)
			bools[placeholder] = true;

	public static void main(String[] args) 
		Uniques uni = new Uniques();

Here I’m using an array of 1,000 boolean values (so that the resulting list will be 3 digit numbers). While an individual boolean value takes up 32 bits in java, an array of them uses only 1 bit per array entry. This saves us a decent amount of memory space compared to an int array which is 32 bits per entry.

This class gives us a public accessible list of 200 entries, each 3 digits (999 maximum value).

The meat of the algorithm is in the lines:

bools[placeholder] = true;

The first line keeps selecting new locations in the boolean array until it finds one that is false, meaning that it hasn’t been used yet, the next line just sets that same location in the array to true to indicate that it has been used.

You can then safely add the integer to your list assured in the knowledge that it is unique.

As always: I’m looking for feedback or better ways to do this.

Signing out for now!

Stack Implementation in C

As an exercise I decided to combine my Data Structures class which is taught mostly through the medium of the Java programming language and my Procedural Programming class using C.  I built a stack implementation based on a linked list

#include <stdio.h>
#include <stdlib.h>

struct node* peek(struct stack *stk);
struct node* pop(struct stack *stk);
void push(struct stack *stk, struct node *n);

struct node
	//you could put any variables you like in here and be able to use the stack the same
	int index;
	struct node *next;

struct stack
	//basically just a variable pointing to the head of the linked list
	struct node *head;

void main()
	int i;
	struct node n, x;
	struct stack stackyStack;

	stackyStack.head = &n;
	printf("test: %d\n", peek(&stackyStack)->index);

	for(i = 1; i < 10; i++)
		push(&stackyStack, &x);
		printf("test: %d\n", peek(&stackyStack)->index);

	for(i = 9; i >= 0; i--)
		printf("pop pop! %d\n", pop(&stackyStack)->index);


struct node* peek(struct stack *stk)
	//shows the contents of the top of the stack without removal
	return stk->head;

struct node* pop(struct stack *stk)
	struct stack newstk = *stk;
	struct node tmp; 

	//store the current head in local variable
	tmp = *newstk.head;

	//making the top of the stack be where the current head is pointing
	stk->head = stk->head->next;
	return &tmp;

void push(struct stack *stk, struct node *n)
	//allocate new memory of node size for dynamically growing stack
	struct node* tmp = (struct node*)malloc(sizeof(struct node));

	//fill info in new node
	tmp->index = n->index;
	//point the new node to the old head
	tmp->next = stk->head;
	//make the new node the head of the stack
	stk->head = tmp;


My next project with it is to make it a character stack and then use it in a program capable of evaluating basic arithmetic expressions or convert arithmetic expressions to inverse polish notation.

I still have to get round to fixing the memory allocation issue but I have decided to do that when I make it into a header file and have to fix the return types etc.

Any feedback or pointers welcome as usual!

Array of Functions in C

This question came up today in a procedural programming class: Is it possible to have an array of functions in C?

The short answer is: yes, but the long answer is: why?

I haven’t really thought of a use for this other than a menu situation where you don’t want to write a switch statement, but you also have to have the same return type and argument format for each of the functions.

#include <stdio.h>
#include <stdlib.h>

void functionOne();
void functionTwo();
void functionZero();

void (*funArray[3])() = {functionZero, functionOne, functionTwo};

int main()
    int choice;

        printf("\nEnter Choice (0 - 2): ");
        scanf_s("%d", &amp;choice);
    }while(choice &lt; 0 || choice &gt; 2);

    return 0;

void functionZero()
    printf("\nFunction 0 executing!\n");

void functionOne()
    printf("\nFunction 1 executing!\n");

void functionTwo()
    printf("\nFunction 2 executing!\n");

This was done in Visual Studio 2010 since I was being absolutely heretical. Forgive them, they know not what they do. I guess its more of an array of pointers than functions but hey, what do you want?

It does work though!

The Question remains: Why?

If anyone has any good ideas for uses of this I’d love to hear about them.

Customising the Firefox Interface with CSS and userchrome

OK, so you like Firefox but maybe you don’t like something about the user interface?

For example I am always bothered by the fact that the search bar is redundant these days since you can search from the navigation bar and change the search engine which is used there via about:config. Having removed the search panel however, I am left with a navigation bar which is now the full width of the screen (1920 pixels!). Again this seems completely redundant.

I am generally a ‘pruner’: meaning I keep the number of open tabs to a minimum, compulsively closing those that I am not using. I heard this terminology from a Visual Studio dev, the other main category that people fall into being a ‘flusher’ who keeps opening more windows and tabs until it becomes unworkable and they have to close everything and start again. So I generally don’t need all the space on my tab bar either; wouldn’t it be nice if I could have everything on one line, freeing up some much needed vertical real estate for actual web content?

Well, thanks to the customisability of the Firefox UI, I can do this easily with a bit of CSS in UserChrome.css!

The UserChrome file is used to control elements of the Firefox UI using CSS code. While it doesn’t exist by default, you can create it yourself with your text editor of choice in your firefox Profile folder:

On Windows, it lives in your Application Data folder with a path like: C:\Documents and Settings\XXXXXXX\Application Data\Mozilla\Firefox\Profiles\chrome\userchrome.css

Under Linux it lives in a similar location in your home folder ~/.mozilla/firefox/XXXXX.default/chrome/userchrome.css

But fortunately there is an easier way to take care of this without needing to go mucking about in your filesystem, and it has the added bonus of not needing to restart your browser every time to see the effects of the changes you make. For this you need to install the Stylish Firefox Add On:


This is a great little add on that lets you make custom CSS for whatever sites you like and has a big library of styles made by others which you can install easily with absolutely no need for CSS knowledge required. It also allows you to modify the UI.

Having installed Stylish, create a new blank style under the ‘Manage Styles’ section and then add the following:

/*tells firefox this applies to UI*/
@-moz-document url-prefix('chrome://')
    /*removes tab icons*/
        display: none !important;

    /*shortens navigation bar*/
        max-width: 300px !important;

You should be able to hit preview and see the effects of this immediately. It’ll look a bit messy at first, but all there is left to do is move around some stuff  using the toolbar customisation tool (right click any toolbar, move your url bar and accompanying buttons to the top left of the tab bar and then set firefox to not display the navbar.

Here’s mine that I’ve just done with a portable Waterfox (a 64 bit variant of Firefox for windows; highly recommended):


As you might imagine, there is almost no limitation to what you can do with this, you can change all colours, sizes and shapes just like you can with html elements using css, you just have to learn all their names.

Happy Hacking.

Hello World!

Hi all, welcome to my blog where I will be posting technology related pieces on a (hopefully) weekly schedule!

My first blog is going to be about customising the Firefox (and browsers forked from Firefox) interface using Cascading Style Sheets (CSS) using your userchrome.css file and other methods.

Stay tuned!