Skip to content

Instantly share code, notes, and snippets.

@mplatts
mplatts / rspec-syntax-cheat-sheet.rb
Created Jan 9, 2012 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
View rspec-syntax-cheat-sheet.rb
# 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 Jan 10, 2012
Rspec 2 Rails Samples
View edit.html.erb_spec.rb
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 Jun 20, 2019
Backbone Testing Cheatsheet
View backbone_testing.coffee
# Libraries used:
# jasmine
# jasmine-jquery
# jasmine-sinon
# sinon
##### Basics Overview #####
describe "APP_NAME.Views.VIEW_FOLDER.VIEW_NAME ", ->
beforeEach ->
@mplatts
mplatts / index.html
Created Oct 30, 2012
Backbone Child Views Solution
View index.html
<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 Oct 30, 2012
Backbone Layout Manager Simple Example
View index.html
<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 Aug 27, 2013
Proposed ruleset for how many coins should be issued for certain events/scenarios in q-learn apps
View q-learn-coin-rules.json
{
"login": {
"firstForDay": {
"coins": 1000,
"message": "First login for the day!"
},
"firstEver": {
"coins": 10000,
"message": "First login"
}
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
You can’t perform that action at this time.