Skip to content

Instantly share code, notes, and snippets.

From Meteor's documentation:

In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.

This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.

Basic async

Sometimes we need to run async code in Meteor.methods. For this we create a Future to block until the async code has finished. This pattern can be seen all over Meteor's own codebase:

@Quebecisnice
Quebecisnice / house_dataset
Created January 30, 2014 15:54
Codalab CLI Tutorial Example Dataset
0 | price:.23 sqft:.25 age:.05 2006
1 2 'second_house | price:.18 sqft:.15 age:.35 1976
0 1 0.5 'third_house | price:.53 sqft:.32 age:.87 1924
@Quebecisnice
Quebecisnice / heatmap1.py
Created August 27, 2013 20:58
Generating a simple heatmap w/ python
import numpy as np
from pandas import *
import matplotlib.pyplot as plt
Index = ['aaa', 'bbb', 'ccc', 'ddd', 'eee']
Cols = ['A', 'B', 'C', 'D']
df = DataFrame(abs(np.random.randn(5,4)), index=Index, columns = Cols)
plt.pcolor(df)
plt.yticks(np.arange(0.5, len(df.index), 1), df.index)
@Quebecisnice
Quebecisnice / _.md
Created August 2, 2013 01:11
INFO 247 - Lab 7 - #3 - Putting it together (full code)
@Quebecisnice
Quebecisnice / _.md
Created August 2, 2013 01:11
INFO 247 - Lab 7 - #3 - Putting it together (full code)
; A REPL-based, annotated Seesaw tutorial
; Please visit https://github.com/daveray/seesaw for more info
;
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers
; Seesaw's basic features and philosophy, but only scratches the surface
; of what's available. It only assumes knowledge of Clojure. No Swing or
; Java experience is needed.
;
; This material was first presented in a talk at @CraftsmanGuild in
; Ann Arbor, MI.
@Quebecisnice
Quebecisnice / Gemfile
Created September 13, 2012 18:43
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@Quebecisnice
Quebecisnice / 24.cpp
Created April 9, 2012 17:57 — forked from fedelebron/24.cpp
24 solver, with no access to binary_function or function<...>, thanks to an outdated compiler. :) Still using C++11 though.
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define forn(i, n) for(int i = 0; i < (n); ++i)
#define FUNC(i) (*(dispatch[funcs[i]]))
#define MFUNC(o) ([](double a, double b) { return a o b; })
using namespace std;