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
"""logger.py | |
Author: Garin Wally; May 9, 2023 | |
This file provides a utility for creating logger objects for logging messages to a file. | |
""" | |
import datetime as dt | |
import logging | |
from pathlib import Path | |
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
# Strategy Pattern for GIS Data Processing | |
# As derived from: | |
# https://refactoring.guru/design-patterns/strategy/python/example#lang-features | |
from abc import ABC, abstractmethod | |
class Strategy(ABC): | |
# Using ABC (Abstract-Base-Class) and @abstractmethod forces | |
# the user to redefine the "main" method |
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 re | |
import pandas as pd | |
def df_to_markdown(df, index=False): | |
"""Converts a pandas DataFrame to a Markdown string. | |
Args: | |
df (DataFrame): dataframe to convert | |
index (bool): optionally, keep the DataFrame index (default False) |
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 re | |
import string | |
import PyPDF2 | |
def clean_pdf_text(pdfobj, page_num): | |
# Get text from PDF object by page number | |
page_text = pdfobj.getPage(page_num).extractText() | |
# Remove double-spaces | |
page_text = page_text.replace(" ", " ") |
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
///// Variables | |
///// Removals | |
///// Replacements/Alterations | |
import minetweaker.item.IIngredient; | |
/////////////////////////////////////////////////////////////////////////////// | |
// Variables | |
/////////////////////////////////////////////////////////////////////////////// |
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
# -*- coding: utf-8 -*- | |
""" | |
Makes a geojson-dashboard config.json file from an input geojson file. | |
Author: Garin Wally; Aug 2017 | |
Use: | |
> python make_config.py us_bounds.json | |
""" | |
import os |
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
""" | |
swtich.py -- JS switches in Python (proof of concept) | |
Author: Garin Wally; Nov 2016 | |
Just took the JavaScript tutorial at codecademy and thought switches were | |
pretty cool, so I coded one up in Python. | |
I have to admit, this implementation is not great, not pretty, and likely | |
not shorter than a standard if/elif/else block. | |
""" |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
get_users.py -- Searches Window's /Users/ file for write-accessable user folders | |
and returns a list of write-accessible folder names (i.e. likely user name). | |
""" | |
import os | |
def get_users(): |
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 locale | |
n = unicode(raw_input().decode(locale.getpreferredencoding())) | |
# Where the input is `José` |
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
# -*- coding: utf-8 -*- | |
import os | |
import codecs | |
from subprocess import Popen, PIPE | |
import apsw | |
db = "test.sqlite" | |
sqlite = "sqlite3_test.sql" |
NewerOlder