Skip to content

Instantly share code, notes, and snippets.

View rodtreweek's full-sized avatar

Rod Treweek rodtreweek

  • Portland, OR
View GitHub Profile
@rodtreweek
rodtreweek / postgres_queries_and_commands.sql
Created May 19, 2017 00:17 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@rodtreweek
rodtreweek / postgres-cheatsheet.md
Created May 24, 2017 15:13 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

If run with -E flag, it will describe the underlaying queries of the \ commands (cool for learning!).

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

@rodtreweek
rodtreweek / puppetdb_postgres_hacks.md
Last active July 13, 2017 14:55 — forked from tnolet/puppetdb_postgres_hacks.md
PuppetDB is awesome. Here's some tips on accessing the data in the Postgresql database...most of 'm just reminders for myself.

NB: The following examples were done on Puppet Enterprise 3.0 running on Centos 6. This should be similar for open source versions, except for some file locations.

1. Logging into the PuppetDB PostgresQL database on Linux

The easiest way to snoop around in the actual PuppetDB postgres database is using the command prompt. You have to be the peadmin user though. Couldn't get it working just under root.

[root@master bin]# sudo su - pe-postgres -s /bin/bash
-bash-4.1$ /opt/puppet/bin/psql
psql (9.2.4)

Type "help" for help.

@rodtreweek
rodtreweek / gpg-import-and-export-instructions.md
Created June 5, 2017 06:00 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@rodtreweek
rodtreweek / .curlrc
Created June 20, 2017 20:46 — forked from v1m/.curlrc
sample .curlrc file
#this is a sample .curlrc file
# store the trace in curl_trace.txt file. beware that multiple executions of the curl command will overwrite this file
--trace curl_trace.txt
# store the header info in curl_headers.txt file. beware that multiple executions of the curl command will overwrite this file
--dump-header curl_headers.txt
#change the below referrer URL or comment it out entirely
-e "https://www.google.com"
@rodtreweek
rodtreweek / amq-mapper.rb
Created June 28, 2017 18:41 — forked from Sharpie/amq-mapper.rb
Transform ActiveMQ config files into a connection diagram for Graphviz
#!/usr/bin/env ruby
# Generate a DOT file showing links between ActiveMQ brokers using
# a list of activemq.xml files passed as ARGV.
require 'rexml/document'
require 'erb'
broker_map = Hash.new
@rodtreweek
rodtreweek / wtf.md
Created July 11, 2017 07:34 — forked from othiym23/wtf.md
An experiment. Subject to change.
@rodtreweek
rodtreweek / osx-pdf-from-markdown.markdown
Created July 16, 2017 08:12 — forked from georgiana-gligor/osx-pdf-from-markdown.markdown
Markdown source for the "Create PDF files from Markdown sources in OSX" article

Create PDF files from Markdown sources in OSX

When [Markdown][markdown] appeared more than 10 years ago, it aimed to make it easier to express ideas in an easy-to-write plain text format. It offers a simple syntax that takes the writer focus away from the formatting, thus giving her time to focus on the actual content.

The market abunds of editors to be used for help with markdown. After a few attempts, I settled to Sublime and its browser preview plugin, which work great for me and have a small memory footprint to accomplish that. To pass the results around to other people, less technical, a markdown file and a bunch of images is not the best approach, so converting it to a more robust format like PDF seems like a much better choice.

[Pandoc][pandoc] is the swiss-army knife of converting documents between various formats. While being able to deal with heavy-weight formats like docx and epub, we will need it for the more lightweight markdown. To be able to generate PDF files, we need LaTeX. On OSX, the s

#!/bin/bash
echo "[ build and install vim from source ]"
# Create directories...
sudo mkdir -p ~/fs/dev;
# This script needs "fpm". If you don't have it
# install ruby, etc. with:
sudo apt-get install ruby ruby-dev build-essential;
@rodtreweek
rodtreweek / README.md
Created October 26, 2017 10:44 — forked from seansawyer/README.md
Managing OpenStack instances with Ansible through an SSH bastion host

Managing OpenStack instances with Ansible through an SSH bastion host

I'm be using DreamCompute as my OpenStack provider, but there are dozens to choose from. I assume you already have Ansible and the OpenStack CLI tools installed.

Motivation

With the proliferation of OpenStack public clouds offering free and intro tiers, it's becoming very easy to effectively run a simple application for free or nearly free. Also with the emergence of Ansible, you don't need to learn and deploy complicated tools to do configuration management.