Skip to content

Instantly share code, notes, and snippets.

View lefnire's full-sized avatar

Tyler Renelle lefnire

View GitHub Profile
alembic==0.9.3
anaconda-client==1.6.3
backports.weakref==1.0rc1
bcrypt==3.1.3
bleach==1.5.0
cffi==1.10.0
click==6.7
clyent==1.2.2
coverage==4.4.1
cycler==0.10.0
diff --git a/frontend/app/scripts/services/property-service.js b/frontend/app/scripts/services/property-service.js
index e98d76b..1ed8a48 100755
--- a/frontend/app/scripts/services/property-service.js
+++ b/frontend/app/scripts/services/property-service.js
@@ -30,9 +30,9 @@ app.service('PropertyService', ['$http', '$q', '$filter', function ($http, $q, $
8: "Other"
};
- this.propertyTypes = function () {
+ function _wrap(request) {
ultimateGear: ->
# on the server this is a LoDash transform, on the client its an object
owned = if window? then user.items.gear.owned else user.items.gear.owned.toObject()
content.classes.forEach (klass) ->
user.achievements.ultimateGear[klass] = _.reduce ['armor', 'shield', 'head', 'weapon'], (soFarGood, type) ->
found = _.find content.gear.tree[klass][type], {last:true}
soFarGood and (!found or owned[found.key]==true) #!found only true when weapon is two-handed (mages)
, true # start with true, else `and` will fail right away

A possible 4th point: responsiveness. Running JS on the client first for a snappy UI, while concurrently running on the server for storage.

Here’s a HabitRPG example: User checks off a to-do and gains Experience, Gold, levels up, finds a rare item, unlocks new features, etc (it's quite complex). All that happens on the client immediately (including notifications, unlocked <div>s, etc), for a snappy front-end experience. Concurrently, the operation is sent to the server which replicates the actions and stores the results in the database. So here you see both code-duplication-reduction, and improved UI responsiveness.

We achieve this now using browserify to share the code b/w server & client. However, our actual glue-code wrapping client objects to send REST ops, and wrapping server objects to store to mongo, is hideous. Your solution looks cleaner and more robust.

If your app uses a realtime connector (websockets, firebase, whatever) running all post-action updates server-si

error: TypeError: Cannot read property 'dayStart' of undefined
at model.UserSchema.methods.unlink.cid (/Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/src/models/user.js:438:31)
at _next (/Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/node_modules/hooks/hooks.js:50:30)
at fnWrapper (/Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/node_modules/hooks/hooks.js:159:8)
at complete (/Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/lib/document.js:986:5)
at /Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/lib/document.js:977:20
at /Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/lib/schema/documentarray.js:100:22
at complete (/Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/lib/document.js:986:5)
at /Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/lib/document.js:977:20
error: TypeError: Cannot read property 'dayStart' of undefined
at model.UserSchema.methods.unlink.cid (/Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/src/models/user.js:438:31)
at _next (/Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/node_modules/hooks/hooks.js:50:30)
at fnWrapper (/Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/node_modules/hooks/hooks.js:159:8)
at complete (/Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/lib/document.js:986:5)
at /Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/lib/document.js:977:20
at /Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/lib/schema/documentarray.js:100:22
at complete (/Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/lib/document.js:986:5)
at /Users/lefnire/Google Drive/Sync/Sites/habitrpg/website/node_modules/mongoose/lib/document.js:977:20
/* 0 */
{
"op" : "query",
"ns" : "habitrpg.groups",
"query" : {
"members" : {
"$in" : [
"33a68f1a-6fe4-4def-b881-490f3a7927c3"
]
},
// db.announcements collection
{
_id: String,
title: String, // title of this whole set of announcements (eg, "Mobile update, neglect strike, mystery items!")
date: Date,
global: Boolean,
sections: [{
title: String, //Eg "Mobile app 0.0.48 released"
body: String, // Store this as markdown, parse to HTML on display
diff --git a/public/js/app.js b/public/js/app.js
index f8410f1..8433ac5 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -1,9 +1,7 @@
"use strict";
window.habitrpg = angular.module('habitrpg',
- ['ngResource', 'ngSanitize', 'userServices', 'groupServices', 'memberServices', 'challengeServices',
- 'authServices', 'notificationServices', 'guideServices', 'authCtrl', 'paymentServices',
diff --git a/migrations/mysteryitems.js b/migrations/mysteryitems.js
index 4743757..be8c3b2 100644
--- a/migrations/mysteryitems.js
+++ b/migrations/mysteryitems.js
@@ -1,6 +1,6 @@
var _id = '';
var update = {
- $push: {
+ $addToSet: {
'purchased.plan.mysteryItems':{