Skip to content

Instantly share code, notes, and snippets.

View ggrandes's full-sized avatar
🛠️
I may be slow to respond.

G.Grandes ggrandes

🛠️
I may be slow to respond.
View GitHub Profile
@ggrandes
ggrandes / prompt.sh
Last active November 26, 2019 19:48
Linux Colored Prompt
#!/bin/bash
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ggrandes
ggrandes / openssl-rsa-signature.sh
Created March 3, 2014 13:37
OpenSSL RSA file Signature / Verify
# Generate RSA Key-Pair
openssl genrsa -out test.key 2048
openssl rsa -pubout -in test.key -out test.pub
# Signature
openssl dgst -sha512 -sign test.key some-file.txt | openssl enc -a -e > some-file.txt.sign
# Verify
openssl enc -a -d < some-file.txt.sign | openssl dgst -sha512 -verify test.pub -signature /dev/stdin some-file.txt
@ggrandes
ggrandes / get-fs-free-space.awk
Last active August 29, 2015 13:56
Get Filesystem Free Space (Linux)
awk -- '$4 ~ /^[0-9]+$/ {print $4}' <(df -kP /tmp)
@ggrandes
ggrandes / system-uid.sh
Created March 4, 2014 19:03
Get Linux System UID
# Works on any machine with 1 ethernet (eth0)
cat /sys/class/net/eth0/address
# Works on { VMWARE, Baremetal, KVM (if setted with -uuid %s) }, Fail on { AWS/XEN }
cat /sys/devices/virtual/dmi/id/product_uuid
dmidecode -s system-uuid
# Works on { VMWARE, Baremetal }, Fail on { AWS/XEN, KVM }
cat /sys/devices/virtual/dmi/id/product_serial
@ggrandes
ggrandes / cert-generator.sh
Last active November 26, 2019 19:48
Generate X.509 Certificate (Server/Client/Mail) with OpenSSL - Linux
#!/bin/bash
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ggrandes
ggrandes / buses.md
Created September 14, 2014 17:28
Storage Bus Speeds
Name Speed (bit/s) Speed (byte/s)
USB 2.0 480Mbit 60MBytes/s
USB 3.0 5Gbit 625MBytes/s
USB 3.1 10Gbit 1250MBytes/s
SATA 1.0/SATA-150 1.5Gbit [a] 150MBytes/s
SATA 2.0/SATA-300 3Gbit [a] 300MBytes/s
SATA 3.0/SATA-600 6Gbit [a] 600MBytes/s
SATA 3.2/SATA-Express 16Gbit 2000MBytes/s
Serial Attached SCSI (SAS) 3Gbit/s [a] 300MBytes/s
@ggrandes
ggrandes / SSLSupport.java
Last active August 29, 2015 14:08
Show supported Java procotols an cipher suites for SSL / TLS
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLParameters;
import java.security.Provider;
import java.security.Security;
public class SSLSupport {
public static void main(String[] args) throws Throwable {
try {
final String bcName = "org.bouncycastle.jce.provider.BouncyCastleProvider";
Security.addProvider((Provider) Class.forName(bcName).newInstance());
@ggrandes
ggrandes / kernel-autoclean.sh
Last active November 24, 2015 10:03
Old Kernel Autoclean (Ubuntu)
#!/bin/bash
# In New Ubuntu Versions:
# apt-get -y autoremove
uname -a
ls -al /boot/vmlinuz-*
sudo aptitude -y purge $(ls -1 /boot/vmlinuz-* | grep -v ".efi." | grep -v -e $(uname -r) | sort | head -n -1 | sed -e 's|/boot/vmlinuz|linux-image|g')
@ggrandes
ggrandes / jenkins-war-download.sh
Last active November 26, 2019 19:47
Jenkins LTS autodownload of latest version
#!/bin/bash
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ggrandes
ggrandes / docluster.sh
Last active November 26, 2019 19:47
Clustered commands (ssh/rsync)
#!/bin/bash
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.