Skip to content

Instantly share code, notes, and snippets.

View desteves's full-sized avatar

diana esteves desteves

View GitHub Profile
sudo rm -f /usr/local/bin/mongosh
hash -r
curl -O https://downloads.mongodb.com/compass/mongodb-mongosh_2.5.9_amd64.deb
sudo dpkg -i mongodb-mongosh_2.5.9_amd64.deb
hash -r
which mongosh
sh .devcontainer/create-library-user.sh
mongosh
@desteves
desteves / jsonSchema_shipwrecks.js
Created December 2, 2024 19:52
Add MongoDB Schema Validation Example
// Define the JSON Schema for feature_type validation
// This schema ensures that the "feature_type" field is required and must be a string
// with one of the specified valid values.
var ruleFeatureType = {
"$jsonSchema": {
"bsonType": "object", // The document must be an object
"required": ["feature_type"], // The document must contain the "feature_type" field
"properties": {
"feature_type": {
"bsonType": "string", // The "feature_type" field must be a string
@desteves
desteves / jsonSchema_combined_test.js
Created December 2, 2024 19:30
MongoDB Schema Validation Combined Rules Test
// MongoDB Schema Validation Combined Rules Test
// Run these commands in the MongoDB Shell
// See https://gist.github.com/desteves/a9332232b7d0d2f7fc359ff0b051065a for ruleFeatureType definition.
// See https://gist.github.com/desteves/49ab39f656f52275432e2ef3977bcb9f for ruleLatdecLondec definition.
var newValidationSchema = {
"$jsonSchema": {
"allOf": [ ruleFeatureType.$jsonSchema, ruleLatdecLondec.$jsonSchema ]
}
@desteves
desteves / jsonSchema_latdec_longdec_type_rule_test.js
Created December 2, 2024 19:27
MongoDB Schema Validation Rule Two (latdec longdec) Tests
// Define the new JSON Schema for latdec and londec validation
var ruleLatdecLondec = {
"$jsonSchema": {
"bsonType": "object", // The document must be an object
"required": ["latdec", "londec"], // The document must contain latdec and londec
"properties": {
"latdec": {
"bsonType": "double",
"minimum": Double(-90),
"maximum": Double(90)
@desteves
desteves / jsonSchema_feature_type_rule_test.js
Created December 2, 2024 19:25
MongoDB Schema Validation Rule One (feature_type) Tests
// Define the JSON Schema for feature_type validation
// This schema ensures that the "feature_type" field is required and must be a string
// with one of the specified valid values.
var ruleFeatureType = {
"$jsonSchema": {
"bsonType": "object", // The document must be an object
"required": ["feature_type"], // The document must contain the "feature_type" field
"properties": {
"feature_type": {
"bsonType": "string", // The "feature_type" field must be a string
@desteves
desteves / cleanup-pulumi-cloud
Created January 17, 2024 19:56
Clean up all stacks in a Pulumi Cloud Org
#!/bin/sh
# REPLACE THESE WITH YOUR VALUES
PULUMI_ACCESS_TOKEN=pul-123
ORG=acme-corp
# Get all stacks
curl \
@desteves
desteves / test.sh
Created December 18, 2023 14:56
Test pulumi golang programs in the pulumi-hugo repo.
#!/bin/sh
# aws sso login --profile work
time=$(date +%s)
echo "Testing all programs -- $time"
for program in $(ls -d */) ; do
echo "Testing ${program}"
cd ${program}
mv go.mod.txt go.mod > /dev/null 2>&1
@desteves
desteves / gh-dl-release
Last active March 12, 2019 21:18 — forked from maxim/gh-dl-release
Download assets from private Github releases
#!/usr/bin/env bash
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#