Skip to content

Instantly share code, notes, and snippets.

@mplatts
mplatts / error.js
Created Aug 26, 2015
Meteor error explanation
View error.js
// see http://docs.meteor.com/#/full/meteor_error
var error = new Meteor.Error('error-name', 'reason');
alert(error) //=> Error: reason [error-name]
alert(error.reason) //=> reason
alert(error.error) //=> error-name
// Explanation.. alert(error) is the same as going alert(error.toString()), which results in "Error: error.reason [error.error]"
View models_assignment_topic.coffee
class App.Models.Assignment.AssignmentTopic extends Backbone.Model
loading: -> @get('loading') || false
questionsRemainingCount: -> @get('questions_count') - @get('questions_answered_count')
questionsRemaining: -> @get('status') == 'try_it_again' || @get('status') == 'in_progress'
className: -> (@get('status') || '').replace(/_/g, '-')
scores: ->
if !@get('scores') || @get('scores').length == 0
i = @get('questions_count')
_([0..i]).map(-> { success: false, className: '' })
View bundles.coffee
class App.Collections.Bundles extends Backbone.Collection
url: '...'
parse: (results) ->
_(results).each (result) -> result.topics_count = result.topic_ids.length
results
@mplatts
mplatts / 0_reuse_code.js
Created May 14, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View _table.scss
$table-border: darken($gray-lighter, 10%);
$table-bg: mix($gray-lighter, $white);
.table {
background-color: $table-bg;
border-collapse: separate;
tr > *:first-child {
border-left: solid 1px $table-border;
}
View hb.haml
.dropdown
.email
%i.sprites-common-student
{{ email }}
= hb 'if pending' do
%a.resend-invitation{href: "#"} {{t 'organization.teachers.index.resend_invitation'}}
%a.pull-right.show-modal{href: "#", data: {template: 'people/remove_invited_teacher_modal', title: "{{t 'organization.teachers.index.remove_teacher' name=email }}"}}
%i.sprites-common-close
= hb 'else'
View team.html
<!-- client/views/team.html -->
<template name="team">
<li>
{{#if editing}}
<form class="form-edit">
<input name="name" type="text" value="{{name}}">
<button type="submit">Submit</button>
<a class="cancel" href="#">Cancel</a>
</form>
View main.html
<!-- /client/main.html -->
<head>
<title>Foosboom</title>
</head>
<body>
<h1>Foosboom</h1>
</body>
View team.coffee
# client/views/team.coffee
Template.team.helpers
editing: -> Session.get('editing') == @_id
Template.team.events
"click .edit": (e, tpl) ->
e.preventDefault()
Session.set('editing', @_id)
View teams.html
<!-- /client/views/teams.html -->
<template name="teams">
<h3>Teams</h3>
</template>
You can’t perform that action at this time.