Skip to content

Instantly share code, notes, and snippets.

@discosultan
Last active November 2, 2020 14:47
Show Gist options
  • Save discosultan/6179719410c1f4425d10fac49a071743 to your computer and use it in GitHub Desktop.
Save discosultan/6179719410c1f4425d10fac49a071743 to your computer and use it in GitHub Desktop.
Cheat sheet for common programming tasks
# Delete all evicted pods.
kubectl get po --all-namespaces --field-selector 'status.phase!=Running' -o yaml | kubectl delete -f -
# List all resources in a namespace.
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -n <namespace>
# Trigger cronjob manually.
kubectl create job --from=cronjob/<cronjob-name> <job-name>
# Run busybox.
kubectl run -i --tty busybox --image=busybox --restart=Never -- sh
-- Alter default privileges.
ALTER DEFAULT PRIVILEGES IN SCHEMA schema GRANT SELECT ON TABLES TO role;
-- Alter privileges.
GRANT SELECT ON ALL TABLES IN SCHEMA schema TO role;
-- Create role.
CREATE ROLE role;
ALTER ROLE role WITH PASSWORD 'role';
ALTER ROLE role SET search_path = schema;
-- Create schema.
CREATE SCHEMA schema;
ALTER SCHEMA schema OWNER TO user;
@discosultan
Copy link
Author

To remove trailing whitespace from all fiels using Visual Studio Code:

  1. Use Regex
  2. Enter " +\n" in the Search bar and "\n" in the Replace bar

@discosultan
Copy link
Author

To fix a stuck Terraform Kinesis delivery stream:

  • update underlying CloudFormation stack manually:
    • rename delivery stream with "-2" suffix, for example
    • switch to a new source stream
  • run terraform apply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment