Skip to content

Instantly share code, notes, and snippets.

View koverholt's full-sized avatar

Kristopher Overholt koverholt

View GitHub Profile
import vertexai
from vertexai.generative_models import (
FunctionDeclaration,
GenerationConfig,
GenerativeModel,
Part,
Tool,
)
from datetime import datetime
@koverholt
koverholt / 1-soap-request.py
Last active January 26, 2023 07:29
Sending a SOAP request with Python
import json
import requests
import xmltodict
import pandas as pd
# SOAP URL, payload, and headers
url = "https://hydrometdata.lcra.org/service.asmx"
payload = """<?xml version="1.0" encoding="utf-8"?>
@koverholt
koverholt / clean_repeated_dates_in_filenames.py
Created November 24, 2019 04:42
Remove repeated dates after "--" strings in Markdown filenames
import os
def find_second(string, substring):
return string.find(substring, string.find(substring) + 1)
for root, dirs, files in os.walk("."):
for file in files:
if file.endswith(".md"):
old_path = os.path.join(root, file)
second_location = find_second(file, "--")
@koverholt
koverholt / clean_markdown_titles.py
Created November 24, 2019 04:42
Remove H1 titles from beginning of Markdown files
import os
buff = []
for root, dirs, files in os.walk("."):
for file in files:
if file.endswith(".md"):
path = os.path.join(root, file)
with open(path, "r") as f:
print(path)
@koverholt
koverholt / split.py
Created November 20, 2019 18:12
Split delimited Markdown files into smaller files
with open("export.md", "r") as f:
buff = []
i = 1
for line in f:
if line.strip() and line.strip() != "---":
buff.append(line)
# Preserve newlines in file
if not line.strip():
buff.append("\n")
#!/usr/bin/env python
"""
Display the per-commit size of a file in a git repository.
$ python counter.py setup.py
82e2452, 2016-02-23T23:57:25-05:00, 14 lines
94e26ae, 2016-02-24T12:01:39-06:00, 15 lines
26e51c5, 2016-03-07T13:35:19-06:00, 19 lines
fed0eb8, 2016-03-15T15:03:36-05:00, 18 lines
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyFPmr8gxiYTmuD+sFiQZofVII0xW1xBYY+SWEKU9vGOmSZeH/LFpLAouKPOh/3Rmutc67r27YwZ90GpMcw0flDwwpFUkb9ETgiULw4tysoIT119NklhVMuxhbgAgI9a9rTmsvYM5qDDYhiCef19xEFhKUitbp0WOF9idnV+OyvqfA7eudO80gqmwyiO7HWhaW5NmX4c4t95953sjq65CBFuyybC1lK5P6Nn+bEOo8KmldX3Cjmhxt69ZJu3tZRxAtqv5hw0abbD4Ou7BmsTSdRrp2JUQcS83s1YuRW5eFpqyl55rwbBaxYwtq0CHYGI/ismN9BdNHDBwv0jDbASPj koverholt@continuum
@koverholt
koverholt / spark_numpy.py
Created April 10, 2015 20:59
Simple Numpy example in Spark
import numpy as np
from pyspark import SparkContext
from pyspark import SparkConf
conf = SparkConf()
conf.setMaster("spark://<HOSTNAME>:7077")
conf.setAppName("NumpyMult")
sc = SparkContext(conf=conf)
@koverholt
koverholt / spark_wordcount.py
Last active August 29, 2015 14:17
Example Wordcount in Spark
from pyspark import SparkContext
from pyspark import SparkConf
if __name__ == "__main__":
conf = SparkConf()
conf.setMaster("spark://{hostname}:7077")
conf.setAppName("WordCount")
sc = SparkContext(conf=conf)
file = sc.textFile("/mnt/gluster/pg2591.txt")