Skip to content

Instantly share code, notes, and snippets.

@Colum
Colum / gist:90fa9c91b417bdfabc9c04e81a6a0f1a
Created January 22, 2024 19:10
Delete documents with duplicate keys keeping 1
# Finds documents from the "users" collection which have duplicate values for
# key "kazoo_id", and deletes as many as needed to keep only 1 document.
from pymongo.mongo_client import MongoClient
from pymongo.server_api import ServerApi
uri = "..."
client = MongoClient(uri, server_api=ServerApi('1'))
deleted = 0
@Colum
Colum / kubeswitch
Last active June 23, 2021 21:51
Quickly change kubectl and gcloud projects
#!/bin/bash
#
# Easily switch your gcloud and kubectl CLIs to a different project.
#
# Usage:
# kubeswitch --project kashoo-stage
# --project
# accepted values: tsb-stage, tsb-prod, kashoo-stage, kashoo-prod
#
# For OSX, place contents in /usr/local/bin/kubeswitch