Skip to content

Instantly share code, notes, and snippets.

Avatar

David Boucha UtahDave

View GitHub Profile
@UtahDave
UtahDave / postgres-cheatsheet.md
Created Feb 11, 2020 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet
View postgres-cheatsheet.md

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@UtahDave
UtahDave / lxc-exec-all.sh
Created May 15, 2019 — forked from lcherone/lxc-exec-all.sh
LXD run command in all running containers
View lxc-exec-all.sh
#!/bin/bash
#
# Run command in all running containers
# Usage: $ ./lxc-exec-all.sh apt update && apt upgrade
#
for container in $(lxc list volatile.last_state.power=RUNNING -c n --format csv); do
lxc exec "$container" "$@"
done
@UtahDave
UtahDave / rpm-digital-signature.sh
Created Mar 14, 2019 — forked from fernandoaleman/rpm-digital-signature.sh
How to sign your custom RPM package with GPG key
View rpm-digital-signature.sh
# How to sign your custom RPM package with GPG key
# Step: 1
# Generate gpg key pair (public key and private key)
#
# You will be prompted with a series of questions about encryption.
# Simply select the default values presented. You will also be asked
# to create a Real Name, Email Address and Comment (comment optional).
#
# If you get the following response:
View api-call-local-async.sh
#!/bin/bash
curl -sSk http://192.168.11.10:8000 \
-b ./cookies.txt \
-H "Accept: application/json" \
-H "Content-type: application/json" \
-d '[{
"client": "local_async",
"tgt":"overlord",
"fun":"state.sls",
"kwarg": { "mods": "test.s_test-state1" }
@UtahDave
UtahDave / git-serve.md
Created Aug 1, 2017 — forked from datagrok/git-serve.md
How to easily launch a temporary one-off git server from any local repository, to enable a peer-to-peer git workflow.
View git-serve.md

Launch a one-off git server from any local repository.

I [tweeted this already][1] but I thought it could use some expansion:

Enable decentralized git workflow: git config alias.serve "daemon --verbose --export-all --base-path=.git --reuseaddr --strict-paths .git/"

Say you use a git workflow that involves working with a core "official" repository that you pull and push your changes from and into. I'm sure many companies do this, as do many users of git hosting services like Github.

Say that server, or Github, goes down for a bit.

View nginx_init.sls
nginx:
pkg.installed: []
service.running:
- require:
- pkg: nginx
View php-fpm_init.sls
php-fpm:
pkg.installed: []
service.running:
- name:
- require:
- pkg: php-fpm
View CheckIfDockerChecksumWasUpdated.sh
#!/bin/bash
touch /tmp/Recent.xyz
while true
do
echo "Checking again..."
wget -q https://apt.dockerproject.org/repo/dists/ubuntu-xenial/main/binary-amd64/Release -O /tmp/Release.xyz
if test /tmp/Release.xyz -nt Recent.xyz; then
mplayer /usr/share/sounds/ubuntu/stereo/phone-incoming-call.ogg
@UtahDave
UtahDave / jqfilter.sh
Created May 27, 2016 — forked from deybhayden/jqfilter.sh
jq filter a list of objects' values
View jqfilter.sh
aws elasticbeanstalk describe-configuration-settings --application-name foo --environment-name foo-staging | jq '.ConfigurationSettings[0].OptionSettings[] | select(.OptionName=="Notification Topic ARN")'
View haproxy-mine-example.sls
{% for server, addrs in salt['mine.get']('roles:docker', 'network.ip_addrs', expr_form='grain').items() %}
{% if '*web1*' in server %}
server {{ server }} {{ addrs[0] }}:443 check inter 2000 rise 2 fall 5
{% endif %}
{% endfor %}
You can’t perform that action at this time.