Skip to content

Instantly share code, notes, and snippets.

View sbrichardson's full-sized avatar
:octocat:
In coding land

Stephen Richardson sbrichardson

:octocat:
In coding land
View GitHub Profile
@sbrichardson
sbrichardson / auth_frame.html
Created September 27, 2016 22:35
Meteor Duo iFrame Template
<template name="loginAuthFrame">
<div class="ui raised very padded text container segment">
<iframe id="duo_iframe" frameborder="0"></iframe>
<style>
#duo_iframe {
width: 100%;
min-width: 304px;
max-width: 620px;
height: 330px;
}
//refactor to your own app's layout/settings as needed. Using FlowRouter with Blaze Layout below.
FlowRouter.route('/auth', {
name: 'auth',
action: function(params, queryParams) {
BlazeLayout.render("mainLayout", {
content: "loginAuthFrame"
});
}
});
@sbrichardson
sbrichardson / auth_frame.js
Last active September 27, 2016 23:20
Meteor Duo iFrame Template js
//basic function to process the response from Duo and route to another page. Param will be the HTML form component.
const processSubmit = function(form) {
// check to ensure correct parameter format
check(form, Match.Where(x => {
return x.nodeName === 'FORM';
}));
// get the input component from the form
const responseInput = form.elements.namedItem("sig_response");
// get the value of the input
const sig_response = responseInput && responseInput.value;
@sbrichardson
sbrichardson / duo.js
Created September 27, 2016 22:04
Meteor.js Duo Security Methods
import lo_ from 'lodash';
import Duo from 'duo_web';
// using lodash .get https://lodash.com/docs/4.16.2#get to access nested object properties safely
// get settings from Meteor settings.json
const duoSettings = lo_.get(Meteor, 'settings.services.duoSecurity', null);
if (!duoSettings) {
throw new Meteor.Error('err - Duo API settings.json not available');
}
@sbrichardson
sbrichardson / new_telemetry.yaml
Created October 26, 2017 02:10
Istio.io Prometheous Metrics telemetry config
# Configuration for metric instances
apiVersion: "config.istio.io/v1alpha2"
kind: metric
metadata:
name: doublerequestcount
namespace: istio-system
spec:
value: "2" # count each request twice
dimensions:
source: source.service | "unknown"
#!/bin/bash
#
# Checks Google Cloud container registry to see if build has finished deploying new image from source repository recent update.
# Retries 15 times, waiting 20 seconds between attempts.
#
DEPLOYMENT="$(basename -s .git `git config --get remote.origin.url`)"
PROJECT_ID="$(gcloud config get-value project)"
IMAGE_NAME="gcr.io/$(gcloud config get-value project)/$DEPLOYMENT:$(git rev-parse HEAD)"
@sbrichardson
sbrichardson / makeFieldList.js
Last active November 18, 2017 09:03
Will build a mongodb fields list filter from a graphql query resolver
///////////////////
// makeFieldList //
///////////////////
const filterString = '_r'
const reg = new RegExp(`${filterString}$`)
/**
* @param {Object[]} fields The selectionSet selections array from the resolver info arg.
* @param {Object} [f={}] Fields object, used with recursive calls
@sbrichardson
sbrichardson / formikApollo.js
Created November 19, 2017 02:55 — forked from mwickett/formikApollo.js
Formik + Apollo
import React from 'react'
import { withRouter, Link } from 'react-router-dom'
import { graphql, compose } from 'react-apollo'
import { Formik } from 'formik'
import Yup from 'yup'
import FormWideError from '../elements/form/FormWideError'
import TextInput from '../elements/form/TextInput'
import Button from '../elements/form/Button'
import { H2 } from '../elements/text/Headings'
@sbrichardson
sbrichardson / RLog.js
Created December 1, 2017 18:27
RLog Benchmark Class
class RLog {
contructor(title) {
this.kind = 'Method Log'
this.name = title
this.book = {
new: true,
errors: [],
successes: [],
errorCount: 0,
successCount: 0,
@sbrichardson
sbrichardson / sqlite-to-json.js
Created January 11, 2019 01:08
Browser based sqlite -> JSON/CSV. Exports sqlite database tables (using sql.js) to JSON, CSV, other (dev in progress).
/* NOTE Originally based on github.com/Philzen/WebSql-Loader */
const TABLE_SQL = "SELECT tbl_name from sqlite_master WHERE type = 'table'"
const MASTER_SQL = 'SELECT sql FROM sqlite_master'
const WEBKIT_INFO = '__WebKitDatabaseInfoTable__'
/* TODO Add other formats */
const FORMAT = {
JSON: 'json',
// CSV: 'csv',