Skip to content

Instantly share code, notes, and snippets.

View mplatts's full-sized avatar

Matt Platts mplatts

View GitHub Profile
@mplatts
mplatts / gr
Created November 9, 2011 02:39
fg
rgregr
@mplatts
mplatts / rspec-syntax-cheat-sheet.rb
Created January 9, 2012 23:59 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# Edited by webtempest.com
# ====================== Rails examples =====================
# ---------------------- Login Support -------------------------
module LoginSupport
# Fake a login for Controller specs
def fake_login_as(user)
@request.session[:user_id] = user ? user.id : nil
@mplatts
mplatts / edit.html.erb_spec.rb
Created January 10, 2012 07:07
Rspec 2 Rails Samples
require 'spec_helper'
describe "cats/edit" do
before(:each) do
@cat = assign(:cat, stub_model(Cat,
:name => "MyString"
))
end
it "renders the edit cat form" do
@mplatts
mplatts / backbone_testing.coffee
Last active June 20, 2019 13:36
Backbone Testing Cheatsheet
# Libraries used:
# jasmine
# jasmine-jquery
# jasmine-sinon
# sinon
##### Basics Overview #####
describe "APP_NAME.Views.VIEW_FOLDER.VIEW_NAME ", ->
beforeEach ->
@mplatts
mplatts / index.html
Created October 30, 2012 03:48
Backbone Child Views Solution
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="https://raw.github.com/documentcloud/underscore/master/underscore.js"></script>
<script src="https://raw.github.com/documentcloud/backbone/master/backbone.js"></script>
</head>
<body>
<div id="app"></div>
@mplatts
mplatts / index.html
Created October 30, 2012 05:20
Backbone Layout Manager Simple Example
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="https://raw.github.com/documentcloud/underscore/master/underscore.js"></script>
<script src="https://raw.github.com/documentcloud/backbone/master/backbone.js"></script>
<script src="https://raw.github.com/tbranyen/backbone.layoutmanager/master/backbone.layoutmanager.js"></script>
</head>
<body>
<div id="app"></div>
@mplatts
mplatts / q-learn-coin-rules.json
Created August 27, 2013 13:22
Proposed ruleset for how many coins should be issued for certain events/scenarios in q-learn apps
{
"login": {
"firstForDay": {
"coins": 1000,
"message": "First login for the day!"
},
"firstEver": {
"coins": 10000,
"message": "First login"
}
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