Skip to content

Instantly share code, notes, and snippets.

View onelharrison's full-sized avatar

Onel Harrison onelharrison

View GitHub Profile
locals {
sys_admin_role = "SYSADMIN"
snowflake_user = "SANDBOX_USER"
}
resource "snowflake_database" "sandbox" {
provider = snowflake.sys_admin
name = "SANDBOX"
}
export AWS_PROFILE=<aws-profile>
export SNOWFLAKE_USER=<snowflake-user>
export SNOWFLAKE_PASSWORD=<snowflake-password>
export SNOWFLAKE_ACCOUNT=<snowflake-account>
export SNOWFLAKE_REGION=<snowflake-region>
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
snowflake = {
source = "chanzuckerberg/snowflake"
version = "~> 0.25"
@onelharrison
onelharrison / subsets.py
Last active August 21, 2021 03:35
Python recipe for generating subsets
from itertools import chain, combinations
from typing import Collection, Iterable, Optional
def subsets(
collection: Collection, min_size: int = 0, max_size: Optional[int] = None
) -> Iterable:
"""Produce all the subsets of `collection` with cardinalities between
`min_size` and `max_size` (inclusive)."""
def log_before(f):
def _wrapper(*args, **kwargs):
print("logging before...")
f(*args, **kwargs)
return _wrapper
def log_after(f):
def _wrapper(*args, **kwargs):
from typing import Any, Tuple
Pair = Tuple[Any, Any]
def pair_first(pair: Pair) -> Any:
"""Returns the first item in a given pair"""
return pair[0]
from math import floor, sqrt
def is_even(num: int) -> bool:
"""Returns True if a given number is even, otherwise False"""
return num % 2 == 0
def is_prime(num: int) -> bool:
"""Returns True if a given number is prime, otherwise False"""
def first_name(full_name: str) -> str:
"""Extracts and returns the first name from a full name"""
return full_name.split(" ")[0]
def square(n: int) -> int:
"""Returns the square of the given number"""
return n ** 2
@onelharrison
onelharrison / rpn_evaluator.py
Last active June 19, 2021 14:05
Python script for evaluating expressions in Reverse Polish Notation
#!/usr/bin/env python
import logging
import operator as op
import sys
from typing import Any, List, Union
logging.getLogger(__name__).setLevel("INFO")
supported_operators = {"+": op.add, "-": op.sub, "*": op.mul, "/": op.truediv}
import redis
r = redis.Redis(host='localhost', port=6379, db=1)
r.set('hello', 'world') # True
value = r.get('hello')
print(value) # b'world'
r.delete('hello') # True