Skip to content

Instantly share code, notes, and snippets.

View weisisheng's full-sized avatar

Vince Fulco--Bighire.tools weisisheng

View GitHub Profile
@weisisheng
weisisheng / lambda.js
Created April 19, 2021 12:13 — forked from sammarks/lambda.js
Slack notifications from AWS Amplify
const https = require('https')
exports.handler = async (event) => {
const sns = event.Records[0].Sns.Message
let color = ''
let message = ''
if (sns.includes('build status is FAILED')) {
color = '#E52E59'
message = 'Release to My Company **production** failed.'
} else if (sns.includes('build status is SUCCEED')) {
@weisisheng
weisisheng / parameterStore.ts
Created April 19, 2021 11:39 — forked from cbschuld/parameterStore.ts
Obtain values from the AWS Parameter store with Typescript/node
import { SSM } from "aws-sdk";
const getParameterWorker = async (name:string, decrypt:boolean) : Promise<string> => {
const ssm = new SSM();
const result = await ssm
.getParameter({ Name: name, WithDecryption: decrypt })
.promise();
return result.Parameter.Value;
}
@weisisheng
weisisheng / cloudformation-eb-apidestinations-demo.yaml
Created April 18, 2021 08:20 — forked from samuelcastle/cloudformation-eb-apidestinations-demo.yaml
Amazon EventBridge API Destinations demo - Cloudformation template
AWSTemplateFormatVersion: 2010-09-09
Parameters:
MailchimpMembersUrl:
Type: String
Default: https://xxx.api.mailchimp.com/3.0/lists/230948/members
MailchimpApiPassword:
Type: String
Default: REPLACEME
@weisisheng
weisisheng / emsiTokenGrabber.js
Created April 10, 2021 01:12
emsiTokenGrabber.js
"use strict";
//const AWS = require("aws-sdk");
const axios = require("axios");
const url = require("url");
// grabbing from AWS SAM template, better than hard coding.
const ClientID = process.env.ClientID;
const Secret = process.env.Secret;
@weisisheng
weisisheng / main.py
Created December 29, 2020 00:27 — forked from zackster/main.py
Serverless fasttext implementation. I have a blog post on the Code For Cash blog (blog.codefor.cash) that discusses what else is needed to run fasttext in a serverless AWS lambda environment: compiling fasttext on ec2 for linux, including nltk in the root directory of the zip, etc.
import string
import re
import nltk
def normalize(text):
# remove punctuation
text = re.sub('[%s]' % re.escape(string.punctuation), '', text)
# split into words
# nltk.data.path.append("/nltk_data")
from nltk.tokenize import word_tokenize
@weisisheng
weisisheng / apigateway-dynamo_serverless.yml
Created November 24, 2020 02:28 — forked from chris/apigateway-dynamo_serverless.yml
Serverless Framework config file for creating API Gateway to DynamoDB proxy
service: my-api
org: CompanyName
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
frameworkVersion: '>=2.1.1 <3.0.0'
custom:
defaultStage: dev
@weisisheng
weisisheng / lambda.js
Created November 17, 2020 04:26 — forked from breenie/lambda.js
SES push attachments to S3
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
const mailParser = require('mailparser').simpleParser;
const dateFormat = require('dateformat');
const path = require('path');
const config = {
incomingBucket: process.env.INCOMING_BUCKET || 'ldsc-webcam',
incomingPrefix: process.env.INCOMING_PREFIX || 'incoming/',
outgoingBucket: process.env.OUTGOING_BUCKET || 'ldsc-webcam',
{
"Comment": "A Hello World example of the Amazon States Language using Pass states",
"StartAt": "Create pending order",
"States": {
"Create pending order": {
"Type": "Pass",
"Next": "Select Payment Method"
},
"Select Payment Method": {
"Type": "Choice",
@weisisheng
weisisheng / SingleTableAppSync.md
Created September 5, 2020 09:48 — forked from dabit3/SingleTableAppSync.md
GraphQL Single Table Design with DynamoDB and AWS AppSync

GraphQL

GraphQL Schema

type Customer {
  id: ID!
  email: String!
}
/* eslint-disable no-undef, react/prop-types */
import React from 'react';
import { css } from 'react-emotion';
import { Box, Flex } from '../../components/Layout';
import colors from '../../utils/colors';
import ButtonPrimary from '../../components/Buttons';
const input = css`
display: block;
box-sizing: border-box;