This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
path = "image_path.png" | |
encoded_path = "encoded.txt" | |
decoded_path = "image_restored.png" | |
with open(path, 'rb') as file: | |
data = base64.encodestring(file.read()) | |
with open(encoded_path, "wb") as txt: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# EditorConfig is awesome: https://EditorConfig.org | |
# top-most EditorConfig file | |
root = true | |
[*] | |
indent_style = space | |
indent_size = 2 | |
end_of_line = lf | |
charset = utf-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GREEN='\033[1;32m' | |
WHITE='\033[0m' | |
EDITORCONFIG='https://gist.githubusercontent.com/Menziess/97ce53ea86d70e4e95eef6097ea40a72/raw/d0780eba0$ | |
SETTINGS_JSON='https://gist.githubusercontent.com/Menziess/dc3d46c4c7743c08626ea2d325d313a3/raw/05411512$ | |
if [ $# -eq 0 ] | |
then | |
echo "Please provide a new project name" && exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name | hp | attack | attack_spd | attack_type | role | ||
---|---|---|---|---|---|---|---|
1 | Abathur | 685 | 26 | 1.43 | Melee | Specialist | |
2 | Anub'arak | 1926 | 99 | 1 | Melee | Warrior | |
3 | Artanis | 2335 | 111 | 1 | Melee | Warrior | |
4 | Arthas | 2382 | 99 | 1 | Melee | Warrior | |
5 | Azmodan | 2738 | 85 | 1 | Ranged | Specialist | |
6 | Brightwing | 1470 | 85 | 1.11 | Ranged | Support | |
7 | Chen | 2556 | 84 | 1.11 | Melee | Warrior | |
8 | Cho | 3528 | 120 | 0.91 | Melee | Warrior | |
9 | Dehaka | 2434 | 110 | 1.11 | Melee | Warrior |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
The solution is to make sure that structs in the DataFrame schema are not of NullType. | |
""" | |
def replace_nulls_struct_fields(df): | |
""" | |
Convert NullType fields in structs. | |
""" | |
old_schema = df.schema | |
new_schema = old_schema.fromJson( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Specify format for logging | |
format = '%(asctime)s - %(message)s' | |
# Set logging config | |
logging.basicConfig(stream=sys.stdout, | |
level=logging.INFO, | |
format=format) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage: curl https://pyenv.run | bash | |
# | |
# For more info, visit: https://raw.githubusercontent.com/pyenv/pyenv-installer | |
# | |
set -e | |
echo "> Prechecks" | |
if [[ -z "$http_proxy" ]]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Databricks notebook source | |
dbutils.widgets.removeAll() | |
def mount(source, mount_point, extra_configs): | |
try: | |
dbutils.fs.mount( | |
source=source, | |
mount_point=mount_point, | |
extra_configs=extra_configs) | |
dbutils.widgets.removeAll() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def deep_ls(path: str, max_depth=1, reverse=False, key=None, keep_hidden=False): | |
"""List all files in base path recursively. | |
List all files and folders in specified path and subfolders within maximum recursion depth. | |
Parameters | |
---------- | |
path : str | |
The path of the folder from which files are listed | |
max_depth : int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyspark.sql import DataFrame, Window | |
def change_data_capture( | |
df: DataFrame, | |
partition_col, | |
valid_from_col, | |
valid_to_col, | |
capture_columns=[] | |
): |
OlderNewer