Skip to content

Instantly share code, notes, and snippets.

@rcy
rcy / gist:5844525
Created June 23, 2013 10:22
Makefile to bundle meteor app to run in production
prod:
rm -rf ./bundle
mrt bundle bundle.tgz > /dev/null
tar -xzf bundle.tgz
rm -r bundle/server/node_modules/fibers
cd bundle/server && npm install [email protected]
clean:
rm -f ./bundle.tgz
rm -rf ./bundle
@rcy
rcy / gist:5874878
Created June 27, 2013 08:28
compute a template to render
Template.editProperty.helpers({
// Render a template based on the control type. For example, if
// this.control.type is 'color', it will render the template with
// name="colorControl", if it exists. 'this' context is passed to
// the control sub-template when rendering.
renderControl: function() {
if ( ! (this.control && this.control.type))
throw new Meteor.Error(500, 'type missing');
var template = Template[this.control.type + 'Control'];
@rcy
rcy / gist:6065263
Created July 23, 2013 19:13
bootstrap modal meteor
Template.inviteModal.rendered = function() {
Deps.autorun(function() {
if (Session.equals('invite', true)) {
$('.modal').modal()
.on('hide', function() {
Session.set('invite', false);
});
}
});
}
// key is a string of possibly dotted accessors
function prop(obj, key) {
var keys = key.split('.');
for (var i in keys) {
if (!obj) break;
obj = obj[keys[i]];
}
return obj;
}
@rcy
rcy / keydown.html
Created August 27, 2013 20:02
keydown test
<head>
<title>keydown</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<input type="text">
@rcy
rcy / gist:6433869
Created September 4, 2013 07:44
simple minimongo query
function miniQuery(doc, query) {
var collection = new Meteor.Collection(null);
collection.insert(doc);
return !! collection.findOne(query);
}
@rcy
rcy / gist:6434088
Created September 4, 2013 08:08
meteor streams demo code
chatStream = new Meteor.Stream('chat');
if(Meteor.isClient) {
sendChat = function(message) {
chatStream.emit('message', message);
console.log('me: ' + message);
};
chatStream.on('message', function(message) {
console.log('user: ' + message);
@rcy
rcy / gist:6720157
Last active December 24, 2015 00:59
branch specific deployments to %.meteor.com
PROJECT=myapp
BRANCH=$(shell git branch | sed -n '/\* /s///p')
TAG=deploy-${BRANCH}-$(shell echo -n `date +%Y%m%d%H%M%S`)
ifeq (${BRANCH}, master)
TARGET=${PROJECT}.meteor.com
else
TARGET=${BRANCH}-${PROJECT}.meteor.com
endif
@rcy
rcy / using settings in meteor
Created March 20, 2014 20:27
simple example of using settings in meteor
settings.json:
```
{"foo": 99}
```
app.js
```
if (Meteor.isServer)
console.log(Meteor.settings.foo);
```
@rcy
rcy / smart.json
Created April 11, 2014 20:20
smart.json iron-router lock version
"iron-router": {
"git": "https://github.com/EventedMind/iron-router.git",
"tag": "v0.6.4"
}