Skip to content

Instantly share code, notes, and snippets.

View Pent's full-sized avatar
🧲
magnetizing

Pent

🧲
magnetizing
View GitHub Profile
@Pent
Pent / gist:7574367
Created November 21, 2013 01:17
reactive map markers
Meteor.subscribe("markers");
//will, in theory, run everytime Markers.find() changes
Deps.autorun(function() {
console.log("grabbed " + Markers.find().count() + " markers");
Markers.find().forEach(function (marker) {
var geoJSON = { type: "FeatureCollection", features: [ marker ]};
L.mapbox.markerLayer(geoJSON, {
detectRetina: true,
}).addTo(map);
@Pent
Pent / publications.js
Created September 29, 2013 20:44
returning more user fields
Meteor.publish(null, function() {
return Meteor.users.find({_id: this.userId}, {fields: {username: 1, emails: 1, profile: 1, admin: 1}});
});
@Pent
Pent / btce.js
Last active December 23, 2015 05:29
api call example
Meteor.methods({
btce: function(to) {
var str = '';
Meteor.http.get('https://btc-e.com/api/2/btc_usd/ticker', function(error, response) {
if (response.statusCode === 200) {
var data = response.content;
data = JSON.parse(data);
if(data.ticker) {
return ("BTC-E: BTC->USD: [" + data.ticker.avg + "]");
}
@Pent
Pent / coinbase.js
Created August 28, 2013 17:52
coinbase api access
coinbase: function(to) {
Meteor.http.get('https://coinbase.com/api/v1/prices/buy', function(error, response) {
if (response.statusCode === 200) {
var data = response.data;
if(data.currency) {
Bot.say(to, 'Coinbase BTC: ' + data.amount + ' ' + data.currency);
}
}
});
}
@Pent
Pent / irc.js
Created August 26, 2013 19:27
Wrapping a meteor call with bindEnvironment
client.addListener('message', Meteor.bindEnvironment(function(handle, to, message) {
//insert irc message into db
Messages.insert({
handle: handle,
room_id: to,
message: message,
date_time: new Date(),
action: false,
irc: true,
bot: false
Meteor.publish(null, function () {
return Meteor.users.find({_id: this.userId}, {fields: {username: 1, profile: 1, role: 1}});
});
@Pent
Pent / client.html
Last active December 20, 2015 10:49
Template layout for Meteor
<body>
{{>body}}
</body>
<template name="body">
{{renderPage layoutName}}
</template>
<template name="adminLayout">
{{>adminHeader}}
@Pent
Pent / gist:5793360
Last active December 18, 2015 13:58
Check Meteor for bundled or development environment
var path = Npm.require("path");
var base = path.resolve('.');
if (base == '/'){
base = path.dirname(global.require.main.filename);
}
var publicPath = path.resolve(base+'/public/');
var staticPath = path.resolve(base+'/static/');
<template name="items">
<ul>
{{#each items}}
<li>
{{>itemlist}}
</li>
{{/if}}
</ul>
</template>
Fiber(function() {
Messages.insert({
handle: handle
});
processMessage(handle, message);
}).run();