This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
########################################## | |
# Bash port of aws rds generate-db-auth-token | |
# | |
# Required environment variables: | |
# AWS Credentials (AWS_ACCESS_KEY_ID; AWS_SECRET_ACCESS_KEY; AWS_SESSION_TOKEN) | |
# PGUSER: Database user name. | |
# PGHOST: Database host. | |
# PGDATABASE: Database name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MFA_DEVICE=$1 | |
if [ -z "$MFA_DEVICE" ]; then | |
echo "MFA device ARN not specified." >&2 | |
exit 1 | |
fi | |
# Prompt for OTP | |
OTP= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jwt = require('jsonwebtoken'); | |
const fs = require('fs'); | |
// Get jwt.dev.key from AWS Secrets Manager. | |
const privateKey = fs.readFileSync('jwt.dev.key'); | |
const payload = { | |
user: { | |
// Must correspond with the ID of a user, in whichever database your connecting to. | |
// Otherwise, inserts will fail, due to FK constraints. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const { yamlParse } = require('yaml-cfn'); | |
const merge = require('lodash/merge'); | |
const resourceReducer = (acc, [key, value]) => { | |
switch (value.Type) { | |
case 'AWS::Serverless::Application': | |
return merge(acc, { applications: { [key]: value } }); | |
case 'AWS::Serverless::Function': | |
return merge(acc, { functions: { [key]: value } }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SomeComponent = () => <span>Hello world</span> | |
export default [ | |
{ | |
path: '/', | |
name: 'main', | |
component: SomeComponent, | |
}, | |
{ | |
path: '/parent', | |
name: 'parent', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { startsWithSegment } from 'router5-helpers'; | |
import { transitionPath } from 'router5'; | |
// Reduces the activated routes, so the last status is used, defaulting to 200 | |
// Reducingg instead of finding, assures that child routes determine the status codes, even when a parent has a different one. | |
export const statusCodeDecorator = routes => () => (toState, fromState) => { | |
const status = getActivatedRoutes(routes, toState, fromState).reduce((s, route) => route.status || s, 200); | |
return Promise.resolve({ ...toState, status }); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const crypto = require('crypto'); | |
const KEY_LENGTH = 32; // Must be 32 bytes | |
const IV_LENGTH = 16; // For AES, this is always 16 | |
// Creates 32 byte key (for AES-256), buffer | |
const createKey = () => crypto.randomBytes(KEY_LENGTH); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.socket.client.IO | |
import io.socket.client.Socket | |
fun connect() { | |
val socket = IO.socket("http://localhost:4000?user=aksel") | |
socket.connect() | |
.on(Socket.EVENT_CONNECT, { println("connected") }) | |
.on(Socket.EVENT_DISCONNECT, { println("disconnected") }) | |
} |