Pallavi Anderson

data-driven and context-aware

CORS on Meteor

| Comments

Meteor’s webapp package exposes the underlying connect API through WebApp.connectHandlers which can be used (among other things) to customize HTTP headers and enable CORS in a Meteor application.

1
2
3
4
5
// Listen to incoming HTTP requests, can only be used on the server
WebApp.connectHandlers.use(function(req, res, next) {
  res.setHeader("Access-Control-Allow-Origin", "*");
  return next();
});

Use the optional path argument to call the handler only for paths that match a specified string.

1
2
3
4
5
// Listen to incoming HTTP requests, can only be used on the server
WebApp.connectHandlers.use("/public", function(req, res, next) {
  res.setHeader("Access-Control-Allow-Origin", "*");
  return next();
});

Meteor Update

| Comments

this happened

This picture sums up why I haven’t been blogging for a while – I joined Google as a software engineer on the Search team (more on this later) and I made a baby!

In other news, my realtime maps example now works with Meteor 1.0.5. All that I needed to do was:

  1. meteor update
  2. Move template methods into a Template.helpers() call - here is an example diff
  3. Remove the #constant guard around the map div

Code here and demo here.

Realtime Maps With Meteor and Leaflet - Part Two

| Comments

this is a Leaflet map with DivIcon markers

Recap

In the last post, I initialized a Leaflet map to work with Stamen Design’s toner themed map tiles and Bootstrap’s responsive layout. I then set up a double-click event handler to gather additional details about the new party, and hooked up the dialog’s save button to pass those details to a Meteor.methods() call to save the party into a server-side mongo collection. Finally, I hooked up a cursor.observe() added() callback to the client-side minimongo collection and set up the callback to automatically add a circular DivIcon marker at the specified coordinates.

Realtime Maps With Meteor and Leaflet - Part One

| Comments

this ‘map’ is actually a static image

The parties example bundled with Meteor is a nifty demonstration of the framework’s core principles, but it uses a 500 x 500 pixel image of downtown San Francisco as a faux map. This means that we cannot pan or zoom the “map,” and when we double-click the image to create new parties, the circle markers are drawn at the position of the clicks in relation to the image element in the browser window, and not at geospatial coordinates.

The Connection Between Google Glasses and Self-driving Humanoids

| Comments

Adrian Holovaty recently wrote about the connection between Google Street View and driverless cars. Towards the end, he wondered whether the decision to record all sensor / locational metadata along with pictures came before the idea of using it to train machine learning algorithms (or vice versa). I’d apply Occam’s razor here – i.e., I’m pretty certain the idea of capturing the data came first.

But what’s more interesting is that it presents a whole new angle on what Project Glass enables: Widespread lifelogging by humans (and not just cars) to cloud-based storage. Add offline speech to text, face recognition, OCR, etc. and you have prosthetic memory.

A tiny step towards “self-driving” humanoids.

Hello Meteor!

| Comments

Here are the slides from my JS.Chi() talk on Meteor. I will follow up with posts expanding on most of the slides in the presentation. This post, however, is for the benefit of all those who are feeling like they might be missing a step with frameworks like Backbone, Ember, (and now Meteor), et. al. It is an overview of the types of problems they’re solving and includes recommendations for further reading.