This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple script to invoke locomotive | |
* uses the jake-lcm module: https://npmjs.org/package/jake-lcm | |
* | |
* Just put this at the root of your locomotive app | |
* | |
* Date: 5/30/13 | |
* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* in the test/ folder of a locomotive app that is using jake-lcm */ | |
var mocha = require('mocha') | |
, should = require('should') | |
, lcm = require('jake-lcm') | |
, User; | |
/* Assume there is a model in app/models/user.js with | |
var userSchema = new Schema({ | |
display_name: { type: String, required: true, index: true , trim: true} | |
, email: { type: String, required: true, trim: true} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Read Linux mouse(s) in node.js | |
* Author: Marc Loehe ([email protected]) | |
* | |
* Adapted from Tim Caswell's nice solution to read a linux joystick | |
* http://nodebits.org/linux-joystick | |
* https://github.com/nodebits/linux-joystick | |
*/ | |
var fs = require('fs'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @alert object set up in before proc | |
it "should have date after sending message" do | |
email = mock('email') | |
Mailer.should_receive(:new).and_return(email) | |
email.should_receive(:send) | |
email.should_receive(:send) | |
@alert.send_alert() | |
@alert.sent_at.class.should == DateTime | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
module Sinatra | |
# module to catch Sinatra errors and send a email | |
module ExceptionMailer | |
def initialize(app) | |
@app = app | |
# set parameters here.. | |
yield self if block_given? | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following sample code doesn't work for me - any ideas on what I need to change? | |
# (you need a hoptoad API key to run this.. | |
require 'rubygems' | |
require 'sinatra/base' | |
require 'rack/hoptoad' | |
API_KEY = 'YOUR HOPTOAD API HERE' | |
class MyApp < Sinatra::Base # (was Sinatra::Default) | |
use Rack::Hoptoad, API_KEY | |
enable :raise_errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra/base' | |
require 'hoptoad_notifier' | |
API_KEY = 'YOUR Hoptoad KEY here' | |
HoptoadNotifier.configure do |config| | |
config.api_key = API_KEY | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic Rspec question: | |
# How do I 'catch' that an Alert was sent to verify my test? | |
require 'spec' | |
class MyTask | |
def problem | |
a = Alert.new | |
a.send_alert | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- This gets the error: | |
"undefined method `merge' for :code:Symbol" | |
--> | |
<%= f.collection_select(:section, :assessment_id, Assessment.all, :id, :code) %> | |
<!-- but building it manually works fine: --> | |
<select name="section[assessment_id]"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- This gets the error: | |
"undefined method `merge' for :code:Symbol" | |
--> | |
<%= f.collection_select(:section, :assessment_id, Assessment.all, :id, :code) %> | |
<!-- but building it manually works fine: --> | |
<select name="section[assessment_id]"> |