Skip to content

Instantly share code, notes, and snippets.

<body>
  <div>
		<header>
			<h1 id="title"><em><a href="/">Hello world!</a></em></h1>
		</header>
		<section>
			<ul>
				<li class="item"><a href="#">Navigation Item</a></li>
 <a href="#">Navigation Item</a>
@adriancooney
adriancooney / sudoku.js
Created April 20, 2012 21:13
Generate a sudoku game
var sudoku = [], iterationCount = 0;
function check(type, pos, num) {
var bool = false;
for(var i = 0; i < 9; i++) {
var tile = (type === 1) ? (pos * 9) + i : //row
(type === 2) ? (i * 9) + pos : null; //Column
(((((pos - (pos % 3))/3) * 3)) * 9) + ((((pos % 3) * 3)) + (i % 3)); //Quadrant
@adriancooney
adriancooney / Array2D.js
Created April 4, 2012 13:52
Javascript 2D Array
/* Extremely simple definition of a 2D array in Javascript. Javascript doesn't allow for a match-all getter so a length has to be defined. This defines the height or rows of the array but not the width; the width or columns is as big as you want it to be, sugar. For some odd reason, the __defineGetter__ doesn't send the name of the current "get" to the callback (which is silly in my opinion for situations exactly like these) so I had to convert the functions to strings. */
var Array2D = function(l) {
if(!l) throw new Error("Please specify a length for your Array2D");
this.arr = [];
this.definedLength = l;
for(var i = 0; i < l; i++) {
this.__defineGetter__(i, Function("var i = " + i + ";if(!this.arr[i]) this.arr[i] = [];return this.arr[i];"));
}