Skip to content

Instantly share code, notes, and snippets.

@davidwalter0
davidwalter0 / dot.git-commit-msg
Last active June 18, 2017 21:17
Change-id: commit-msg dot.git/commit-msg ; chmod +x .git/commit-msg | gerrit style & others
#!/bin/sh
# From Gerrit Code Review 2.14.1-1490-gf292b12563
#
# Part of Gerrit Code Review (https://www.gerritcodereview.com/)
#
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@davidwalter0
davidwalter0 / dump-cert-info.sh
Last active July 26, 2017 20:16
example certificate info dump with openssl
#!/bin/bash
# https://gist.github.com/davidwalter0/1a96b1afe5794f2a0c8d50e1de3e8aa4
# https://serverfault.com/questions/661978/displaying-a-remote-ssl-certificate-details-using-cli-tools
domain=${1}
if (( $# < 1 )); then
echo usage ${0##*/} domain
exit 1
fi
echo | \
openssl s_client -showcerts -servername ${domain}\
rpm -qa --qf '%{INSTALLTIME} (%{INSTALLTIME:date}): %{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n'
To list all packages, sorted by install date, latest first:
rpm -qa --last
This should work on any RPM based machine:
rpm -qa --qf '%{INSTALLTIME} (%{INSTALLTIME:date}): %{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -n
@davidwalter0
davidwalter0 / stash-pop-recover
Created August 10, 2017 17:42
Undoing accidental git stash pop
# https://stackoverflow.com/questions/6543519/undoing-accidental-git-stash-pop
# https://stackoverflow.com/questions/89332/how-to-recover-a-dropped-stash-in-git
accepted
If you have only just popped it and the terminal is still open, you will still have the hash value printed by git stash pop on screen (thanks, Dolda).
Otherwise, you can find it using this for Linux and Unix:
git fsck --no-reflog | awk '/dangling commit/ {print $3}'
and for Windows:
- name: Ping David to fix config
delegate_to: localhost
shell: |
. ${HOME}/bin/sms.environment
${HOME}/bin/send.$(uname -s|tr [A-Z] [a-z]) "status update from app..."
- name: Pause for config
pause:
seconds: 120
@davidwalter0
davidwalter0 / gist:a4744b453c4975c49e0e835f7d7f8f89
Last active September 21, 2018 17:59
vgo git version run as git vgo-version >> /tmp/vgo.version
[alias]
# create an un-versioned version faux tag string with v0.0.0-date-commit format
# github.com/davidwalter0/hello v0.0.0-20180519105930-66b6dd4eb1dd
vgo-version = "!TOP=$(git rev-parse --show-toplevel); git log -n 1 --abbrev=12 --date=format:'%Y%m%d%H%M%S' --pretty=format:\"${TOP#${GOPATH}/src/} v0.0.0-%cd-%h\";echo"
@davidwalter0
davidwalter0 / vgo-mode.el
Last active August 16, 2019 01:22
emacs: go.mod and go.sum highlighting
;;; package --- mode for go.mod files
;;; Commentary:
;;; font-lock syntax for go.mod files
;;;
(setq vgo-highlights
'(
;;; go.sum
("^\\([^ ]*\\) *[^ ]* h1:*[^ ]*=$" . (1 font-lock-keyword-face))
("^[^ ]* *\\([^ ]*\\) h1:*\\([^ ]*=\\)$" . (1 font-lock-builtin-face))
@davidwalter0
davidwalter0 / wayback.go
Last active November 16, 2018 00:15
x/vgo: thoughts on selection criteria for non-versioned go repo
// https://gist.github.com/davidwalter0/60f41b53732656c5c546cc8b0a739d11
// x/vgo: thoughts on selection criteria for non-versioned go repo
// Run git branch version selection for non-vgo versioned repository
// as if in a wayback machine.
// Use the dependency's commit ctime as the wayback ctime.
// Commits prior to the wayback ctime in sub-dependencies are eligible.
// Use the newest commit prior to the wayback ctime.
@davidwalter0
davidwalter0 / uploader.go
Created February 14, 2019 03:57 — forked from TheGU/uploader.go
Golang to upload file to google drive with progress bar using Google API
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
@davidwalter0
davidwalter0 / jq-query.sh
Last active March 2, 2019 22:25
kubernetes / jq example rule
#!/bin/bash
kubectl get no -o json|jq -r '.items[]|select(.metadata.name == "node1.example.com")|.metadata' | cat -
curl 0.0.0.0:8080/api/v1/nodes|jq -r '.items[]|select(.metadata.name == "node1.example.com")|.metadata' | cat -
kubectl get no -o json|jq -r '.items[]|select(.metadata.name == "node1.example.com")|.metadata.annotations."flannel.alpha.coreos.com/backend-data"' | cat -
curl -s 0.0.0.0:8080/api/v1/nodes|jq -r '.items[]|select(.metadata.name == "node1.example.com")|.metadata.annotations.flannel.alpha.coreos.com/backend-data' | cat -