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
@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">
View ember_obj_serialize.txt
var Foo = Ember.Object.extend({zerb: function () {}});
undefined
var bar = Foo.create();
undefined
JSON.stringify(bar);
"{}"
bar.set('asdf', 'ASDF');
Class {asdf: "ASDF", __ember1458770221107: null, __nextSuper: undefined, __ember_meta__: Object}
JSON.stringify(bar);
"{"asdf":"ASDF"}"
@mde
mde / gist:7810003
Last active Dec 30, 2015
"foo" task for creating a new Foo instance
View gist:7810003
task('foo', {async: true}, function () {
var f = geddy.model.Foo.create({title: 'zerb', description: 'frang'});
f.save(function (err, data) {
if (err) { throw err; }
geddy.model.Foo.all({id: f.id}, function (err, data) {
if (err) { throw err; }
console.log('Found foo', data[0].id);
geddy.model.Foo.first({id: f.id}, function (err, data) {
if (err) { throw err; }
console.log('Found foo again', data.id);
View model-hasMany-error.js
var
// $ npm install model@0.2.10
model = require( 'model'),
Adapter = require('./node_modules/model/lib/adapters/memory/').Adapter,
adapter = new Adapter({});
var User = function () {
this.adapter = adapter;
this.property('login', 'string', {required: true});
this.property('password', 'string', {required: true});
View gist:6237190
// Determine if `content` is a collection of models
else if(content instanceof Array) {
if(!type) {
throw new Error(
'Cannot determine model type from empty array, specify one in opts');
}
@mde
mde / gist:6223332
Created Aug 13, 2013
Two overlapping experiments
View gist:6223332
<%
var msg = '';
if (testA) {
msg += '<div>group</div>';
}
if (testB || testA) {
msg += '<div>conversation</div>';
}
%>
<%= msg; %>
View gist:6100679
var User = function () {
this.hasMany('Messages');
this.hasMany('ConversationMemberships');
this.hasMany('Conversations', {through: 'ConversationMembership'});
};
var Conversation = function () {
this.hasMany('Messages');
this.hasMany('ConversationMemberships');
this.hasMany('Users', {through: 'ConversationMembership'});
@mde
mde / gist:6100608
Created Jul 28, 2013
Istanbul output
View gist:6100608
♢ cli
when given a config file
✓ should load the specified config file
when calling execute more than once
✓ should not print the results from previous execution
♢ eslint
@mde
mde / gist:6040868
Created Jul 19, 2013
geddy gen secret
View gist:6040868
mdes-mbp-2:work mde$ geddy gen app foo
Created app foo.
mdes-mbp-2:work mde$ cd foo/
mdes-mbp-2:foo mde$ geddy gen secret
Added app-secret to config/secrets.json.
DO NOT add this file into your revision control.
DO make a backup of it, keep it someplace safe.
mdes-mbp-2:foo mde$ geddy -v
0.9.8
@mde
mde / gist:5476069
Created Apr 28, 2013
Templater race
View gist:5476069
templater.addListener('data', function (data) {
// Buffer for now, but we could stream
content += data;
});
templater.addListener('end', function () {
if (self.params.action == 'test') {
if (content.indexOf('Hello') > -1) {
console.log(self.params.action);
throw new Error();
}
You can’t perform that action at this time.