Skip to content

Instantly share code, notes, and snippets.

View singledigit's full-sized avatar

Eric Johnson singledigit

View GitHub Profile
@singledigit
singledigit / Custom Validation
Last active September 18, 2015 17:29
Aurelia-Validation: My approach at centralizing the validation and still being able to use custom-validation
import moment from 'moment';
export function isValidDate(fmt) {
let dateFormat = fmt || 'MM/DD/YYYY';
this.passes((newValue) => {
let mmt = moment(newValue, dateFormat);
return mmt.isValid() && mmt.format(dateFormat) === newValue;
});
return this;
/**
* Created by ericjohnson on 10/6/15.
*/
import moment from 'moment';
export class Storage {
constructor() {
this.index = {};
this.storage = window.localStorage;
@singledigit
singledigit / action-intent-request.js
Last active February 25, 2016 10:22
Alexis Skill Skeleton Files
/**
* Created by ericjohnson on 2/23/16.
*/
let model = require('./response-model'),
utilities = require('./utilities'),
ActionLaunchRequest = require('./action-launch-request'),
client = require('api-client');
export function intent(event, context) {
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Hello world!</h1>
<script src="script.js"></script>
@singledigit
singledigit / Auth Class
Last active October 3, 2022 18:00
Pattern for using Cognito User Pools as authentication against Cognito Identity
import {inject} from 'aurelia-framework';
import {Session} from './session';
@inject(Session)
export class Auth {
// App specific
userPoolId = 'us-east-1_fgCWraBkF';
appClientId = '57lq262n28o7ddt8i36jcjj7qd';
@singledigit
singledigit / Activate
Last active February 11, 2021 23:57
Code examples for Serverless Architecture Demo part 3
activate(){
return this.auth.getSession();
}
@singledigit
singledigit / aureila-dynamic-validation-rules.js
Last active October 11, 2016 21:08
Dynamically build Aurelia Validation rules.
//This is a rough attempt at dynamically building validation rules based on a JSON document.
let rules = [];
Forms[this.viewing].map(field => {
if(field.required && !field.viewIf){
rules.push(ValidationRules.ensure(field.propName).required().rules[0])
}
if (field.required && field.viewIf) {
rules.push(ValidationRules.ensure(field.propName).required()
@singledigit
singledigit / Base File
Last active June 7, 2018 16:39
Cloudformation Files for Creating a Serverless CICD Pipeline
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Deployment Stack'
Parameters:
GitHubToken:
NoEcho: true
Type: String
Description: Secret. It might look something like 9b189a1654643522561f7b3ebd44a1531a4287af OAuthToken with access to Repo. Go to https://github.com/settings/tokens"
GitHubOwner:
Type: String
Description: GitHub UserName
@singledigit
singledigit / Usage
Last active March 27, 2017 21:04
Aurelia value-converter allowing two string values to be used as a checkbox boolean
<input type="checkbox" checked.bind="color | checkedValue:'Green':'Blue'" />
@singledigit
singledigit / cognito.yaml
Last active January 16, 2024 16:15
Create a Cognito Authentication Backend via CloudFormation
AWSTemplateFormatVersion: '2010-09-09'
Description: Cognito Stack
Parameters:
AuthName:
Type: String
Description: Unique Auth Name for Cognito Resources
Resources:
# Creates a role that allows Cognito to send SNS messages
SNSRole: