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 / cloudformation-yaml-to-json.py
Created October 26, 2017 09:15 — forked from kesor/cloudformation-yaml-to-json.py
Convert CloudFormation YAML format to JSON format
#!/usr/bin/env python
import sys, yaml, json
def funcparse(loader, node):
node.value = {
yaml.constructor.ScalarNode: loader.construct_scalar,
yaml.constructor.SequenceNode: loader.construct_sequence,
yaml.constructor.MappingNode: loader.construct_mapping,
}[type(node)](node)
node.tag = node.tag.replace(u'!Ref', 'Ref').replace(u'!', u'Fn::')
@luckylittle
luckylittle / converter.py
Created October 26, 2017 09:17 — forked from kj187/converter.py
Converting a CloudFormation Template from JSON to YAML
#!/usr/bin/env python
## Converting a CloudFormation Template from JSON to YAML
## Script copyright: http://blog.flux7.com/how-to-convert-a-cloudformation-template-from-json-to-yaml
##
## Example:
## $ python converter.py --json my-stack.template --yaml my-stack.yaml
import yaml
import json
@luckylittle
luckylittle / delete_default_vpcs.py
Created January 3, 2018 23:56
Delete Default VPCs in AWS account
#!/usr/bin/env python
#
# Python Version: 2.7
# Boto Version 2.38
#
# Remove those pesky default VPCs
#
# Warning: Deleting the default VPC is a permanent action.
# You must contact AWS Support if you want to create a new default VPC.
#
@luckylittle
luckylittle / gist:27b9b36ea7f5c362a925d8f7b649659d
Created January 11, 2018 06:22
AWS CLI CloudFormation inject AMI ID to the Parameters file
# 1. Find the latest ID of the AMI:
NEW_AMI_ID=$(aws ec2 describe-images \
--filters Name=name,Values=*WHATEVER AMI NAME YOU ARE LOOKING FOR* \
--query 'Images[*].[ImageId,CreationDate]' \
--output text | sort -k2 -r | head -n1 | awk {'print $1'})
# 2. Modify a PARAMETERS.vars.json that is being used by AWS CLI in step 3.:
tmp=$(mktemp)
jq -r '[ .[] | select(.ParameterKey=="AmiId").ParameterValue |= '\"$NEW_AMI_ID\"' ]' \
PARAMETERS.vars.json > "$tmp" && mv "$tmp" PARAMETERS.vars.json
@luckylittle
luckylittle / safari2go.sh
Last active April 28, 2018 02:41
Epub extractor for Android application "Safari To Go" data files
#!/bin/bash
bookid=$(find . -maxdepth 1 -regextype sed -regex ".*/[0-9]\+" | tr -d './')
echo "Fix the font's URL of ${bookid}..."
sed -i -e 's#\/getfile#http:\/\/my.safaribooksonline.com\/getfile#g' publisher-style.css
echo "Download the fonts for ${bookid}..."
mkdir -p fonts
mkdir -p css
@luckylittle
luckylittle / check-sfv-incl-subfolders.sh
Created May 4, 2018 23:06
Recursively, quietly check the SFV of all files in all subfolders
#!/bin/bash
# cksfv v1.3.14: http://www.iki.fi/shd/foss/cksfv/
cksfv -C /home/lmaly/Downloads/ -qr
@luckylittle
luckylittle / unrar-incl-subfolders.sh
Created May 4, 2018 23:09
Recursively, UnRar all files
#!/bin/bash
# UNRAR 5.00 freeware https://www.rarlab.com/rar/unrar-5.0-RHEL5x64.tar.gz
find . -name '*.rar' -type f -execdir unrar e -o- {} \;
@luckylittle
luckylittle / Preparing-for-a-Python-Interview.md
Last active September 6, 2022 02:38
Preparing for a Python Interview: 10 Things you should know

#1 KNOW HOW TO WRITE CODE ON A WHITEBOARD/PAPER

#2 KNOW BASIC PYTHON CONTROL FLOW: controlflow.py

a)

for i in range(1,11):
  print i
@luckylittle
luckylittle / insertion_sort.py
Last active May 12, 2018 09:55
Insertion sort algorithm in Python
def insertion_sort(list):
"""
Insertion sort algorithm by @luckylittle
"""
for i in range(1, len(list)):
current = list[i]
while (i > 0) and (list[i-1] > current):
list[i] = list[i - 1]
i -= 1
@luckylittle
luckylittle / centos7-rhel8-initialize.sh
Last active August 10, 2023 06:37
Bash script that downloads the most important apps that i use on my CentOS7/RHEL7/RHEL8 laptop
#!/bin/bash
# This is more of a notes, rather than script...
# CentOS 7 #1805 (@luckylittle)
# Majority of apps that i use on my personal CentOS laptop
# CentOS 7 #1805 based on RHEL 7.5 (ISO & VirtualBox)
# wget http://mirror.slu.cz/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1804.iso
# wget https://cloud.centos.org/centos/7/vagrant/x86_64/images/CentOS-7-x86_64-Vagrant-1804_02.VirtualBox.box