Skip to content

Instantly share code, notes, and snippets.

Tinytest.add('Working', function(test) {
Books = new Meteor.Collection('books' + test.id);
Authors = new Meteor.Collection('authors' + test.id);
var author1 = Authors.insert({
firstName: 'Charles',
lastName: 'Darwin'
});
var book1 = Books.insert({
sendVideoMessagingSMS: function(to, message) {
check([this.userId, to, message], [String]);
twilio.sendSms({
to: to,
from: "...",
body: message
}, function(error, response) {
if (error)
throw new Meteor.Error(503, "Failed to send SMS.");
// Link service accounts when signed in
orig_updateOrCreateUserFromExternalService = Accounts.updateOrCreateUserFromExternalService;
Accounts.updateOrCreateUserFromExternalService = function(serviceName, serviceData, options) {
var loggedInUser = Meteor.user();
if (loggedInUser) {
var setAttr = {};
setAttr['linkedServices.' + serviceName] = serviceData;
Meteor.users.update(loggedInUser._id, { $set: setAttr });
GroupOneController = RouteController.extend({
activeTab: 'groupOne',
// ...
});
PageController = GroupOneController.extend({
// inherits 'activeTab'
// ...
});
Router.handlebars = function(options) {
options = options || {};
options.data = options.data || {};
if (! options.template)
throw new Meteor.Error("Router.handlebars: options.template is required");
if (! options.path)
throw new Meteor.Error("Router.handlebars: options.path is required");
return {
if (Meteor.isServer) {
Router.handlebars = (function(fn) {
return function (options) {
options.template = Handlebars.templates[options.template];
return fn(options);
};
}(Router.handlebars));
}
Router.configure({
Router.static = function(options) {
options = options || {};
if (! options.path)
throw new Meteor.Error("Router.static: options.path is required");
return {
where: 'server',
path: options.path,
action: function() {
Template.foo.events({
'keyup .bar': _.debounce(function(event) {
// ...
}, 300)
});
@dburles
dburles / gist:7e6f8a1ae2c89b7f005d
Created December 2, 2014 05:16
default Meteor project using template session
if (Meteor.isClient) {
Template.hello.created = function() {
this.setDefault('counter', 0);
};
Template.hello.helpers({
counter: function() {
var template = Template.instance();
return template.get('counter');
}
Blaze.TemplateInstance.prototype.setDefault = function(key, value) {
return Session.setDefault(this.view.name + '.' + key, value);
};
Blaze.TemplateInstance.prototype.set = function(key, value) {
return Session.set(this.view.name + '.' + key, value);
};
Blaze.TemplateInstance.prototype.get = function(key) {
return Session.get(this.view.name + '.' + key);