Evil Science A whole load of stuff


Have you wanted to do something a little different with your jQuery UI Tabs?

Go here and be enlightened:


Filed under: jquery No Comments

Notepad++ Emmet jQuery Template

Here's a little addition I've made for the excellent Notepad++ plugin Emmet. It's a shortcut that creates a HTML5 template with a link to jQuery "jquery-2.1.3.min.js" and a "$(document).ready" function, as shown below.


It's straightforwards to do, and requires three additions to Emmet's "snippets.json" file, that is located in the Notepad++ direction "\plugins\EmmetNPP\emmet\".

Addition 1, to the section "snippets", a child of "html":

"jqdocready": "\\$(document).ready(function() {\n\n});"

Additions 2 and 3, to the section "abbreviations", a child of "html":



In situ, the three additions look like this:




Obviously, make changes at your own risk, but if done correctly, this will work. Cheers m'dears,

Filed under: HTML5, Main No Comments

jQuery code hinting in Notepad++

Does what it says on the tin:



Filed under: Development No Comments

FastStone Capture – Windows Screen Capture Tool

FastStone Capture is a powerful, flexible and intuitive screen-capture utility. It allows you to capture anything on the screen including windows, objects, full screen, rectangle regions, freehand-selected regions and scrolling windows/web pages.


Filed under: Main No Comments

Simple C# colour picker

Here's a simple C# colour picker I've created. It's derived from a combobox with a simple override on the OnDrawItem() method. It looks like this:


And you can find it over on my GitHub page.

This contains no error handling, and is simple as it can be, so use it and your own peril. It's not going to make your computer explode, but you know what I mean. Any problems, feed etc drop me a line.

Filed under: C# No Comments

Harry invokes RASHOMON while talking about MALEFICENT!

Harry shows off his impressive ability to skim Wikipedia pages about a movie and then badly compare it to another movie. http://www.aintitcool.com/node/67505

A noteworthy snippet from his review:

Burton’s ALICE IN WONDERLAND is a bizarre strange marvel – and I call it a marvel cuz while watching it…  I marvel at how bizarre it was.




Checking the validity of an NHS Number using 1 line of C#

This article is an implementation of the method for checking NHS Number validity, as described in the article:


This is an experiment to reduce the checking method to one line of code, and makes no attempt at being efficient. This single line, below, is arranged into 8 lines to make it easier to read.

pNHSNumber.ToCharArray().Where (i=> i>= 48 && i <=57).Count() != 10 ? false :
new List() { pNHSNumber.ToCharArray()
.Where((value, index) => index < 9)
.Select((value, index) => (10 - index) * (value - 48))
.Sum() }
.Select(i=> i % 11)
.Select(i=> (11 - i) == 11 ? 0 : (11-i))
.First() == (pNHSNumber[pNHSNumber.Length - 1] - 48);

It is constructed as follows:

  • Line 1: Checking the string length is 10 and consists only of digits
  • Lines 2 - 5:  Multiply the first nine digits by a weighting factor and sum, storing the result, a single value, in a generic list.
    • Line 3 : select the first 9 digits of pNHSNumber.ToCharArray()
    • Line 4: Multiply each of the digits by it's weighting - first digit by 10 e.g. (10 - index of 0), second digit by 9 (e.g. 10 minus index of 1) etc
    • Lin 5: sum the values produced by line 4
  • Line 6: Get the remainder of the sum when divided by 11
  • Line 7: Subtract the remainder from 11, and if the resultant value is 11 change to 0
  • Line 8: Test if the check digit is equal to last digit


Wrap up the above in a function:

bool CheckNNHSNumber (pNHSNumber string)
pNHSNumber.ToCharArray().Where (i=> i>= 48 && i <=57).Count() != 10 ? false :
new List() { pNHSNumber.ToCharArray()
.Where((value, index) => index < 9)
.Select((value, index) => (10 - index) * (value - 48))
.Sum() }
.Select(i=> i % 11)
.Select(i=> (11 - i) == 11 ? 0 : (11-i))
.First() == (pNHSNumber[pNHSNumber.Length - 1] - 48);

and call it, thusly:

//valid NHS number

//invalid NHS Number

Filed under: C#, Main No Comments

Doctor Who missing episode totals by year


The above says it all - the number of episodes of Doctor Who missing by year, the reason for the drop is due to pure look and the dedication of Doctor Who fans in searching for missing episodes.

For more information, go to The Destruction of Time: What Is Missing.

Tagged as: No Comments

iPlayer Automator – download BBC iPlayer programs

Currently, Get iPlayer Automator allows you to download and watch BBC & ITV shows on your Mac. Series-Link/PVR functionality ensures you will never miss your favourite shows. Programmes are fully tagged and added to iTunes automatically upon completion. It is simple and easy to use, and runs on any machine running Mac OS X 10.6 or later.




Filed under: Mac No Comments

C# Brute Force Sudoku Algorithm

I've created in C# an algorithm that solves sudoku using the brute force method. This algorithm is contained in the class csSudokuBruteForce.cs that can be found on GitHub here.

A little bit about it

The csSudokuBruteForce class contains a class called csCell which represents a cell within a sudoku grid with properties representing the row, column, box that cell belongs to, the cell's value and whether it is solved; 81 of these cells are stored within a generic list called grid which represent sudoku.

The public method BruteForce is called to begin the brute algorithm, which returns a integer array representing the solved sudoku. Testing on Quad core PC shows that solutions can be found in under a second for any tried.

This algorithm doesn't test the validity of the provided sudoku before it starts the brute force algorithm, and may therefore crash out if what is given to it is incomplete, malformed, containing incorrect characters. It just assumes it'll get a string 81 characters in length that consists of only the numbers 1 to 9 and 0.

Using the code

This class is easy to use, and requires only a string of 81 characters representing the sudoku to be solved.  Here's an example of it's use:

csSudokuBruteForce b = new csSudokuBruteForce();

<span style="line-height: 1.5em;">string puzzle = "003020600900305001001806400008102900700000008006708200002609500800203009005010300";</span>

//solve the sudoku and return the result as an integer array

int [] solution =  b.BruteForce(puzzle);

If you're using this code in a C# Console Application and want to output the array containing the solution, here's how to do it using Linq:

Console.WriteLine (
solution.Select((val, ind) => val.ToString() + ((ind+1) % 9 == 0 ? "\n" : ""))
.Aggregate((total, current) => total + current)

What about Project Euler 96?

No. I'm not going to tell you how to to solve it.

Go on!



I'll give you a hand, but no more. Here's how to extract one puzzle at a time from Euler 96's text file of puzzles:

//load the entire sudoku.txt file
List<string> puzzles = new StreamReader("sudoku.txt").sr.ReadToEnd().Split('\n').ToList();

string puzzle;

for (int ctr = 0; ctr <= 49; ctr++)</span>

puzzle = puzzles.Where((val, ind) => ind >= (ctr * 10) +1 &amp;amp;amp; ind < (ctr * 10) +10)
.Aggregate((total, current) => total + current);


It uses loads the text file into a generic list, and then uses Linq to extract the required data from that file. Use your brain and work out how to use it yourself.

You're welcome.

Filed under: C# No Comments