Skip to content

Instantly share code, notes, and snippets.

View zackproser's full-sized avatar
💭
Studying 📖

Zack Proser zackproser

💭
Studying 📖
View GitHub Profile
@zackproser
zackproser / delete-namespace.py
Created June 6, 2024 11:18
Pinecone delete namespace
index.delete(delete_all=True, namespace='example-namespace')
@zackproser
zackproser / pinecone-attach-metadata.py
Created June 6, 2024 11:17
Pinecone attach metadata
index.upsert(
vectors=[
{
"id": "order1#chunk1",
"values": [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
"metadata": {"user_id": 3046, "url": "https://example.com"}
},
{
"id": "order2#chunk2",
"values": [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2],
@zackproser
zackproser / delete-id-prefixes.py
Created June 6, 2024 11:17
Pinecone delete with ID prefixes
for ids in index.list(prefix='order1#', namespace='orders'):
print(ids) # ['order1#chunk1', 'order1#chunk2', 'order1#chunk3']
index.delete(ids=ids, namespace=namespace)
@zackproser
zackproser / iterate-prefixes.py
Created June 6, 2024 11:16
Pinecone iterate over ID prefixes
# Iterate over all chunks from order #1
for ids in index.list(prefix='order1#', namespace='orders'):
print(ids)
@zackproser
zackproser / id-prefixing.py
Created June 6, 2024 11:11
Pinecone ID-prefixing
index = pc.Index("serverless-index")
index.upsert(
vectors=[
{"id": "order1#chunk1", "values": [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]},
{"id": "order1#chunk2", "values": [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2]},
{"id": "order1#chunk3", "values": [0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3]},
{"id": "order1#chunk4", "values": [0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4]}
],
namespace="orders"
@zackproser
zackproser / Install Hashicorp Nomad on Linux
Created May 1, 2023 12:17
A shell script to install an arbitrary version of HashiCorp Nomad on a Linux system
#!/usr/bin/env bash
TARGET_RELEASE="1.5.3"
cd "$(mktemp -d)" || exit
wget https://releases.hashicorp.com/nomad/${TARGET_RELEASE}/nomad_${TARGET_RELEASE}_linux_amd64.zip
unzip nomad_${TARGET_RELEASE}_linux_amd64.zip
@zackproser
zackproser / config.yml
Last active March 16, 2021 15:15
CircleCI Workflows version upgrade
workflows:
# We need to upgrade this version to 2 across all our repos to be able to use the context nodes!
version: 1
build-and-test:
jobs:
- test:
context:
- Gruntwork Admin
filters:
tags:
@zackproser
zackproser / add-or-edit-license.sh
Last active April 12, 2021 23:57
add-or-edit-license.sh
#!/usr/bin/env bash
YEAR=$(date +"%Y")
FULLNAME="Gruntwork, LLC"
function create_license {
cat << EOF > LICENSE.txt
MIT License
Copyright (c) 2016 to $YEAR, $FULLNAME
@zackproser
zackproser / circle-ci-workflows-upgrade.sh
Last active March 15, 2021 22:16
circle-ci-workflows-upgrade.sh
#!/usr/bin/env bash
echo "Upgrading CircleCI workflows syntax to 2..."
yq w -i .circleci/config.yml 'workflows.version' 2
# remove stray merge tags from the final output
sed -i '/!!merge /d' .circleci/config.yml
@zackproser
zackproser / update-all-repo-names.sh
Created March 15, 2021 20:30
update-all-repo-names.sh
#!/usr/bin/env bash
# We renamed a ton of our repos to the Terraform Registry naming format. This script uses grep and sed to search for
# references to the old names and replace them with the new names.
# Bash doesn't have a good way to escape quotes in strings. The official solution is to list multiple strings next
# to each other (https://stackoverflow.com/a/28786747/483528), but that becomes unreadable, especially with regex.
# Therefore, to make our regex more readable, we are declaring clearly-named variables for the special characters we
# want to match, and including those in a string with no need for escaping or crazy concatenation
readonly DOUBLE_QUOTE='"'
readonly SINGLE_QUOTE="'"