Skip to content

Instantly share code, notes, and snippets.

View mbrevoort's full-sized avatar

Mike Brevoort mbrevoort

View GitHub Profile
@mbrevoort
mbrevoort / gist:dcdbbb4e2d5b2f62f407
Created June 1, 2015 06:08
CircleCI Circle.yml for building Godeps backed Go service and building and pushing to private docker registry
machine:
services:
- redis
- docker
environment:
PROJECT_NAME: <your-project>
checkout:
post:
@mbrevoort
mbrevoort / gist:11028515
Created April 18, 2014 07:03
/etc/init/consul.conf with appuser
# consul - agent instance
#
description "consul agent"
start on networking
stop on runlevel [06]
# Respawn it if the process exits
respawn
SyntaxError: Unexpected token [
at Object.parse (native)
at parse (/home/appuser/thalassa-server-app/app/node_modules/thalassa/node_modules/seaport/node_modules/crdt/node_modules/scuttlebutt/node_modules/stream-serializer/index.js:20:17)
at Stream.onData [as write] (/home/appuser/thalassa-server-app/app/node_modules/thalassa/node_modules/seaport/node_modules/crdt/node_modules/scuttlebutt/node_modules/stream-serializer/index.js:34:7)
at Stream.write (/home/appuser/thalassa-server-app/app/node_modules/thalassa/node_modules/seaport/lib/seaport.js:199:11)
at Stream.stream.write (/home/appuser/thalassa-server-app/app/node_modules/thalassa/node_modules/seaport/node_modules/through/index.js:25:11)
at Stream.ondata (stream.js:51:26)
at Stream.EventEmitter.emit (events.js:117:20)
at Stream.stream.emit (/home/appuser/thalassa-server-app/app/node_modules/thalassa/node_modules/seaport/node_modules/crdt/node_modules/scuttlebutt/node_modules/stream-serializer/index.js:58:33)
at Stream.st
@mbrevoort
mbrevoort / LogstashUDP.js
Created June 24, 2013 06:55
A simple Logstash UDP logger for Winston.
// Really simple Winston Logstash UDP Logger
var dgram = require('dgram'),
util = require('util'),
os = require('os'),
winston = require('winston');
var LogstashUDP = module.exports = function (options) {
winston.Transport.call(this, options);
options = options || {};
@mbrevoort
mbrevoort / desktopNotification.js
Last active December 16, 2015 20:38
A basic AnguarlJS webkit notification service that only notifies when the window is not focused.
app.factory('desktopNotification', function ($window, $document) {
var focused = true;
var onFocus = function () { focused = true; };
var onBlur = function () { focused = false; };
if (/*@cc_on!@*/false) { // check for Internet Explorer
$document.onfocusin = onFocus;
$document.onfocusout = onBlur;
@mbrevoort
mbrevoort / isActive.js
Last active December 16, 2015 07:09
Simple browser IsActive - periodically emit if a user is active or still active, emit if inactive.
// var isActive = new IsActive(10000, window);
// isActive.on('active', function () { console.log('active') });
// isActive.on('inactive', function () { console.log('inactive') });
// isActive.start();
var IsActive = function (timerPeriod, g) {
timerPeriod = parseInt(timerPeriod) || 60000;
if (!g) g = window;
var ACTIVE = true,
@mbrevoort
mbrevoort / package.json_private_module
Created July 26, 2012 03:08
private npm repo namespace idea so that private registries don't have to replicate the entire public NPM registry or you don't have to do some sort of conditional proxying.
// A module published to a private registry would optionally have a "registry"
// property that is a reference to the registry where this module is published.
//
// A `npm publish` would publish to the registry in the registry property.
//
// Otherwise, `npm --registry http://private.me:5984/registry/_design/app/_rewrite publish`
//
{
"name": "foo",
@mbrevoort
mbrevoort / statsd.js
Created April 30, 2012 14:18
Simple Counter/Timer Statsd Node Client
var dgram = require('dgram');
module.exports = function (port, host) {
return new function() {
this._host = host || '127.0.0.1';
this._port = port || 8125;
this._client = dgram.createSocket("udp4");
this._send = function (message) {
console.log('STATSD', message);
@mbrevoort
mbrevoort / setup-statsd.sh
Created April 29, 2012 23:10 — forked from jasonroelofs/setup-statsd.sh
Turn an Ubuntu 10.10 EC2 into a StatsD/Graphite server
# install git
sudo apt-get --yes install g++ curl libssl-dev apache2-utils
sudo apt-get --yes install git-core
# download the Node source, compile and install it
git clone https://github.com/joyent/node.git ~/node
cd ~/node
./configure
make
sudo make install
# install the Node package manager for later use
@mbrevoort
mbrevoort / client.js
Created February 25, 2012 00:19
Simple proxy/service registration
var DNode = require('dnode'),
argv = require('optimist')
.usage('Usage: $0 --p [num] --pp [num] --name [str]')
.demand(['pp', 'name'])
.argv,
sprintf = require('sprintf').sprintf,
http = require('http'),
util = require('./util'),
DNode = require('dnode'),
logf = require('./util').logf,