#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
#!/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::') |
#!/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 |
#!/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. | |
# |
# 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 |
#!/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 |
#!/bin/bash | |
# cksfv v1.3.14: http://www.iki.fi/shd/foss/cksfv/ | |
cksfv -C /home/lmaly/Downloads/ -qr |
#!/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- {} \; |
#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
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 |
#!/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 |