Skip to content

Instantly share code, notes, and snippets.

View philippatterson's full-sized avatar

Philip Patterson philippatterson

View GitHub Profile
@veselosky
veselosky / s3gzip.py
Last active August 29, 2024 11:32
How to store and retrieve gzip-compressed objects in AWS S3
# vim: set fileencoding=utf-8 :
#
# How to store and retrieve gzip-compressed objects in AWS S3
###########################################################################
#
# Copyright 2015 Vince Veselosky and contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@scarytom
scarytom / openfigi.sh
Created June 15, 2016 09:00
Script to call openfigi with a list of ISINs and return instrument data as JSON
#!/bin/sh -eu
BATCH_SIZE=100
debug() {
#echo "${1}" 1>&2
true
}
isin_to_json() {
@romaninsh
romaninsh / lambda-vpc-internet-access-cloudformation.yml
Last active December 22, 2021 00:26
CloudFormation template implementing Private network which can be used by Serverless to deploy Lambda into VPCs an maintaining internet access
# Add the following to your existing VPC CF stack
# create 2 subnets, lambdas like to be in multiple subnets
Private1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 0, !GetAZs ]
CidrBlock: !Ref Private1CIDR
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@markusrenepae
markusrenepae / simulator.py
Created January 2, 2020 22:22
This gist is for another medium article and is about an investment simulator.
import pandas as pd
import numpy as np
import datetime as dt
import math
import warnings
warnings.filterwarnings("ignore")
prices = pd.read_csv("adjclose.csv", index_col="Date", parse_dates=True)
volumechanges = pd.read_csv("volume.csv", index_col="Date", parse_dates=True).pct_change()*100
@hugo1005
hugo1005 / portfolio_opimization.py
Created January 22, 2021 21:10
portfolio_opimization
import requests
import pandas as pd
import time
import json
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import seaborn as sns
from tqdm import tqdm
import cvxopt as opt
import bornly as bns
import numpy as np
import pandas as pd
from pmdarima import auto_arima
from statsmodels.tsa.statespace.sarimax import SARIMAX
flights = bns.load_dataset("flights")
flights["t"] = np.arange(len(flights))
PERIOD = 12
n_steps = 12
@allenheltondev
allenheltondev / index.js
Created September 21, 2022 12:44
Parameterize Step Function Workflow Definition
const fs = require('fs');
const YAML = require('json-to-pretty-yaml');
const definition = JSON.parse(fs.readFileSync('definition.asl.json'));
const substitutions = [];
parameterizeStates(definition.States, substitutions);
console.log(substitutions)