Skip to content

Instantly share code, notes, and snippets.

View david-sanabria's full-sized avatar

David Sanabria david-sanabria

View GitHub Profile
@david-sanabria
david-sanabria / install-jdk12.sh
Last active August 13, 2019 18:04
A simple BASH script to download and install the latest OpenJDK v12 from jdk.java.net.
#!/bin/bash
# install-jdk12.sh
# Written: 2019-08-13
# Author: David.Sanabria@osi.ca.gov
# License: A-GPL
#
# This handy shell script downloads OpenJDK 12.02 from the OpenJDK website
# Inspired by some instructions from https://solarianprogrammer.com/2018/09/28/installing-openjdk-macos/
#
@david-sanabria
david-sanabria / audit-s3-buckets.sh
Last active June 11, 2019 21:51
A simple BASH script that pulls all S3 Buckets out of S3 using the credentials that are configured # for your AWS command line. Requires you to have configured the AWS command line tool (AWS CLI) with your credentials.
#!/bin/bash
#
# audit-s3-buckets.sh
# David Sanabria, @Philozopher, 30-May-2019
# CC-BY-SA
# https://creativecommons.org/licenses/by-sa/4.0
#
# This script pulls all S3 Buckets out of S3 using the credentials that are configured
# for your AWS command line.
#
@david-sanabria
david-sanabria / pg_base62_encode.sql
Last active March 28, 2024 11:08
Base62 Encode/Decode functions for PostgreSQL.
/*
* This script will create base62_encode() and base62_decode() in the current schema of a postgresql database.
* Give it a star if you find it useful.
*/
CREATE OR REPLACE FUNCTION base62_encode( long_number bigint )
RETURNS text
AS $BODY$
/*
* base62_encode()
@david-sanabria
david-sanabria / Useful-MacOS-Commands.sh
Created May 21, 2017 23:35
Some of my favourite MacOS Commands... generally useful stuff for working in the Mac terminal.
#Make all files visible (relaunch Finder to see files)
defaults write com.apple.finder AppleShowAllFiles YES
@david-sanabria
david-sanabria / s3-bucket-test.sh
Last active March 30, 2017 20:20
AWS CLI - Test for S3 Bucket Existence
#!/bin/sh
if [[ $(aws s3api list-buckets --query 'Buckets[?starts_with(Name,`my-bucket`)].[Name]' --output text) = 'my-bucket' ]]; then
echo "You're a genius. Now do something useful";
fi
## Alternate Syntax
if [[ $(aws s3api list-buckets --query 'Buckets[?Name == `my-bucket`].[Name]' --output text) = 'my-bucket' ]]; then
echo "You're a specific genius. Now do something useful";
fi
@david-sanabria
david-sanabria / checkip.sh
Created February 14, 2017 00:20
Check your public IP address from the command line
#!/bin/bash
#
# CheckIP.sh
# Check your public IP address from the command line using Dynamic DNS
# Source: user "lv4tech" post to commandlinefu.com
#
# This script will display just your IP address as it appears from the
# CheckIP service as dyndns.com
#
@david-sanabria
david-sanabria / ssh_config
Last active October 4, 2017 04:13
Example SSH Config Entry for personal accounts
# SSH_CONFIG example
# David Sanabria, 2017-01-24
#
# This is an example of a personal SSH config file. You need to add this
# file to the ssh root directory on your computer, which is typically found in your
# home directory (e.g. ~/.ssh/config). You can learn more from the command line by
# typing "man ssh_config" from your terminal (*nix) or from my blog entry on this topic
# at http://bit.ly/2jX2GQr (Wordpress).
#
# You can safely delete every line in this example gist that starts with the "#" comment
@david-sanabria
david-sanabria / quick-ssh-connect
Created January 12, 2017 02:04
This gist provides a bash command that looks at your ssh configuration file and uses it to give you a list of ssh hosts that you have configured
if [ -f ~/.ssh/config ]; then
#Print simple list
grep ~/.ssh/config -e 'Host ' | awk '{print $2}'
#provide list in Select form to allow quickly connecting to the target
select TGT in $(grep ~/.ssh/config -e 'Host ' | awk '{print $2}');
do
ssh $TGT
done;
else
@david-sanabria
david-sanabria / get-ssid.sh
Created November 29, 2016 20:43
How to: Get Currently Connected SSID from the command line
# get-ssid.sh
# To use these commands, identify the snippet that applies to your OS.
# This script currently does not check the OS version, so if you run this command you will
# get unexpected results.
#
##
## MacOS 10.10+
##