Skip to content

Instantly share code, notes, and snippets.

View cmather's full-sized avatar

Chris Mather cmather

  • Elements
  • California
View GitHub Profile
@cmather
cmather / index.ts
Created September 26, 2021 17:25
app/index.ts
import { Application } from '@elemnets/application';
let app = new Application();
export default app;
Rooms = new Mongo.Collection('rooms');
Messages = new Mongo.Collection('messages');
if (Meteor.isClient) {
Meteor.subscribe('rooms', function () {
var room = Rooms.findOne();
Meteor.subscribe('messages', room._id);
});
}
@cmather
cmather / app.css
Created May 28, 2015 01:28
Frontend Masters CSS
/* CSS declarations go here */
body {
font-family: Helvetica Neue;
font-size: 14px;
margin: 0;
padding: 0;
height: 100vh;
width: 100%;
}
@cmather
cmather / test.js
Created November 18, 2014 16:54
Example JavaScript snippet that I'll embed.
var myFunc = function () {
return "Hello, world!";
};
@cmather
cmather / async.js
Created July 20, 2013 23:14
Async call from within a Meteor server side method.
if (Meteor.isServer) {
var Fiber = Npm.require('fibers');
function async (cb) {
Meteor.setTimeout(function () {
cb(null, 'hello');
}, 3000);
}
Meteor.methods({
@cmather
cmather / parent-data-context.js
Created March 2, 2013 03:15
Example of monkey patching Handlebars 'each' method in Meteor to give access to a parent data context inside a child template helper.
if (Meteor.isClient) {
_.extend(Handlebars._default_helpers, {
'each': function (data, options) {
var parentData = this;
if (data && data.length > 0) {
return _.map(data, function (childContext, idx) {
var branch = (childContext._id || (typeof childContext === 'string' ? childContext : null) ||
Spark.UNIQUE_LABEL);
return Spark.labelBranch(branch, function () {
@cmather
cmather / app
Created November 30, 2012 20:31
Example Nginx Config
map $uri $preferred_proto {
default "http";
~^/assets/ "none";
~^/signup "https";
~^/users "https";
~^/users/(.*)$ "https";
~^/login "https";
~^/sessions "https";
~^/api/(.*)$ "https";
~^/password_resets "https";
@cmather
cmather / ruby.rb
Created June 22, 2012 00:08
Test Gist
module Boom
def say
"boom"
end
end
@cmather
cmather / javascript-constructor-function.js
Created June 22, 2012 00:00
JavaScript Constructor Function
function Constructor(config) {
this.config = config;
}
var myObject = new Constructor({ title: "Hello World" });
@cmather
cmather / getViewportSize.js
Created March 18, 2012 19:14 — forked from scottjehl/getViewportSize.js
Reliably get viewport dimensions in JS
/*!
An experiment in getting accurate visible viewport dimensions across devices
(c) 2012 Scott Jehl.
MIT/GPLv2 Licence
*/
function viewportSize(){
var test = document.createElement( "div" );
test.style.cssText = "position: fixed;top: 0;left: 0;bottom: 0;right: 0;";