Skip to content

Instantly share code, notes, and snippets.

View luckylittle's full-sized avatar
:octocat:
Working for @RedHatOfficial

Lucian Maly luckylittle

:octocat:
Working for @RedHatOfficial
View GitHub Profile
@luckylittle
luckylittle / rename.sh
Created October 29, 2020 10:38
Safely rename files inside directories with the same name as the parent directory name
#!/bin/bash
# Thu Oct 29 10:34:58 UTC 2020
# Lucian Maly, [email protected]
for pathname in $(ls -d1 */);
do
cd "${pathname}" || exit
for file in *
do
mv -iv "${file}" "$(basename "${pathname}").${file##*.}"
@luckylittle
luckylittle / default
Last active July 29, 2021 01:03
Configuration of PXE Boot & Repository server in VirtualBox for automated install of RHEL 8.2 (VirtualBox <-> laptop)
default menu.c32
prompt 0
timeout 300
ONTIMEOUT local
label 1
menu label ^1) Install RHEL 8 with Local Repo
kernel rhel8/vmlinuz
append initrd=rhel8/initrd.img method=http://192.168.130.2/rhel8 devfs=nomount
@luckylittle
luckylittle / audible_sort_by_price.txt
Last active September 22, 2020 12:27
Audible.com.au all categories sorted by price
# 1 Action-Thrillers-Audiobooks
https://www.audible.com.au/search?node=2683326051&pageSize=50&sort=price-asc-rank&page=1
# 2 Contemporary-Quests-Audiobooks
https://www.audible.com.au/search?node=2683327051&pageSize=50&sort=price-asc-rank&page=1
# 3 Historical-Adventures-Audiobooks
https://www.audible.com.au/search?node=2683328051&pageSize=50&sort=price-asc-rank&page=1
# 4 Military-Action-Audiobooks
https://www.audible.com.au/search?node=2683329051&pageSize=50&sort=price-asc-rank&page=1
# 5 Spy-Stories-Audiobooks
https://www.audible.com.au/search?node=2683330051&pageSize=50&sort=price-asc-rank&page=1
@luckylittle
luckylittle / extract_href.py
Last active September 22, 2020 11:21
Super easy hyperlink extractor for local HTML
#!/bin/python3
from bs4 import BeautifulSoup
import os
file = open("audible.html", "r")
html_doc = file.read()
soup = BeautifulSoup(html_doc, 'html.parser')
@luckylittle
luckylittle / manning.py
Last active September 13, 2020 10:41
Manning Publications - Creates folder structure based on the products in your dashboard
#!/bin/python3
"""
Author: Lucian Maly
"""
import requests
from bs4 import BeautifulSoup
import datetime
import os
@luckylittle
luckylittle / 01-mirror-OCP4-images-to-dir.sh
Last active December 28, 2021 10:30
Mirror OpenShift 4 images from Quay.io to the local Docker registry (for installations in highly secure offline environments)
#!/bin/bash
echo 'First you must get the pull-secret.txt from `https://cloud.redhat.com/openshift/install/pre-release` to the same directory where you run this from'
# Exports - required environment variables:
DEFAULT_OCPVERSION="4.4.3"
DEFAULT_ARCH="x86_64"
LOCAL_REPOSITORY="openshift/ocp${OCP_RELEASE}"
PRODUCT_REPO="openshift-release-dev"
LOCAL_SECRET_JSON="pull-secret.txt"
@luckylittle
luckylittle / randomize_filenames.sh
Created May 30, 2020 00:07
Bash script to randomize filenames (to 6 alphanumeric characters)
#!/bin/bash
for x in $(ls -1); do mv {${x},$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)}; done
# Before:
# ~ ls
# ~ IMG_20200522_225920.jpg IMG_20200522_230114.jpg IMG_20200522_230302.jpg
# After:
# ~ ls
# ~ 14pkJd 4ld2t9 6foTRm
@luckylittle
luckylittle / generate_md5sum.sh
Last active November 28, 2021 07:22
Create MD5 checksum for every MKV file
#!/bin/bash
find . -type f -iname "*.mkv" -execdir sh -c 'md5sum {} > $(basename {} .mkv).md5' \;
@luckylittle
luckylittle / sumologic.yml
Created May 21, 2020 01:16
Red Hat Ansible Tower - passing Sumologic accessID/accessKEY from the Microsoft Azure Key Vault to the playbook example
---
# Tested on Ansible 2.9.4 & Tower 3.6.4
# Passing Sumologic accessID/accessKEY from the Microsoft Azure Key Vault to the playbook example
# Copyright (c) 2020 Lucian Maly, Red Hat
# Configuration in Tower:
# 1) Credentials > prod-ansible-azure-kms:
# a/ VAULT URL (DNS NAME)
# b/ CLIENT ID
@luckylittle
luckylittle / s3_keys.yml
Created May 19, 2020 16:30
Red Hat Ansible aws_s3 module filter example
---
# Tested on Ansible 2.9.4
# aws_s3 module lists all objects, including folders - that is sometimes undesirable
# Copyright (c) 2020 Lucian Maly, Red Hat
- hosts: localhost
gather_facts: false
vars:
s3_keys: