Skip to content

Instantly share code, notes, and snippets.

View rpivo's full-sized avatar

Ryan Pivovar rpivo

  • New York City, NY
View GitHub Profile
@rpivo
rpivo / index.md
Created February 8, 2021 00:25
The Difference Between Columnar-Based & Row-Based Storage

The Difference Between Columnar-Based & Row-Based Storage

Row-Based Storage
1. Marc, Johnson, Washington, 27
2. Jim, Thompson, Denver, 33
3. Jack, Riley, Seattle, 51

Columnar-Based Storage
ID: 1,2,3
@rpivo
rpivo / index.md
Created February 14, 2021 07:49
Checking the Type of a Variable in Python

Checking the Type of a Variable in Python

l = [1, 2, 3, 4, 5]
n = 5
s = 'hello'

print(
  type(l), # <class 'list'>
 type(n), # 
@rpivo
rpivo / index.md
Last active February 14, 2021 21:10
Publishing a Message to an AWS SNS Topic From an AWS Lambda Function Using Boto3

Publishing a Message to an AWS SNS Topic From an AWS Lambda Function Using Boto3

import json
import boto3

def lambda_handler(event, context):
    message = {'key': 'value'}

 boto3.client('sns').publish(
@rpivo
rpivo / index.md
Last active February 14, 2021 22:42
Installing a Python Package in the Current Directory With pip

Installing a Python Package in the Current Directory With pip

Example below uses pip3 to install the pytrends package and its dependencies inside a subfolder called package within the current directory.

pip3 install pytrends --target ./package
@rpivo
rpivo / index.md
Created February 14, 2021 22:45
Making All Files Within the Current Directory Readable on Linux & Mac

Making All Files Within the Current Directory Readable on Linux & Mac

-R runs the operation recursively so that all nested files are made readable.

chmod -R +r .
@rpivo
rpivo / index.md
Created February 15, 2021 02:53
Unzip a File Into a Specific Folder With Bash

Unzip a File Into a Specific Folder With Bash

The below command unzips someFile.zip into the package directory.

unzip someFile.zip -d package
@rpivo
rpivo / index.md
Created February 15, 2021 03:03
Using the AWS CLI to Push an Updated Zip File to an AWS Lambda Function

Using the AWS CLI to Push an Updated Zip File to an AWS Lambda Function

aws lambda update-function-code --function-name name-of-function --zip-file fileb://name-of-zipe-file.zip
@rpivo
rpivo / index.md
Last active February 22, 2021 00:42
Adding Another File to a Zip Folder With Bash

Adding Another File to a Zip Folder With Bash

The below assumes that a publish.zip file already exists. You can zip up another file in this folder like so:

zip -g lambda.zip lambda_function.py
@rpivo
rpivo / index.md
Last active February 15, 2021 15:34
Opening an Interactive Shell in Docker

Opening an Interactive Shell in Docker

Below are the flags used in this Docker command.

  • -i: Keeps STDIN open, even if not attached.
  • -t: Short for "tty", or teletypewriter. Allocates a tty for the process, which basically means that a shell is opened up to be used alongs the open STDIN.
  • -v: specifies a volume that you want to bind mount. In the example below, this binds the current directory to a folder in the Docker container called virtual-folder

We can allide the -i and -t flags since they don't have any arguments. -v can be kept separate since we need to specify an argument for it.

@rpivo
rpivo / index.md
Last active February 15, 2021 16:41
Manually Starting an Amazon Linux Docker Container and Preparing Python Packages for AWS Lambda

Manually Starting an Amazon Linux Docker Container and Preparing Python Packages for AWS Lambda

You can start an interactive shell with an amazonlinux Docker container with this command:

docker run -it -v ~/Documents/dev/folder:/virtual-folder amazonlinux

See this gist for more details on the above.