Skip to content

Instantly share code, notes, and snippets.

@billydh
billydh / build.gradle.kts
Created November 8, 2020 07:41
dynamodb-enhanced dependency
...
...
dependencies {
...
...
implementation("software.amazon.awssdk:dynamodb-enhanced")
}
dependencyManagement {
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient
import software.amazon.awssdk.services.dynamodb.model.*
import java.util.concurrent.CompletableFuture
class CustomerRepo(private val client: DynamoDbAsyncClient,
private val customerTableName: String) {
fun saveCustomer(customer: CustomerPersist): CompletableFuture<PutItemResponse> {
val putItemRequest = PutItemRequest.builder()
.item(
@billydh
billydh / main.py
Last active June 1, 2020 12:58
Entry point for Zoom meeting attendance report automation
import os
from typing import List
import pandas as pd
from pandas import DataFrame
from requests import Response
from googl import Googl
from zoom import Zoom
@billydh
billydh / googl.py
Created June 1, 2020 12:10
Google class to get folder id in Google Drive, create new Google Sheet, insert pandas DataFrame into Google Sheet and get Google Sheet link by its id
from typing import List
from google.oauth2 import service_account
from googleapiclient import discovery
from pandas import DataFrame
class Googl:
def __init__(self, service_account_file: str, scopes: List[str]):
self.service_account_file = service_account_file
@billydh
billydh / zoom.py
Created June 1, 2020 11:59
Zoom class to call report meeting participants API
import time
from typing import Optional, Dict, Union, Any
import requests
from authlib.jose import jwt
from requests import Response
class Zoom:
def __init__(self, api_key: str, api_secret: str):
@billydh
billydh / requirements.txt
Created June 1, 2020 11:44
Dependencies for Zoom reporting program
requests==2.23.0
Authlib==0.14.1
pandas==1.0.3
google-api-python-client==1.8.0
@billydh
billydh / download_sheet_to_csv.py
Created May 3, 2020 13:47
Python function to download a Sheet from a Google Spreadsheet into a csv file
import csv
def download_sheet_to_csv(sheets_instance, spreadsheet_id, sheet_name):
result = sheets_instance.spreadsheets().values().get(spreadsheetId=spreadsheet_id, range=sheet_name).execute()
output_file = f'{sheet_name}.csv'
with open(output_file, 'w') as f:
writer = csv.writer(f)
writer.writerows(result.get('values'))
from googleapiclient import errors
def get_spreadsheet_id(api_service, spreadsheet_name):
results = []
page_token = None
while True:
try:
param = {'q': 'mimeType="application/vnd.google-apps.spreadsheet"'}
@billydh
billydh / get_api_services.py
Created May 3, 2020 13:41
Python function to initialise drive and sheets API services
from googleapiclient import discovery
from httplib2 import Http
from oauth2client import file, client, tools
def get_api_services():
# define credentials and client secret file paths
credentials_file_path = './credentials/credentials.json'
clientsecret_file_path = './credentials/client_secret.json'
@billydh
billydh / send_record.py
Created April 29, 2020 08:02
Adjusted Avro Producer code due to change in parse_command_line_args function
#!/usr/bin/env python
import json
import uuid
from confluent_kafka.avro import AvroProducer
from utils.load_avro_schema_from_file import load_avro_schema_from_file
from utils.parse_command_line_args import parse_command_line_args