Skip to content

Instantly share code, notes, and snippets.

View jonjamz's full-sized avatar

Jonathan James jonjamz

  • Cheerity
  • New York, NY
View GitHub Profile
@jonjamz
jonjamz / gist:d335159ca9487c8158b8
Last active August 29, 2015 14:10
Track last visited route in Iron Router by wrapping Router.go
var go;
go = Router.go;
Session.set('lastRoute', null);
Router.go = function() {
if (!Session.equals('lastRoute', Router.current().route.path())) {
Session.set('lastRoute', Router.current().route.path());
}
@jonjamz
jonjamz / gist:bbd1c65b0f7cdd7ca461
Last active January 26, 2017 10:50
Alternative to Meteor.Collection._publishCursor that returns the observeChanges handle
###
When attempting to use Meteor.Collection._publishCursor in publish functions as part of a join,
we'll do something like this (as outlined in Discover Meteor's Advanced Publications chapter):
Meteor.publish (authorId) ->
sub = @
commentHandles = {}
unless @userId?
return undefined
@jonjamz
jonjamz / gist:b45f0d8fb049cdecdd42
Last active August 29, 2015 14:01
Replace first-level bullet points with numbered points
window.post = $('textarea').val()
var i = 1;
window.post = window.post.replace(/(\n)[^\s](\\*)/g, function(str, p1, offset, s) {
return '\n' + i++ + '.';
});
$('textarea').val(window.post);