Skip to content

Instantly share code, notes, and snippets.

Meteor.methods({
searchPosts: function(term) {
console.log('-- searching for "'+term+'" --')
Future = Npm.require('fibers/future');
var fut = new Future();
Meteor._RemoteCollectionDriver.mongo.db.executeDbCommand({
"text": "posts",
search: term
}, function (error,results){
@SachaG
SachaG / MeteorMethodInTemplateHelper.js
Last active September 22, 2016 01:39
Use the return value of a Meteor method in a template helper.
if(Meteor.isClient){
// set Session variable in method callback
Meteor.call('myMeteorMethod', "foo", function(error, result){
Session.set('myMethodResult', result);
});
// use reactive Session variable in helper
Template.myTemplate.helpers({
myHelper: function(){
@SachaG
SachaG / AsynchronousFunctionWithinMeteorMethod.js
Last active November 17, 2016 09:32
Call an asynchronous function and use its returned value from within a Meteor method using Future.
if(Meteor.isServer){
Meteor.methods({
myMeteorMethod: function() {
// load Future
Future = Npm.require('fibers/future');
var myFuture = new Future();
// call the function and store its result
SomeAsynchronousFunction("foo", function (error,results){
Exception from Deps recompute: TypeError: Cannot read property 'nodeName' of null
at Patcher.match (http://localhost:3000/packages/spark.js?3a050592ceb34d6c585c70f1df11e353610be0ab:1540:12)
at http://localhost:3000/packages/spark.js?3a050592ceb34d6c585c70f1df11e353610be0ab:1353:23
at visitNodes (http://localhost:3000/packages/spark.js?3a050592ceb34d6c585c70f1df11e353610be0ab:1320:11)
at visitNodes (http://localhost:3000/packages/spark.js?3a050592ceb34d6c585c70f1df11e353610be0ab:1321:9)
at visitNodes (http://localhost:3000/packages/spark.js?3a050592ceb34d6c585c70f1df11e353610be0ab:1321:9)
at visitNodes (http://localhost:3000/packages/spark.js?3a050592ceb34d6c585c70f1df11e353610be0ab:1321:9)
at visitNodes (http://localhost:3000/packages/spark.js?3a050592ceb34d6c585c70f1df11e353610be0ab:1321:9)
at visitNodes (http://localhost:3000/packages/spark.js?3a050592ceb34d6c585c70f1df11e353610be0ab:1321:9)
at patch (http://localhost:3000/packages/spark.js?3a050592ceb34d6c585c70f1df11e35
4:58:33 PM - started
4:58:33 PM - started installing mongodb on 162.243.142.107
5:00:03 PM - completed installing mongodb on 162.243.142.107
5:00:03 PM - started configuring mongodb on 162.243.142.107
5:00:16 PM - completed configuring mongodb on 162.243.142.107
5:00:16 PM - started installing meteor on 162.243.142.107
5:01:06 PM - completed installing meteor on 162.243.142.107
5:01:06 PM - started configuring meteor on 162.243.142.107
5:01:14 PM - failed configuring meteor on 162.243.142.107
-----------------------------------STDERR-----------------------------------
Handlebars.registerHelper('each_with_index', function(items, options) {
var out = '';
for(var i=0, l=items.length; i<l; i++) {
var key = 'Branch-' + i;
out = out + Spark.labelBranch(key,function(){
options.fn(_.extend(items[i], {rank: i}));
});
}
console.log('each_with_index:')
console.log(out)
[
{
"_id": "LJNnpzMtgHu4mra3Q",
"statusCode": 200,
"content": "{\"page\":\"1\",\"per_page\":12,\"pages\":50,\"total\":600,\"shots\":[{\"id\":1482504,\"title\":\"All of the Pixels\",\"height\":600,\"width\":800,\"likes_count\":316,\"comments_count\":17,\"rebounds_count\":0,\"url\":\"http://dribbble.com/shots/1482504-All-of-the-Pixels\",\"short_url\":\"http://drbl.in/kCnK\",\"views_count\":2115,\"rebound_source_id\":null,\"image_url\":\"http://d13yacurqjgara.cloudfront.net/users/13774/screenshots/1482504/luma.jpg\",\"image_teaser_url\":\"http://d13yacurqjgara.cloudfront.net/users/13774/screenshots/1482504/luma_teaser.jpg\",\"image_400_url\":\"http://d13yacurqjgara.cloudfront.net/users/13774/screenshots/1482504/luma_1x.jpg\",\"player\":{\"id\":13774,\"name\":\"Justin Mezzell\",\"location\":\"Orlando, FL\",\"followers_count\":17388,\"draftees_count\":8,\"likes_count\":3696,\"likes_received_count\":65672,\"comments_count\":784,\"comments_received_count\":4346,\"rebounds_count\":5,\"rebounds_received_
I recently changed the time/date on my server to try and deal with timezone issues, and MeteorUp seems not to have liked that.
```
tar: bundle/programs/server/start.sh: time stamp 2014-05-21 00:57:07 is 55.26219052 s in the future
tar: bundle/programs/server: time stamp 2014-05-21 00:57:07 is 55.262111128 s in the future
tar: bundle/programs: time stamp 2014-05-21 00:57:05 is 53.262037846 s in the future
tar: bundle/server/.bundle_version.txt: time stamp 2014-05-21 00:57:09 is 57.261902421 s in the future
tar: bundle/server: time stamp 2014-05-21 00:57:09 is 57.261823251 s in the future
tar: bundle/star.json: time stamp 2014-05-21 00:57:09 is 57.261665531 s in the future
@SachaG
SachaG / gist:17f6d55be78c63174ec9
Created July 2, 2014 09:23
Front email forwarding error
This is the mail system at host eforward3e.registrar-servers.com.
I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.
@SachaG
SachaG / gist:d57fccc728dd2959f8d0
Last active August 29, 2015 14:03
Iron Router subscription loading pattern
// Global data controller
DataController = RouteController.extend({
onBeforeAction: function(pause) {
var loading = false, notFound = false;
_.each(this.routeData(), function (dataItem) {
var handle = dataItem.subscription;