Skip to content

Instantly share code, notes, and snippets.

View lhazlewood's full-sized avatar

Les Hazlewood lhazlewood

  • Las Vegas, California, USA
  • 10:32 (UTC -07:00)
View GitHub Profile
@lhazlewood
lhazlewood / all_jdk_ec_curve_names.groovy
Created October 25, 2021 00:47
List all of a JDKs supported elliptic curve names
for (Provider provider : Security.getProviders()) {
for (def service : provider.getServices()) {
if (service.getType() == 'AlgorithmParameters' && service.getAlgorithm() == 'EC') {
String result = service.getAttribute('SupportedCurves')
String[] split = Strings.delimitedListToStringArray(result, '|')
println "supported curves: "
for(String s : split) {
String[] cleaned = Strings.delimitedListToStringArray(s, ',' ,'[]')
Set<String> names = io.jsonwebtoken.lang.Collections.setOf(cleaned)
println names.join(', ')
@lhazlewood
lhazlewood / get_jdk_vendor
Created November 27, 2019 20:02
Determine the jdk vendor from the command line
java -XshowSettings:properties -version 2>&1 | grep 'java.vendor =' | awk -F'= ' '{print $2}'
@lhazlewood
lhazlewood / gist:24134e708248b8a651ed9dd43df15cad
Created February 6, 2019 01:44
macos sierra on virtualbox addendum
$ NAME="macOSSierra"
$ VBoxManage setextradata "$NAME" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Mac-F22589C8"
$ VBoxManage setextradata "$NAME" "VBoxInternal/Devices/efi/0/Config/DmiSystemSerial" "CK1156I6DB6"
$ VBoxManage modifyvm "$NAME" --paravirtprovider none
# after reboot:
$ VBoxManage modifyvm "$NAME" --paravirtprovider default
@lhazlewood
lhazlewood / jdk_or_jre_installations.sh
Last active November 2, 2018 19:44
Find all existing JDK or JRE installations on RedHat, Centos or Fedora
# Specifically JDK installations (contain 'javac' command) and not JREs:
yum --disablerepo=* whatprovides '*/bin/javac' | grep ilename | awk -F': ' '{print $2}' | sed 's/\/bin\/javac//'
# All JRE installations (those with bin/java but without bin/javac). Includes JREs that are included in JDKs.
for candidate in $(yum --disablerepo=* whatprovides '*/bin/java' | grep ilename | awk -F': ' '{print $2}' | sed 's/\/bin\/java//'); do
if [ ! -x "${candidate}/bin/javac" ]; then
echo "${candidate}"
fi
done
@lhazlewood
lhazlewood / gist:e7d09ca3a847a93dbad79570b4d22baf
Created November 1, 2018 21:45
Print an ansible fact or variable on the command line using the ansible cli and jq
# for example, to print ansible_distribution:
ansible localhost -m setup 2>/dev/null | sed '1 s/^.*$/{/' | jq -r '.ansible_facts.ansible_distribution'
@lhazlewood
lhazlewood / curl_get_status_headers_and_body.sh
Created June 14, 2018 17:55
Using curl on macos to execute a single http request and then get the status code, headers and body
response="$(curl --silent --show-error -i https://google.com)"
status_code="$(echo "$response" | head -1 | awk '{print $2}')"
headers="$(echo "$response" | sed "/^\s*$(printf '\r')*$/q" | sed '/^[[:space:]]*$/d' | tail -n +2)"
body="$(echo "$response" | sed "1,/^\s*$(printf '\r')*$/d")"
#!/bin/bash
echo `ps -A | grep coreaudiod | grep -v grep`
sudo kill `ps -A -o pid,comm | grep coreaudiod | grep -v grep | awk '{ print $1 }'`
sleep 1
echo `ps -A | grep coreaudiod | grep -v grep`
#!/usr/bin/env bash
[[ -z "$JAVA_HOME" ]] && echo "JAVA_HOME must be set" && exit 1
cd $JAVA_HOME/jre/lib/security
curl -LO "http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip" -H 'Cookie: oraclelicense=accept-securebackup-cookie'
# backup existing JVM files that we will replace just in case:
mv local_policy.jar local_policy.jar.orig
mv US_export_policy.jar US_export_policy.jar.orig
unzip jce_policy-8.zip
@lhazlewood
lhazlewood / m2
Created March 24, 2016 21:10
Bash script to switch maven configurations by name
#!/usr/bin/env bash
LINK_FILE="$HOME/.m2/settings.xml"
if [ ! -L "$LINK_FILE" ]; then
echo "This program expects $LINK_FILE to be a symbolic link."
exit 1
fi
if [ -z "$1" ]; then
@lhazlewood
lhazlewood / gist:118af652fee56873d51a
Created September 10, 2014 01:52
Building rdeslonde/Stormpath-SDK-CSharp with mono 3.8.0
xbuild StormPathUserManagement.sln /p:TargetFrameworkProfile="" /p:TargetFrameworkVersion="v4.5" /p:TreatWarningsAsErrors="false"
XBuild Engine Version 12.0
Mono, Version 3.8.0.0
Copyright (C) 2005-2013 Various Mono authors
Build started 9/9/2014 6:49:25 PM.
__________________________________________________
Project "/Users/lhazlewood/projects/lhazlewood/Stormpath-SDK-CSharp/StormPathUserManagement.sln" (default target(s)):
Target ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".