Skip to content

Instantly share code, notes, and snippets.

There doesn't seem to be a gcloud method for querying firestore.
```
ACCESS_TOKEN=$(gcloud auth application-default print-access-token)
```
Make a request to Firestore API: Once you have your access token, you can make a GET request to the Firestore REST API to retrieve a document. The URL for the request should be in the following format:
https://firestore.googleapis.com/v1/projects/{project-id}/databases/(default)/documents/{collection-id}/{document-id}
@jmound
jmound / gist:3163a200033569567e822df8b2949600
Created November 19, 2021 17:27
bash functions that exit on errors
Crafting bash functions that exit on errors:
function name {( set -e
do stuff...
)}
The (...) creates a subshell, and the "set -e" prefix causes an exit on any
nonzero exit codes of the included commands.
https://stackoverflow.com/a/58964551/90442
@jmound
jmound / gist:fb0d776ae1728f2084bc392df31dd7b8
Last active October 17, 2023 15:28
bash style guide- an example where it makes a difference
WITH_NEWLINE="line with newline
"
WITHOUT_NEWLINE="line without newline"
echo $WITH_NEWLINE
echo $WITHOUT_NEWLINE
echo "The above have matching newlines- you would expect that they should not"
echo "${WITH_NEWLINE}"
echo "${WITHOUT_NEWLINE}"
@jmound
jmound / markdown-import.php
Created October 30, 2020 13:35 — forked from vlucas/markdown-import.php
Imports Markdown files in a local directory into a WordPress installation
<?php
// Turn on all error reporting so we can see if anything goes wrong
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
// Relative path to your wp-config.php file (to connect to the database)
require '../wp-config.php';
require './frontmatter.php'; // Parses YAML frontmatter - https://github.com/Modularr/YAML-FrontMatter
require './Parsedown.php'; // Markdown parser - https://github.com/erusev/parsedown
@jmound
jmound / vim open file at end
Created September 24, 2020 16:24
Open a file at the end with vim (useful for large files, like a sql dump)
# https://edunham.net/2015/01/29/vim_open_file_with_cursor_at_the_end.html
vim "+normal G$" file.txt
# or in edit mode:
vim "+normal G$" +startinsert file.txt
@jmound
jmound / fail.md
Created October 4, 2019 17:07 — forked from coryodaniel/debug-containers.md
Connect to a failing kubernetes pod to inspect mounts, etc

Update the command/args:

command: [ "/bin/sh", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]

Run a command

kubectl exec my-pod -c my-container -- ls /
@jmound
jmound / refresh.sh
Last active August 7, 2023 10:33
Bash function to refresh all pods in all deployments by namespace
# based on the "patch deployment" strategy in this comment:
# https://github.com/kubernetes/kubernetes/issues/13488#issuecomment-372532659
# requires jq
# $1 is a valid namespace
function refresh-all-pods() {
echo
DEPLOYMENT_LIST=$(kubectl -n $1 get deployment -o json|jq -r .items[].metadata.name)
echo "Refreshing pods in all Deployments"
for deployment_name in $DEPLOYMENT_LIST ; do
@jmound
jmound / 0_reuse_code.js
Created April 28, 2016 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console