Skip to content

Instantly share code, notes, and snippets.

View wdhowe's full-sized avatar

Bill Howe wdhowe

View GitHub Profile
@wdhowe
wdhowe / update_seqs_to_latest.sql
Created October 24, 2024 13:36
Postgresql: Update all Sequences to Latest
DO $$
DECLARE
i TEXT;
BEGIN
FOR i IN (
SELECT 'SELECT SETVAL('
|| quote_literal(quote_ident(PGT.schemaname) || '.' || quote_ident(S.relname))
|| ', COALESCE(MAX(' ||quote_ident(C.attname)|| '), 1) ) FROM '
|| quote_ident(PGT.schemaname)|| '.'||quote_ident(T.relname)|| ';'
FROM pg_class AS S,
@wdhowe
wdhowe / list_seqs.sql
Created October 24, 2024 13:35
Postgresql: List All Sequences
-- List all sequences and their current values, excluding system schemas
SELECT
n.nspname as schema,
s.relname as sequence_name,
t.relname as table_name,
a.attname as column_name,
pg_sequence_last_value(s.oid) as last_value
FROM pg_class s
JOIN pg_namespace n ON n.oid = s.relnamespace
JOIN pg_depend d ON d.objid = s.oid
@wdhowe
wdhowe / git-pr-cli.md
Created October 24, 2024 13:29
Git: Pull Request CLI

Git: Pull Request CLI

Some github cli example commands to open pull requests.

Remove --dry-run to create.

With a Template

Opens a pull reqest to merge SOURCEBRANCH into DESTBRANCH, using a markdown formatted template for the body.

@wdhowe
wdhowe / git-single-dir-checkout.md
Created October 24, 2024 13:24
Git: Checkout a single directory from a git repo

Git: Checkout a single directory from a git repo

Setup Directory

mkdir myrepo && cd myrepo
git init

Configure Repo

@wdhowe
wdhowe / repo-move.md
Created October 24, 2024 13:20
Git: Move files and history from oldrepo to newrepo

Git: Move files and history from oldrepo to newrepo

Example commands show moving the "data" directory from oldrepo to newrepo and includes all history.

oldrepo (the source)

  • Clone a fresh copy of oldrepo.

git clone [email protected]:USERHERE/oldrepo.git

@wdhowe
wdhowe / .bashrc
Created September 5, 2024 01:34
bash color prompt with git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# color prompt example: "user@host:~/path(git-branch)$"
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\e[91m\]$(parse_git_branch)\[\e[00m\]\$'
@wdhowe
wdhowe / local-clj-docs.md
Last active February 3, 2024 18:22
Analyze Clojure Docs Locally

Analyze Clojure Docs Locally

Analyzing your project via the cljdoc-analyzer locally will ensure that when your project is pushed to clojars, the API docs will have a much better chance of successfully generating.

Install the cljdoc-analyzer.

clojure -Ttools install io.github.cljdoc/cljdoc-analyzer '{:git/tag "RELEASE"}' :as cljdoc
@wdhowe
wdhowe / renew-expired-gpg-key.md
Last active February 3, 2024 20:59
Renew Expired GPG Key

Extend your GPG key expiry

  • Find the ID of the expiring key. Note your key ID.

    gpg --list-secret-keys
  • Start editing the key.

@wdhowe
wdhowe / git-cheatsheet.md
Last active October 24, 2024 13:09
Git Commands Cheat Sheet

Git Commands Cheat Sheet

Configuration

List Current Global Settings

git config --global --list
@wdhowe
wdhowe / cert-check.sh
Created February 2, 2024 18:47
Certificate View from the Shell
#!/bin/bash
url=$1
echo | \
openssl s_client -showcerts -servername ${url} -connect ${url}:443 2>/dev/null | \
openssl x509 -inform pem -noout -text