Skip to content

Instantly share code, notes, and snippets.

@jaystile
jaystile / firefox_markdown_viewing.md
Created July 13, 2023 15:41
Firefox Markdown Viewing

View Markdown in Firefox

I want to see local markdown files in the Firefox browser formatted and displayed. I've discovered that Firefox is a real stickler for not displaying files unless they are of mimetype text/plain. Even if you install a markdown viewer extension, if you try to open a local file it was try and download the file instead.

To solve this, I had to configure the text/markdown mime type locally to be text/plain and then it worked fine.

Procedure

cp /etc/mime.types ~/.mime.types
@jaystile
jaystile / git-notes.md
Last active April 5, 2023 14:57
git-notes
  • git remote update origin --prune : Removes branches that have been removed at the origin
  • git fetch && git log ..origin/master : See the incoming commits
  • git fetch && git log origin/master.. : See the outgoing commits
  • git diff <commithash> : See the changes since the commithash

Alias section (for .gitconfig)

[alias]
  br = branch
 co = checkout
@jaystile
jaystile / rust-notes.md
Last active January 5, 2022 14:10
Rust Notes

Comments

  • //! crate level comment
  • /// doc comment, supports markdown, testable code samples
  • // code comment

Cargo

Docs

  • cargo docs --open
  • cargo clippy
@jaystile
jaystile / bashTips.md
Last active November 18, 2021 17:01
bash tips

Debug!

Print out the all the information with the parameter expansions and replacements

set -x
mycommand "$myArgs"
set +x

Check for a command before using it in a script

@jaystile
jaystile / batchRename.sh
Last active October 21, 2021 01:55
Batch renaming script with bash
#!/bin/bash
# Write results to a tmp file and clean it up on exit
tmpfile=$(mktemp /tmp/batchRename.sh.XXXXXX)
cleanup() {
rm "$tmpfile"
}
trap cleanup 0 1 2 3 6
# Structure the name
@jaystile
jaystile / openssl.md
Last active October 8, 2021 20:17
Openssl Tips

Get all the Subject Alternative Names for a host

When connecting to a server only the name that was requested is returned in the message. This will download the certificate and print all the Subject Alternative Names.

openssl s_client -connect 127.0.0.1:8443 </dev/null 2>/dev/null | openssl x509 -inform pem -text | grep -A1 "Subject Alternative Name"
@jaystile
jaystile / importTruststore.sh
Created August 31, 2021 13:15
Keytool import all certificates from one truststore into another
#!/bin/bash
# Template for importing one truststore into another which transfers all aliases and certs.
src_keystore=./srctruststore.jks
src_store_password='src_store_password'
dest_keystore=./dest_keystore.jks
dest_store_password='dest_store_password'
keytool -importkeystore -v -noprompt \
-srckeystore ${src_keystore} -srcstorepass ${src_store_password} \
-destkeystore ${dest_keystore} -deststorepass ${dest_store_password}
@jaystile
jaystile / kubernetes-tips.md
Last active September 24, 2021 11:48
kubenetes tricks

Copy a Secret from one namespace to another

# https://stackoverflow.com/questions/46297949/sharing-secret-across-namespaces/60627332#60627332
kubectl get secret <secret-name> -n <source-namespace> -o json | jq 'del(.metadata["namespace","creationTimestamp","resourceVersion","selfLink","uid"])' | kubectl apply -n <target-namespace> -f -

List all images in the cluster

kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .spec.containers[*]}{.image}{", "}{end}{end}' |sort
@jaystile
jaystile / findH264.sh
Created April 12, 2021 02:18
Bash Script to find all H.264 files in a folder.
#!/bin/bash
# Check that an executable is available.
function check_prerequisite {
local app=$1
if ! which "$app"; then
echo "$1 not detected. Please, install and then continue"
exit 1
fi