Skip to content

Instantly share code, notes, and snippets.

View mplatts's full-sized avatar

Matt Platts mplatts

View GitHub Profile
@mplatts
mplatts / error.js
Created August 26, 2015 02:59
Meteor error explanation
// 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]"
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: '' })
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 13:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mplatts
mplatts / _table.scss
Created May 28, 2014 10:16
_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;
}
.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'
@mplatts
mplatts / teams.coffee
Last active August 29, 2015 14:09
collections 1
# lib/collections/teams.coffee
@Teams = new Mongo.Collection('teams')
@mplatts
mplatts / fixtures.coffee
Last active August 29, 2015 14:09
collections 3
# server/fixtures.coffee
if Teams.find().count() == 0
[
{name: 'Barcelona'}
{name: 'Manchester City'}
].forEach (data) -> Teams.insert(data)
@mplatts
mplatts / mongo.sh
Created November 18, 2014 05:29
collections 4
meteor:PRIMARY> db.teams.find()
{ "name" : "Barcelona", "_id" : "DsjnxpH7ZbEgmwrCY" }
{ "name" : "Manchester City", "_id" : "CbbrW3mLcNLK6vSAL" }
@mplatts
mplatts / main.coffee
Created November 18, 2014 05:31
collections 6
# client/main.coffee
Meteor.subscribe 'teams'