Skip to content

Instantly share code, notes, and snippets.

View ceth-x86's full-sized avatar

ceth ceth-x86

  • Amsterdam, Netherlands
View GitHub Profile
@ceth-x86
ceth-x86 / gist:5309314
Created April 4, 2013 10:19
QUnit : integrating with DOM
module("module 2", {
setup: function() {
$("body").append("<div id='div1'>some text</div>");
},
teardown: function() {
$("#div1").remove();
}
});
test("integrating with DOM", function() {
@ceth-x86
ceth-x86 / suite.html
Last active December 15, 2015 19:09
QUnit : Minimal example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>QUnit Example</title>
<link rel="stylesheet" href="qunit.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
@ceth-x86
ceth-x86 / tests.js
Last active December 15, 2015 19:09
QUnit : Tests organization
module("module 1");
test("my first test", function() {
ok(true);
});
module("module 2", {
setup: function() {
},
@ceth-x86
ceth-x86 / rest.rb
Created April 5, 2013 10:56
Exploring Everyday Things : Offices and Restrooms
DURATION = 9 * 60 # minutes
class Restroom
attr_reader :queue
attr_reader :facilities
def initialize(facilities_per_restroom = 3)
@queue = []
@facilities = []
facilities_per_restroom.times { @facilities << Facility.new }
@ceth-x86
ceth-x86 / gist:5336353
Created April 8, 2013 12:11
Javascript : include js
<head>
...
<script type="text/javascript" src="some.js"></script>
</head>
@ceth-x86
ceth-x86 / module.js
Created April 8, 2013 12:25
Backbone : Simple model
var Person = Backbone.Model.extend({
defaults: {
name: 'Nikola',
age: 40,
job: 'developer'
},
work: function() {
return this.get('name') + ' is working.';
}
@ceth-x86
ceth-x86 / module.js
Created April 8, 2013 12:52
Backbone : simple view
var Person = Backbone.Model.extend({
defaults: {
name: 'Nikola',
age: 40,
job: 'developer'
},
work: function() {
return this.get('name') + ' is working.';
}
@ceth-x86
ceth-x86 / script.js
Created April 9, 2013 08:13
Javascript : Create simple object
// first method
function MyClass() {
this.name = "test class";
}
var s = new MyClass();
s.name = "some";
// another one method (old-style)
@ceth-x86
ceth-x86 / script.js
Created April 9, 2013 08:17
Javascript : Prototype method
function MyClass(name) {
this.name = name;
}
MyClass.prototype.say_hello = function() {
alert(this.name);
}
var s = new MyClass("hello");
s.say_hello();
@ceth-x86
ceth-x86 / script.js
Created April 9, 2013 08:23
Javascript : Dynamically Selecting a Method / Property
function MyClass(name) {
this.name = name;
}
MyClass.prototype.say_hello = function() {
alert(this.name);
}
MyClass.prototype.say_something = function(phrase) {
this.name = phrase;