Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block drmikecrowe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
drmikecrowe / app.js
Last active May 25, 2020
Sharing constants between node.js app and web app
View app.js
//** In web app **//
var current = constants.STATE_WAITING;
View FormService.js
var forms = require('forms');
var fields = forms. fields,
validators = forms.validators,
widgets = forms.widgets;
var _ = require('lodash');
var fs = require('fs');
function repl(str,arr) {
_.forOwn(arr,function(value,key) {
var search = '{'+key+'}';
drmikecrowe / reindex-db.js
Last active Jul 25, 2016
Complex indices (and post-create index) of Waterline models
View reindex-db.js
* FILE: api/hooks/reindex-db.js
* Created by mcrowe on 1/28/15.
* Insures indices recreated if needed, and allows complex indicies to be specified in the model as well. Example:
module.exports = {
schema : true,
version : "1.3",
drmikecrowe /
Last active Aug 29, 2015
Reformat Gherkin test scripts to line up properly


Here's how our tests are setup:

  • Tests are grouped in subdirectories
  • Each directory/filename is prefixed with a number between 100-999, typically incremented by 10. This allows us to insert new tests into the stream of sequential tests
  • Tests start at 100, but configuration setup tests start at 010.
  • Tests are tagged according to the directory, and directory/file

This is very easy to understand/use, especially when you get 1000s of steps/scenarios and complex tests in your setup.

View app.yml
# file: roles/app/tasks/main.yml
- name: ensure logging directory exists
file: path=/var/log/acme state=directory
- install
- name: ensure config directory exists
file: path=/etc/acme/app state=directory
docker-yml() {
docker inspect -f $'
image: {{.Config.Image}}
entrypoint: {{json .Config.Entrypoint}}
environment: {{range .Config.Env}}
- {{.}}{{end}}
' $1
drmikecrowe / setup.js
Created Jan 19, 2016
Set debug log level for MongoClient
View setup.js
var MongoClient = require('mongodb').MongoClient
, Logger = require('mongodb').Logger;
drmikecrowe / Account.js
Last active Jan 27, 2020
Auto-incrementing ID's in Loopback
View Account.js
module.exports = function (Account) {
Account.observe('before save', function addAccountId(ctx, next) {
if (!ctx.isNewInstance) {
debug('id is already set, returning',;
return next();
app.dataSources.db.connector.collection("Sequences").findAndModify({name: 'Account'}, [['_id', 'asc']], {$inc: {value: 1}}, {new: true}, function (err, rec) {
if (err) {
drmikecrowe / DisableAllMethods.js
Last active Sep 5, 2019
Loopback mixin to disable or expose methods
View DisableAllMethods.js
// based on
'use strict';
relationMethodPrefixes = [
drmikecrowe / Dockerfile
Created Jan 14, 2017
Working PHP Docker Compose System with PhantimJS testing
View Dockerfile
# Build using docker build -t php-drmikecrowe
FROM php:5.6-apache
MAINTAINER Emilien Kenler <>
RUN apt-get update && apt-get install -y git libpq-dev libmcrypt-dev zlib1g-dev libicu-dev g++ graphviz && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install pdo_pgsql pdo_mysql mbstring mcrypt zip sockets intl bcmath mysqli
RUN curl -o /usr/local/bin/composer && \
You can’t perform that action at this time.