Python Basic Math
Updated below (Feb 13th 2016)
Originally Written on June 24th 2015
I had been interviewing lately... (its more official now which is why I'm writing about it) I did a bunch of interviews, some wanting to test my python prowess, and well they stumped me. On basic math with python... yeah I was extremely frustrated by the experience as I've been doing python for years... never had many on the spot, do some basic math now kind of moments. None the less, it irritated me. So, I went home and revisited the question. Not 5 minutes later I had the answer,
but it bugged me the whole drive home. Which is something I do a lot, something bugs me regardless of how small and meaningless (like needing to do basic math in python), I'm posting here for posterity. Question is not word for word what I got, because I didn't copy it, but heres the basics of it:
Write a script that will check numbers 1 through 100, to see if they are divisible by 4, if they are print "word". If they are divisible by 6, print "anotherword", if they are divisible by both, print "both". Otherwise print the number.
for x in range(1,101):
is4 = False
is6 = False
print str(x) + "/4 = " + str(float(x/4.0))
is4 = True
print str(x) + "/6 = " + str(float(x/6.0 ...
Continue reading »
Part 2 of CoreOS on AWS with Ansible, part 1 discussed the CoreOS Cluster Setup. As I was writing this, it did dawn on me that the order I'm writing these in, is probably backwards. You would need the Security Group setup before the cluster could come up. Sorry, but on we go.
AWS Security Groups, are "kinda" like firewalls. Except they do not exist on the typical network boundary, they exist within the virtual layers of the network bridges between the host OS and the Virtual Machines running on it. Its what allows EC2 instances that reside on multiple networks and separate Availability Zones to exist within the same Security Group, and thus the same access privileges. Overall, it does make Security on AWS simpler to manage. Then VPC's came along with the ability to put firewall ACL's on your private subnets in addition to them, and things can get pretty harry, quickly, but maybe another time.
I will again be running everything in one file, and not with a separate rules directory as is typical of Ansible play books, for simplicity. The first part is pretty typical of an Ansible EC2 play.
- name: Configure Security Groups for AWS Infrastructure
my_ip: 10.1.1.1/32 # My Home Public IP
I'm using a few variables here, basically the name of the security group, region and the VPC id. I also have a variable ...
Continue reading »