Skip to content

Instantly share code, notes, and snippets.

View rxgx's full-sized avatar

Ryan Gasparini rxgx

View GitHub Profile
@rxgx
rxgx / rename-flow-to-typescript.js
Created August 1, 2019 03:42
Rename files with Flow annotation to TypeScript
const { genSummarizedReport } = require('flow-annotation-check');
const fs = require('fs');
const options = {
include: ['src/**/*.js'],
exclude: ['+(node_modules|build|flow-typed)/**/*.js'],
absolute: true,
};
function renameFile(srcPath, srcExt, destExt) {
@rxgx
rxgx / rename-to-jsx.js
Created July 31, 2019 21:02
Rename JS to JSX with ESLint JSON output
// Run eslint with the rule 'react/jsx-filename-extension' as 'error'
// eslint -o json > files.json
const fs = require('fs');
const json = require('./files.json')
console.log('run...', json.length);
json
.filter(entry => entry.messages.length)
const AWS = require('aws-sdk');
const client = new AWS.SecretsManager({});
// Call the AWS API and return a Promise
function getAwsSecret(secretName) {
return client.getSecretValue({ SecretId: secretName }).promise();
}
// Create a async function to use the Promise
@rxgx
rxgx / addEncryptedToken.js
Last active April 18, 2018 23:03
Auth0 rule to save an encrypted version of Google's refresh token to a user's app_metadata
function (user, context, callback) {
const namespace = 'https://grateful.digital/';
if (
user.app_metadata &&
user.app_metadata.refresh_token_encrypted
) {
const refreshTokenEncrypted = user.app_metadata.refresh_token_encrypted;
context.idToken[namespace + 'refresh_token_encrypted'] = refreshTokenEncrypted;
}
@rxgx
rxgx / server.js
Last active September 25, 2020 22:16
Express initial config
const cors = require('cors');
const express = require('express');
const corsConfig = {
optionsSuccessStatus: 200,
origin: ['http://localhost:3000', 'http://localhost:8000']
}
app = express();
@rxgx
rxgx / instagram-embed.html
Last active December 12, 2017 18:04
What you get when requesting an embed for: https://www.instagram.com/p/Bchw14MD64q/
<blockquote class="instagram-media" data-instgrm-captioned data-instgrm-version="7" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:658px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);">
<div style="padding:8px;">
<div style=" background:#F8F8F8; line-height:0; margin-top:40px; padding:62.5% 0; text-align:center; width:100%;">
<div style=" background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAMUExURczMzPf399fX1+bm5mzY9AMAAADiSURBVDjLvZXbEsMgCES5/P8/t9FuRVCRmU73JWlzosgSIIZURCjo/ad+EQJJB4Hv8BFt+IDpQoCx1wjOSBFhh2XssxEIYn3ulI/6MNReE07UIWJEv8UEOWDS88LY97kqyTliJKKtuYBbruAyVh5wOHiXmpi5we58Ek028czwyuQdLKPG1Bkb4NnM+VeAnfHqn1k4+GPT6uGQcvu2h2OVuIf/gWUFyy8OWEpdyZSa3aVCqpVoVvzZZ2VTnn2wU8qzVjDDetO90GSy9mVLqtgYSy231MxrY6I2gGqjrTY0L8fxCxfCBbhWrsYYAAAAAElFTkSuQmCC); display:block; height:44px; margin:0 auto -44px;
@rxgx
rxgx / eslint-prettier-package.json
Created August 11, 2017 23:21
If ESLint then Prettier
{
"eslintConfig": {
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"browser": true,
"es6": true,
@rxgx
rxgx / pr.sh
Created April 19, 2017 17:05
Pull Request Script
# Open browser and submit PR for current branch against master
pr () {
local repo=`git remote -v | grep -m 1 "(push)" | sed -e "s/.github.com[:/]\(.*/)\.git.*/\1/"`
local branch=`git name-rev --name-only HEAD`
echo "... creating pull request for branch \"$branch\" in \"$repo\""
open https://github.com/$repo/pull/new/$branch
}
@rxgx
rxgx / Dockerfile
Last active November 12, 2019 17:49
NodeJS Docker & Make Files
FROM node:lts
# Copy the working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN npm ci --no-progress
RUN npm run build --if-exists
# Exposes a port to other containers but your app may use any port specified in it