Skip to content

Instantly share code, notes, and snippets.

View PsycheShaman's full-sized avatar
:atom:
wizarding

Christiaan Gerhardus Viljoen PsycheShaman

:atom:
wizarding
View GitHub Profile
@PsycheShaman
PsycheShaman / unzip_s3_source_data.py
Created September 13, 2021 06:59
Python function to unzip an archive stored in S3 to a specified destination folder in S3.
import boto3
import io
import zipfile
def unzip_s3_source_data(
s3_source_bucket: str,
s3_source_folder: str,
s3_destination_folder: str
) -> None:
"""
import pandas as pd
def set_pd_display():
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', None)
select city_name, current_date, get_weather_udf(city_name)
from cities;
CREATE OR REPLACE EXTERNAL FUNCTION get_weather_udf (city varchar)
RETURNS varchar STABLE
LAMBDA 'my-function'
IAM_ROLE '<Role ARN>';
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Invoke",
"Effect": "Allow",
"Action": [
"lambda:InvokeFunction"
],
"Resource": "arn:aws:lambda:us-west-2:123456789012:function:my-function"
import http.client
from geopy.geocoders import Nominatim
import json
def geo_code(city):
geo_locator = Nominatim(user_agent="medium_article_example")
location = geo_locator.geocode(city)
print(location.latitude, location.longitude)
return (location.latitude, location.longitude)
create table cities (city_name varchar);
insert into dev.public.cities
(city_name)
values ('Cape Town'),('Pretoria'),('Johannesburg'),('Bloemfontein');
sudo apt-get install apache2-utils
htpasswd -B -C 10 password.db newusername
# To verify that the password was created correctly, you can run:
htpasswd -v password.db newusername
password-authenticator.name=file
file.password-file=/etc/presto/password.db
file-refresh-period=1m
file.auth-token-cache.max-size=1000
http-server.authentication.type=PASSWORD
web-ui.authentication.type=form