Meteor Cheat Sheet

Notes covering the critical Meteor concepts that will help you get up and running.

Meteor

Meteor is a full-stack Javascript framework for building web and native applications.

Directory Structure

  • Files in the Client folder are only rendered on the Client.
  • Files in the Server folder are only rendered on the Server.
  • Files in Lib are rendered on both Client and Server.
  • Files in Public are rendered to the Client.

Routing

Routing requires middleware/package. Most common:
  • Flow-router
  • Iron-router

Global helpers (functions)

  • Create helper in lib directory (“/lib/helpers.js”)
  • Syntax: Template.registerHelper(‘helperName’, ‘function () {});

Collections

  • Create a collection in lib (Collection = new Mongo.Collection(‘collection’);

CRUD

  • Insert: collection.insert(doc, [callback]);
  • Update: collection.update(selector, modifier, [options], [callback])
  • Remove: collection.remove(selector, [callback])

Sessions

  • Sessions are global objects on the client. Can be used to store key-value pairs
  • Session.set(key, value) – New session
  • Session.set(key) – Get the value of session

Templates

Creating a new template (template name=“foo”> in HTML creates a template object named Template.foo.
Events
Template.myTemplate.events – Specify events for this template like click, dblclick
Helpers
Template.myTemplate.helpers – Specify template helpers (methods) available to this template
onRendered
Template.mytemplate.onRendered – Methods to be called when template is inserted into DOM

Packages

Middleware/extensions to be used with app.
NPM packages with Meteor

Accounts

  • Basic package is ‘accounts-base’
  • accounts-password, accounts-facebook, accounts-github, accounts-google, accounts-meetup, accounts-twitter
  • Meteor.user() – Get current user record or null if no user is logged in
Accounts UI
  • Add accounts-ui package
  • Add at least one login provider package:
    • accounts-password
    • accounts-facebook
    • accounts-github
    • etc
  • Add {{> loginButtons}} helper to an HTML file
  • This will place login widget on page

Real But Not True

I discovered a very simple and powerful thought that’s helping me find my way back to the present moment. It’s the notion that thoughts and their underlying beliefs are real but not true.

Psychologist and Meditation Teacher Tara Brach explains this wonderfully: “[Thoughts/beliefs] are appearing, they come with a very real and painful experience of fear or hurt or shame in our bodies. But they are interpretations of reality, mental images and soundbites we have produced that represent the world and entrap us in a confining trance. They are not truth itself.”

According to Tara, our core beliefs are often based on our early and most potent fears. The greater the stress or trauma we experienced, the greater likelihood of deeply rooted fear-based beliefs.

For example, imagine you’re a child asking your mother a lot of questions. She responds to a lot of your questions but ignores others. She may be having a bad day and may yell at you and tell you to stop asking so many questions.

You may not remember these incidents when you’re older but these memories may influence the way you behave in certain situations. For instance, you may be reluctant to ask questions because you think people will get annoyed or question your intelligence.

When we believe that thoughts are real but not true, we can better manage the impact of these fear-based beliefs. We can rid ourselves of these outdated observations that halt our curiosity.

Bravery Manifesto

To have my chin up even when I don’t know where I’m going
To listen because I’m heard
To help because I’m able
To be excited for others because together, we’re powerful
To share because I’m privileged
To laugh at myself because sometimes things just happen
To be okay with maybes and I don’t knows
To more quickly adapt because this is the quickest path to growth

A Simple Question To Keep Us Moving Forward

Solving any problem successfully requires continuous action despite all difficulties.

Sometimes difficulty arises as doubt. A single doubt can quickly manifest into debilitating fear. It can entrap us in a negative mindset that nudges us back into our old habits of resistance.

We should greet each doubt with a friendly curiosity that asks “what’s the simplest thing we can do next?” This simple tactic helps us see doubt for what it is — A guide for the next possible action. And by continuously deflecting doubt through action, we can continue our movement towards success.

UX Design Patterns: Gradual Engagement

Goldfish have 9 second attention spans. Crazy right? Well don’t judge those innocent little goldfish just yet.

A Microsoft study found that on average, our span is only 8 seconds. Our roles as UX designers are even more imperative.

This post is a part of a series, “UX Design Patterns” and it aims to equip us with design patterns that can maximize our limited time with customers.

Gradual Engagement

Imagine you’re selling a product in person and you only have 8 seconds. How would you use your time? For starters, you wouldn’t lead with a registration form.

Continue reading

Typography: Free Gotham and Sentinel Substitutions

I’m a big fan of Gotham and Sentinel. Both fonts work really well in isolation or when paired. I find the pairing works especially well when Gotham leads (headers, sub-heads) and Sentinel supports (paragraphs, list items).

Gotham & Sentinel Pairing

Here’s an example of the pairing in an agency theme I’m currently designing:

husammachlovi-typography-sentinel-gotham

By the way, notice how KILLER Sentinel looks when italicized?

This awesome font combo costs about $99/year though. I can’t possibly ask customers to spend that much for a theme purchase. And so began my search for free alternatives.
Continue reading

Solo Travel Learnings: Bravery and Honesty

I just came back from a 5-day solo trip in Beijing. I learned a lot about myself during this trip. Most remarkably, I learned the importance of bravery and honesty.

Traveling alone, I quickly realized how tough it is to make one’s own decisions. I had to determine if people were trustworthy, restaurants were clean, and areas were safe. Back home, these decisions are far less complex as I have access to varying perspectives from family, friends and mentors.

I began to use my senses and emotions to guide me in my decision making.

Continue reading

Wherever You Go, There You Are

I’m writing this from Beijing. Just 2 days ago, I was climbing the Great Wall of China. And days before that, I was at the Forbidden City with thousands of other tourists marveling at the architecture. Though despite these precious experiences, I still found myself giving energy to made-up worries. Worries for work that hasn’t yet started, things I said and things I wanted to do.

The strange thing is that this stress felt like home. I was able to recognize myself through the stress. This led me to a fascinating thought — wherever you go, there you are. There are no shortcuts to finding inner peace. It requires hours upon hours of mental training.

Continue reading