Skip to content

Instantly share code, notes, and snippets.

View JamieKnight's full-sized avatar

Jamie Knight JamieKnight

View GitHub Profile
@JamieKnight
JamieKnight / panel.html
Created April 21, 2013 15:27
JS prototypes and inheritance. testing argument to preserve require argument tests.
<!doctype>
<html>
<head>
</head>
<body>
<h1> Inheretence testing</h1>
<script type="text/javascript">
//base object
@JamieKnight
JamieKnight / instance.js
Created April 10, 2013 14:53
instance of in jasmine
it("Should accept a DOM node as paramater 1", function() {
var node = document.createElement("div");
var draw = new Drawer(node)
expect(draw instanceof Drawer).toBeTruthy();
});
@JamieKnight
JamieKnight / drawerTests.js
Created April 10, 2013 13:14
RadioNav Code Review - Drawer & Panel Tests (WIP)
define("drawerTest", ['Drawer', "Panel"], function(Drawer, Panel) {
//Object init - no parameters
describe("Radionav Drawer object", function(){
describe("Contructor accepts correct paramaters", function(){
it("Should accept a DOM node as paramater 1", function() {
var node = document.createElement("div");
var draw = new Drawer(node)
expect(draw instanceof Drawer).toBeTruthy();
@JamieKnight
JamieKnight / gist:5310634
Created April 4, 2013 14:05
Errors building Servo on 10.8.2
ompile_and_link: x86_64-apple-darwin/stage2/lib/rustc/x86_64-apple-darwin/lib/librust.dylib
warning: no debug symbols in executable (-arch x86_64)
/Users/jamie/servo/build/src/rust/x86_64-apple-darwin/stage2/bin/rustc -A default_methods -O /Users/jamie/servo/src/rust-cocoa/cocoa.rc -o libcocoa.dummy
/Users/jamie/servo/src/rust-cocoa/base.rs:1:4: 1:8 warning: unused import
/Users/jamie/servo/src/rust-cocoa/base.rs:1 use std;
^~~~
warning: no debug symbols in executable (-arch x86_64)
touch libcocoa.dummy
/Users/jamie/servo/build/src/rust/x86_64-apple-darwin/stage2/bin/rustc -A default_methods -O /Users/jamie/servo/src/rust-core-foundation/core_foundation.rc -o librustcorefoundation.dummy
/Users/jamie/servo/src/rust-core-foundation/array.rs:29:42: 29:43 error: obsolete syntax: visibility-qualified trait implementation
@JamieKnight
JamieKnight / gist:4280942
Created December 13, 2012 23:02
Needed a single loop capable of looping from 0 - 255 and 255 to 0 for a LED fading function. If the type is "up" then i want it to go from 0 to 255, if the direction is down then i want it to go from 255 to 0. One loop, two directions no repeated code.
//better soltion
void fade(char type[], int pins[],){
//step though brightness in 255 steps, going up or down
for (int i = 0; i < 255; i++ ) {
int intensity = i;
if (type == "down") intensity = 255 - i;
//loop for each group of LEDs
for (int thisPin = 0; thisPin < 3; thisPin++) {
analogWrite(pins[thisPin], intensity);
@JamieKnight
JamieKnight / UpdateFromArray
Created May 18, 2011 19:43
A simple method to update properties from array returned buy $query->result()
function updateFromArray($array){
foreach($array as $property => $value){
if(property_exists( $this, $property)){
$this->$property = $value;
}
}