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
cgmartin / vera_auth_test.sh
Last active Nov 5, 2017
Vera Auth Sessions Example
View vera_auth_test.sh
#!/bin/bash
set -e
command -v jq >/dev/null 2>&1 || { echo >&2 "I require jq but it's not installed (see: https://stedolan.github.io/jq/). Aborting."; exit 1; }
command -v curl >/dev/null 2>&1 || { echo >&2 "I require curl but it's not installed (see: https://curl.haxx.se/). Aborting."; exit 1; }
# Auth API Notes: http://forum.micasaverde.com/index.php/topic,24942.45.html
# New Server domains listing: http://forum.micasaverde.com/index.php/topic,25859.0.html
# Example implementations:
# https://github.com/rickbassham/vera/blob/master/vera_test.py
# https://github.com/amg0/ALTUI/blob/master/Remote/VeraloginAction.php
@cgmartin
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
cgmartin / le-aws-upload-cert.sh
Last active Dec 10, 2018
Scripts for manually creating Let's Encrypt certificates for AWS S3/CloudFront
View le-aws-upload-cert.sh
#!/bin/bash
# Usage:
# $ le-aws-upload-cert.sh
echo "Current list of certificates in AWS"
echo "-----------------------------------"
aws iam list-server-certificates
echo
read -p "Domain name: " domain_name
@cgmartin
cgmartin / check-certs.sh
Created Jan 17, 2016
Bash SSL Certificate Expiration Check
View check-certs.sh
#!/bin/bash
TARGET="mysite.example.net";
RECIPIENT="hostmaster@mysite.example.net";
DAYS=7;
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
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});
Promise.promisifyAll(cache);
@cgmartin
cgmartin / README.md
Last active Aug 29, 2015 — forked from domenic/README.md
Node git pre-commit hook
View README.md

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
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
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;
require('./proxy-server');
require('./static-server');
@cgmartin
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
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
*/
angular.module('ui.bootstrap.datepicker')
.config(function($provide) {
$provide.decorator('datepickerDirective', function($delegate) {
You can’t perform that action at this time.