Skip to content

Instantly share code, notes, and snippets.

Christopher Martin cgmartin

Block or report user

Report or block cgmartin

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
cgmartin /
Last active Aug 29, 2019
Vera Auth Sessions Example
set -e
command -v jq >/dev/null 2>&1 || { echo >&2 "I require jq but it's not installed (see: Aborting."; exit 1; }
command -v curl >/dev/null 2>&1 || { echo >&2 "I require curl but it's not installed (see: Aborting."; exit 1; }
# Auth API Notes:,24942.45.html
# New Server domains listing:,25859.0.html
# Example implementations:
cgmartin / RBLuaTest.lua
Last active Feb 28, 2018
RBLuaTest.lua Modifications (1.7) [Works in UI7 v1.7.3015]
View RBLuaTest.lua
module("RBLuaTest", package.seeall)
local version = "1.7"
local luadir = "/etc/cmh-ludl/"
LuaTest is a tool for testing Vera scene Lua code. It runs on Vera as an http handler.
Upload RBLuaTest.lua to Vera using APPS->Develop Apps->Luup files then restart Vera.
Enter following three lines into APPS->Develop Apps->Test Luup code (LUA) and click GO:
cgmartin /
Last active Dec 10, 2018
Scripts for manually creating Let's Encrypt certificates for AWS S3/CloudFront
# Usage:
# $
echo "Current list of certificates in AWS"
echo "-----------------------------------"
aws iam list-server-certificates
read -p "Domain name: " domain_name
cgmartin /
Created Jan 17, 2016
Bash SSL Certificate Expiration Check
echo "checking if $TARGET expires in less than $DAYS days";
expirationdate=$(date -d "$(: | openssl s_client -connect $TARGET:443 -servername $TARGET 2>/dev/null \
| openssl x509 -text \
| grep 'Not After' \
|awk '{print $4,$5,$7}')" '+%s');
in7days=$(($(date +%s) + (86400*$DAYS)));
cgmartin / users-router.js
Created Nov 12, 2015
node-cache-manager promisify example (w/ bluebird)
View users-router.js
'use strict';
var express = require('express');
var usersApi = require('../lib/users-api');
var Promise = require('bluebird');
var cacheManager = require('cache-manager');
var cache = cacheManager.caching({store: 'memory', max: 100, ttl: 900});
cgmartin /
Last active Aug 29, 2015 — forked from domenic/
Node git pre-commit hook

Here's how this works:

  • Include a git-hooks/ directory in your project, with these two files (plus other hooks if you want, written in a similar style).
  • Ensure the files under the git-hooks/ directory are executable: chmod 755 git-hooks/*
  • Add test script to your package.json, e.g.
    "scripts": {
        "test": "mocha"
cgmartin / logging-middleware.js
Created May 24, 2015
Morgan JSON log format example
View logging-middleware.js
'use strict';
var morgan = require('morgan');
var os = require('os');
morgan.token('conversation-id', function getConversationId(req) {
return req.conversationId;
morgan.token('session-id', function getSessionId(req) {
return req.sessionId;
cgmartin / all-in-one.js
Created Mar 12, 2015
Node Proxy Example
View all-in-one.js
'use strict';
var port = parseInt(process.env.PROXY_PORT || process.env.PORT || 8000);
process.env.PROXY_PORT = port;
process.env.STATIC_PORT = port + 1;
process.env.API_PORT = port + 2;
process.env.CHAT_PORT = port + 3;
cgmartin / gulpfile.js
Created Feb 8, 2015
Node ES6 istanbul, isparta, mocha-co gulpfile example
View gulpfile.js
'use strict';
var gulp = require('gulp');
var del = require('del');
var mocha = require('gulp-mocha-co');
var istanbul = require('gulp-istanbul');
var isparta = require('isparta');
var coverageEnforcer = require('gulp-istanbul-enforcer');
var paths = {
server: {
cgmartin / datepicker.decorator.js
Last active May 21, 2018
Send an event to refresh view of ui-bootstrap datepicker
View datepicker.decorator.js
* Decorates the ui-bootstrap datepicker directive's controller to allow
* refreshing the datepicker view (and rerunning invalid dates function)
* upon an event trigger: `$scope.$broadcast('refreshDatepickers');`
* Works with inline and popup. Include this after `ui.bootstrap` js
.config(function($provide) {
$provide.decorator('datepickerDirective', function($delegate) {
You can’t perform that action at this time.