Skip to content

Instantly share code, notes, and snippets.

View daveroma's full-sized avatar
🎯
Focusing

David Roma daveroma

🎯
Focusing
View GitHub Profile
@daveroma
daveroma / Gruntfile.js
Last active May 21, 2016 22:51
Use Grunt to pre-compile less and javascript files
module.exports = function(grunt) {
grunt.initConfig({
less: {
development: {
options: {
compress: true,
yuicompress: true,
optimization: 2
},
@daveroma
daveroma / Gruntfile.js
Last active May 6, 2016 14:35
Use Grunt to compile pug files into html
module.exports = function(grunt) {
grunt.initConfig({
pug: {
compile: {
options: {
pretty: true,
data: {
debug: false
}
@daveroma
daveroma / LESS-greytext.less
Created April 22, 2016 16:16
LESS mixin for creating various shades of grey text using RGBa and optional opacity
.greytext(@opacity: 1.0) {
color: rgb(0, 0, 0); /* Fallback for older browsers */
color: rgba(0, 0, 0, @opacity);
}
@daveroma
daveroma / Meteor-collection-observe.es6.js
Created May 1, 2016 15:04
Do something when a document is added to a MongoDB collection in Meteor
Meteor.startup(function() {
let leadsLoaded = false;
let leadsCursor = Leads.find();
Meteor.subscribe('leads', function() {
leadsLoaded = true;
});
leadsCursor.observe({
var M = M || {};
M.lenderMap = function(defaultCenter) {
var map;
var infoWindow;
var service;
var infoWindowTemplate = function(result) {
return '<div class="info-window">' +
@daveroma
daveroma / javascript-static-app-base.js
Created May 24, 2016 10:39
JavaScript structure for static web pages
var App = App || {};
App.home = function() {
function privateFunction() {
return 'Can\'t see meh';
}
return {
init: function() {
@daveroma
daveroma / meteor-1.3-synchronous-server-method.js
Last active July 6, 2016 15:58
Meteor 1.3 code to expose a server method which leverages Futures enabling a synchronous call to the Stripe API, creates a new "Customer" and returns a response once the request has completed.
import { Meteor } from 'meteor/meteor';
import { Stripe } from 'meteor/mrgalaxy:stripe';
import Future from 'fibers/future';
Meteor.methods({
stripeCreateCustomer(token, email) {
const stripeCustomer = new Future();
@daveroma
daveroma / node-bot-starter-app.js
Last active July 6, 2016 17:08
A node.js starter script that uses websockets to facilitate communication between a web client and a chat bot living at pandorabots.com
const server = require('http').createServer(),
express = require('express'),
jade = require('jade'),
debug = require('debug')('loanbot:server'),
fs = require('fs'),
path = require('path')
WebSocketServer = require('ws').Server,
pandoraBot = require('pb-node'),
app = express(),
wss = new WebSocketServer({ server }),