Skip to content

Instantly share code, notes, and snippets.

Matthew Eernisse mde

Block or report user

Report or block mde

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:371696
// If foo is true, then we do all this stuff
if (foo) {
// Do foo stuff
}
// This is the stuff that happens in the else case
else {
// asdf here is 'QWER' because we like it
var asdf = 'QWER';
// zoobie ... well, what to say about zoobie
var zoobie = 'FRANG';
View gist:388573
var wm = windmill.jsTest;
var asserts = windmill.controller.asserts;
var test_openProject = new function () {
this.test_click = function () {
wm.actions.click( { link: "Food" } );
};
this.test_wait = { method: "waits.forPageLoad", params: { timeout: "20000" }};
View gist:439523
// Totally naive mixin for demonstration purposes
var mixInProperties = function (to, from) {
for (var p in from) {
to[p] = from[p];
}
}
// Base pseudoclass
var InheritedCodeObj = function (id) {
this.id = id || '(none)';
View gist:462157
var isArray = function (obj) {
return obj &&
typeof obj === 'object' &&
typeof obj.length === 'number' &&
typeof obj.splice === 'function' &&
!(obj.propertyIsEnumerable('length'));
};
View gist:467367
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
div {
border: 1px solid red;
width: 400px;
}
textarea {
margin: 0 -11px;
View gist:654680
node> var parentFunc = function () { this.a = []; };
node> typeof parentFunc;
'function'
node> var foo = new parentFunc();
node> foo;
{ a: [] }
node> var subFunc = function () {};
node> subFunc.prototype = foo;
{ a: [] }
node> var bar = new subFunc();
View assertImageLoaded
var assertImageLoaded = function (img) {
var complete = img.complete;
// Workaround for Safari -- it only supports the
// complete attrib on script-created images
if (typeof complete == 'undefined' || complete === false) {
var test = new Image();
// If the original image was successfully loaded,
// src for new one should be pulled from cache
test.src = img.src;
complete = test.complete;
@mde
mde / gist:967610
Created May 11, 2011
HTML markdown viewer
View gist:967610
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="./showdown.js"></script>
<title>
Markdown Viewer
</title>
<style type="text/css">
@mde
mde / gist:1005311
Created Jun 2, 2011
JS inheritance stuff
View gist:1005311
var MyThing = function () {
this.a = function () {
};
this.b = [];
this.c = 'foo';
};
MyThing.prototype = new (function () {
var MY_SETTING = 2112;
var _myPrivateFunc = function () {
View JavaScript null is a wily beast
js> null > -1;
true
js> null < 1;
true
js> null > 0;
false
js> null < 0;
false
js> null == 0;
false
You can’t perform that action at this time.