Skip to content

Instantly share code, notes, and snippets.

@stephentcannon
stephentcannon / gist:8982924
Created February 13, 2014 20:13
CSS3 supports the following media types
media_type: all | aural | braille | handheld | print |
projection | screen | tty | tv | embossed
media_feature: width | min-width | max-width
| height | min-height | max-height
| device-width | min-device-width | max-device-width
| device-height | min-device-height | max-device-height
| aspect-ratio | min-aspect-ratio | max-aspect-ratio
| device-aspect-ratio | min-device-aspect-ratio | max-device-aspect-ratio
| color | min-color | max-color
| color-index | min-color-index | max-color-index
// default desktop view
#signInPage{
border: 1px solid gray;
}
// landscape orientation view for tablets
@media only screen and (min-width: 768px) {
#signInPage{
padding: 20px;
}
}
@stephentcannon
stephentcannon / gist:8981744
Created February 13, 2014 19:11
when is meteor collection find firing?
var wrappedFind = Meteor.Collection.prototype.find;
Meteor.Collection.prototype.find = function () {
var cursor = wrappedFind.apply(this, arguments);
var collectionName = this._name;
cursor.observeChanges({
added: function (id, fields) {
console.log(collectionName, 'added', id, fields);
},
@stephentcannon
stephentcannon / Templates rendering
Created February 13, 2014 19:10
What meteor templates are rendering
function logRenders () {
_.each(Template, function (template, name) {
var oldRender = template.rendered;
var counter = 0;
template.rendered = function () {
console.log(name, "render count: ", ++counter);
oldRender && oldRender.apply(this, arguments);
};
});

##Meteor Latency Compensation - The Correct Way

This is a kind of correction I wan't make regards to the concept describe in discover-meteor book

For the latency compensation to occur we cloud simply share the same method in the client/server. We can do this by simply putting the method under a place which can see by bot the server and client.

But practically(not all the time) we should not do that. In the server code we might have some logic which should not share. Or simply we might have some secret tokens.

So the correcy approach is define the method (in this case post) seperately in the two context. as shown below

#!/bin/bash
# __
# _____ ____ _/ |_ ____ ____ _______
# / \ _/ __ \ \ __\_/ __ \ / _ \ \_ __ \
# | Y Y \\ ___/ | | \ ___/ ( <_> ) | | \/
# |__|_| / \___ > |__| \___ > \____/ |__|
# \/ \/ \/
#
# .___
# __| _/ __ __ _____ ______
#!/bin/bash
# __
# _____ ____ _/ |_ ____ ____ _______
# / \ _/ __ \ \ __\_/ __ \ / _ \ \_ __ \
# | Y Y \\ ___/ | | \ ___/ ( <_> ) | | \/
# |__|_| / \___ > |__| \___ > \____/ |__|
# \/ \/ \/
#
# .___
# __| _/ __ __ _____ ______
@stephentcannon
stephentcannon / meteorexecflow.js
Last active December 15, 2015 01:49
Meteor execution flow issue
// CLIENT SIDE
// kicks off process by inserting process/report request into
vat ts = new Date();
var options =
{ start_date: '03/17/2013',
end_date: '03/18/2013',
client_updated_td: ts,
};
Commissions.insert(doc);
// make sure we're using the right db; this is the same as "use aggdb;" in shell
db = db.getSiblingDB("aggdb");
// simple projection
var p1 = db.runCommand(
{ aggregate : "article", pipeline : [
{ $project : {
tags : 1,
pageViews : 1
}}
@stephentcannon
stephentcannon / gist:3409103
Created August 20, 2012 23:17
Moment.js handlebars helper
// format an ISO date using Moment.js
// http://momentjs.com/
// moment syntax example: moment(Date("2011-07-18T15:50:52")).format("MMMM YYYY")
// usage: {{dateFormat creation_date format="MMMM YYYY"}}
Handlebars.registerHelper('dateFormat', function(context, block) {
if (window.moment) {
var f = block.hash.format || "MMM DD, YYYY hh:mm:ss A";
return moment(context).format(f); //had to remove Date(context)
}else{
return context; // moment plugin not available. return data as is.