Skip to content

Instantly share code, notes, and snippets.

@misutowolf
misutowolf / editable-text.js
Created April 21, 2015 14:33
ET Callback for Currency stuff
EditableText.registerCallbacks({
// Callback for editing category limit/budget.
budgetCurrency: function(doc) {
// Variables based on editing.
var oldVal = this.oldValue;
var newVal = this.newValue;
// Verification:
if (isNaN(newVal)) {
@misutowolf
misutowolf / router.js
Created April 20, 2015 21:49
Possible Route for App?
// Application interface (main)
Router.route('/app', function() {
this.render('/app', {
data: {
categories: function() {
return Categories.find({userId: Meteor.userId()});
},
transactions: function() {
return Transactions.find({userId: Meteor.userId()});
}
@misutowolf
misutowolf / single.js
Created March 9, 2015 16:32
groupSingle
Template.groupsSingle.helpers({
// Generate tag list
tagList: function() {
return this.tags;
},
rosterList: function() {
var theHTML = "";
for (var i = 1; i <= numRanks; i++) {
var rankName = theRanks[i-1].name + "s";
theHTML += "<h5>" + rankName + "</h5>";
var theGroup = _.filter(theRoster, function(item) { return item.rank === i; });
console.log(JSON.stringify(theGroup));
// Check for empty rank (no members of rank)
if (_.isEmpty(theGroup)) {
theHTML += "<ul><li>None</li></ul>";
} else {
theHTML += "<ul>";
@misutowolf
misutowolf / startup.coffee
Created January 16, 2015 19:12
bot client stuff
# Generate client objects from list of users at time of startup.
theNames.forEach (doc) ->
CLIENTS[doc.profile.name] = new WASDbot
server: 'irc.twitch.tv'
port: 6667
nick: "wasdboss"
realname: "wasdboss"
username: "wasdboss"
servpass: "oauth:cd3sm3q4klbgl7dt3c6gwbu5x08gj5"
channels: ["#" + doc.profile.name]
this.route('profile', {
path: '/profile/:username',
waitOn: function() {
return this.subscribe("userByUsername", this.params.username);
},
data: function() {
var userDoc = Meteor.users.findOne({"username": this.params.username});
// Guard against non-ready user document.
if (!userDoc) {
this.route('profile', {
path: '/profile/:username',
data: function() {
console.log(this.params.username);
var userCursor = Meteor.users.findOne({"username": this.params.username});
console.log(JSON.stringify(userCursor));
var bookCursor = Books.find({owner: userCursor._id});
return {
theUser: userCursor,
theBooks: bookCursor
Meteor.startup (function() {
if (Prefixes.find().count() == 0) {
prefixes = [
{
"prefix": "ADNR"
},
{
"prefix": "AHNR"
classCount: function() {
// Attempt aggregation of the books table to count by class, maybe.
var db = MongoInternals.defaultRemoteCollectionDriver().mongo.db;
var col = db.collection("books");
var aggregateSync = Meteor._wrapAsync(col.aggregate.bind(col));
var pipeline = [
{$group: {_id: "$class", count: {$sum: 1}}},
{$sort: {_id: 1}}
];
this.route('browse-class', {
path: '/browse/:class',
data: function() {
"class": this.params.class,
numBooks: Books.find({"class": this.params.class},{sort:{"createdAt": 1}}).count(),
books: Books.find({"class": this.params.class},{sort:{"createdAt": 1}})
}
});