Skip to content

Instantly share code, notes, and snippets.

View tapmodo's full-sized avatar

Kelly Hallman tapmodo

  • Tapmodo Interactive LLC
  • California
View GitHub Profile
@tapmodo
tapmodo / bs3-nav.jade
Created December 2, 2013 17:56
Example of Bootstrap 3.0.2 navbar in jade format
- var navmenu = { Dashboard: '/', Upload: '/upload' }
nav.navbar.navbar-default(role='navigation')
div.navbar-header
button(type='button',data-toggle='collapse',data-target='#jcs-navbar-collapse-1').navbar-toggle
span.sr-only Toggle navigation
span.iconbar
span.iconbar
span.iconbar
a(href='#').navbar-brand Brand
var mongoose = require('mongoose');
var _ = require('underscore');
mongoose.connect('mongodb://localhost/mydatabase');
/**
* Define a schema and model (using schema)
*/
var userSchema = mongoose.Schema({
@tapmodo
tapmodo / 01_async.js
Created October 2, 2014 19:51
Compare "async" and "co" libraries
server.get('/queue/pending',function(req,res,next){
var page = req.params.page || 1;
page = page - 1;
var per_page = req.params.per_page || 50;
pool.getConnection(function(err,db){
async.series([
function(done){
db.query(
'SELECT COUNT(*) AS total FROM '+
'(SELECT DISTINCT event, venue, event_time FROM import_queue '+
@tapmodo
tapmodo / polyfills.js
Created October 22, 2014 23:24
Array.filter and Array.map Javascript Polyfills
// Array.map polyfill
if (Array.prototype.map === undefined) {
Array.prototype.map = function(fn) {
var rv = [];
for(var i=0, l=this.length; i<l; i++)
rv.push(fn(this[i]));
return rv;
@tapmodo
tapmodo / map_and_filter.js
Created October 22, 2014 23:41
map and filter functions
// map function
function array_map(arr,fn) {
var rv = [];
for(var i=0, l=arr.length; i<l; i++)
rv.push(fn(arr[i]));
return rv;
};
@tapmodo
tapmodo / influx-collector.js
Last active October 29, 2015 02:50
This is a first stab at a batch uploader for InfluxDB. It seems to work. If you wanted to use this for any other queue batching operation, you could overload the write() and _send() methods...
var _ = require('lodash');
var debug = require('debug')('influx:batch');
var SeriesWriter = function(db,options){
this.db = db;
this.setOptions(options);
this.sending = false;
this.timer = null;
this.queue = [];
};
var es = require('event-stream');
var fs = require('fs');
var ldif = require('ldif');
var Streamer = function(stream,options){
var chain = stream, self = this;
options = ldif._extend({},Streamer.defaults,options);
// Normalize pipeline array
if (!Array.isArray(options.pipeline))
@tapmodo
tapmodo / foundation-2col-layout.scss
Created December 6, 2015 03:59
2 scrollable column layout, with header and footer, using Foundation 6
@import '../../bower_components/foundation-sites/scss/foundation';
@include foundation-everything;
.container {
@include grid-row(16) {
.sidebar { @include grid-column(5); }
.main-content { @include grid-column(11); }
}
}

Keybase proof

I hereby claim:

  • I am tapmodo on github.
  • I am khallman (https://keybase.io/khallman) on keybase.
  • I have a public key ASCZaySVvMgIlUktbO90VOlMrP4SSIf6JeBk1Ya5K2bkxQo

To claim this, I am signing this object:

@tapmodo
tapmodo / cartesian.js
Last active November 21, 2018 15:05
const collection = [
{ attributeValue: ["RED", "GOLD"] },
{ attributeValue: ["16G", "32G", "64G"] },
{ attributeValue: ["PLUS"] }
]
function cartesian(data) {
const f = (a,b) => [].concat(...a.map(d => b.map(e => [].concat(d, e))))
const recurse = (a, b, ...c) => (b? recurse(f(a, b), ...c): a)
return recurse(...data)