Skip to content

Instantly share code, notes, and snippets.

View stubotnik's full-sized avatar

Stu Gray stubotnik

  • Dublin, Ireland
View GitHub Profile
@stubotnik
stubotnik / app.rb
Created September 21, 2012 08:58
uninitialized constant error
class MyProject < Padrino::Application
register Padrino::Rendering
register Padrino::Mailer
register Padrino::Helpers
MY_CONST = 123
end
@stubotnik
stubotnik / minesweeper.rb
Created July 20, 2012 14:41
Minesweeper Kata
module Minesweeper
class Game
attr_reader :fields
def initialize
@fields = []
@allow_input = true
@stubotnik
stubotnik / DynResourceLoader.js
Created July 19, 2012 07:41
Dynamic resource loading with LAB.js
DynResourceLoader = Class.create({
initialize: function () {
document.observe("custom:pageAddedToDOM", this.load.bind(this));
},
load: function (e) {
var page = e.memo;
if (page.hasAttribute("data-required-js")) {
@stubotnik
stubotnik / z-indexes.scss
Created July 11, 2012 13:13
Manage complex z-index layouts with SASS variables
$pages-z-index: 1;
$menu-z-index: $pages-z-index - 1;
$betcard-mask-z-index: $pages-z-index + 1;
$betcard-z-index: $betcard-mask-z-index + 1;
$header-z-index: $betcard-z-index + 1;
$alert-dialog-z-index: $header-z-index + 1;
$betcard-delay-z-index: $alert-dialog-z-index + 1;
$ajax-blocker-z-index: $betcard-delay-z-index;
@stubotnik
stubotnik / auto-pop.js
Created April 3, 2012 15:13
Auto-populate sign-up
(function(){
$("firstName").value = "Joe";
$("lastName").value = "Test";
$("email").value = $("emailConfirm").value = "user" + Math.round(Math.random() * 1000000) + "@example.com";
$("birthMonth").selectedIndex = 1;
$("birthDate").selectedIndex = 2;
$("birthYear").selectedIndex = 10;
$("phone").value = "123456789"
$("accName").value = "Tst" + Math.round(Math.random() * 1000000);
$("pwd").value = $("pwdConfirm").value = "Tester1234";
@stubotnik
stubotnik / kt.rb
Created February 10, 2012 16:44
Knights Tour
# Knights Tour - unpolished
module KnightsTour
class Game
def initialize (boardHeight, boardWidth)
@board = Array.new(boardHeight) {Array.new(boardWidth, 0)}
@moveCounter = 0;
end
@stubotnik
stubotnik / xAjaxRequest.js
Created December 2, 2011 16:46
pre-onComplete handler for all Ajax requests
xAjaxRequest = Class.create({
initialize: function (url, options) {
//if the request has a callback, wrap that in our own callback
if (typeof options.onComplete == "function") {
var f = options.onComplete;
options.onComplete =