AWS Summit: GameDay Experience

Today, I participated in a local AWS Summit’s free GameDay event here in Chicago. Going into this, I was not sure what I was getting myself into. The details of the event sounded intriguing; split up and compete to see who can create the best scalable solution.

The event starts by splitting you up into groups of 3-4 individuals. It pairs beginners with advanced AWS users to not only help balance out the room but also teach at the same time. I thought that was a really cool and neat concept; learn from one another. Walking into the room, I voiced a confident “advanced” but leaving it left me hungry for more and full of questions. It was well worth my time and it was loads of fun.

First, the CEO of Unicorn Rentals walks in and gives the most “inspiring” talk that basically can be summed up to: “I told folks on Good Morning America that we are live, good luck, don’t mess up, and make me a lot of money.” Fortunately for us, we were given a comical half-assed “Runbook” of the architecture and how it works; sadly this is probably more documentation than some projects I have worked on in my professional career! From coffee stains to passwords scribbled all over the place, I knew from the get go that this was going to be a fun little ride.

The "Runbook"

First thing we did from logging in was delete all those scratched out accounts, and change the password on the root account! Once we secured the account, we needed to register our team on the scoreboard. This was done by creating a root TXT record in the hosted zone with our team name. It appears the organizers listened for the TXT records and registered teams off that; kinda cool! From here, the fun begins and our application begins taking load.

When we were handed the account, we were told that it is working today, but we need to make it better to handle increased load in ~30 minute increments. First thing we checked was to see how our application was configured. We noticed that the root A record was pointing to an individual EC2 instance with a static IP and not to a ELB/ASG. We corrected this issue by creating an ALIAS record to the ELB for the root record and associated the ELB with the ASG. Next, we were told to create a simple deployment architecture using only User Data and Auto Scaling Groups. We started by copying the existing broken launch configuration, fixed it so it got the new code base and also didn’t have a shutdown command at the end (WHY!!!), and then we proceeded to launch with a scale of 2 instances (hard-coded for now). Keep in mind this was only 30 minutes into the competition.

From here, we faced various issues such as:

  • The “Network Engineer” messed up our ACLs with a bad script
  • The same “Network Engineer” killed our main route table with no default Internet Gateway.
  • You were met with other nefarious and “accidental” issues along the way and it was great to simulate the Oops moments.

Aside from these moments, we began to notice that our subnet for launching instances was limited to only a /28 CIDR block! Load by this point was starting to jump to almost double digits; This just wouldn’t do! We fixed this by creating three subnets (one in each AZ) and associated them with the ELB, and autoscaling groups. With ample space, we can now focus on improving our scaling policy. At first we scaled based on network requests, but later on we determined we should have used the ELB Alarms on latency and scaled off of this. With a solid policy, enough servers to handle traffic, we figured we are good to go! Wrong, so wrong, I can’t believe how wrong we were.

Despite having everything in order, our servers still couldn’t keep up with load! What was going on? There was enough servers, they weren’t crashing, no high load. What could be the problem? We were stuck on this for sometime until we logged into the instance and noticed that the application handled one request with an average latency of about 4 seconds. Playing with the binary, we noticed there was an Elasticache (memcached) option we could leverage. We sprang to the occasion and built up a small distributed memcache cluster and configured our app to use it. Now our average request time was ~.2 seconds! Sweet!

However, despite having fast response times, we were still getting failures. I didn’t make any sense, until we ran the binary and watched it. It appeared that it would only handle one connection at a time, and then reject any other connections as it was handling that one request. This ended up taking the most time, but we couldn’t implement a solution in time. Speaking with some of the Solutions Architects, they mentioned some teams used Docker to run multiple on the same host, and some folks found out that you can run about ~4 binaries concurrently on different ports and handle the load. While the competition winded down, I was implementing a solution that involved running 4 instances of the binary on the same host leveraging IpTables to do round robin; unfortunately, I didn’t get a chance to see it in practice but I was confident this solution would have worked.

Change Management...HAH

All in all, it was a great experience. No my team did not win, but I got to explain and teach others about AWS and some best practices. Towards the end it was really cool to see a team effort as we started tackling harder and harder challenges, and overall I think we all walked away with a little bit more knowledge than we came in. At one point, I had 10 people sitting around me listening to me explain how we do deployments at gogo, our challenges and pitfalls with AWS, and other random topics. Even some of the Solutions Architects came by to sit and discuss, and joked “I needed stadium seating” with the amount of people around me! At that moment it made me realize we do some pretty wicked stuff at work. If anything, this re-energized me to get back and implement some of the things I learned at work!

With all this being said, I really got to thank the AWS Summit GameDay organizers! This is great, and loads of fun. Please keep doing these kinds of events; especially in other cities!

Secret Santa – Python Flask Webapp

Hey all, sorry for the past quiet months. It has been quite hectic with my company moving downtown, changing positions, and ultimately trying to crank out and learn so really cool and exciting technology. As every with every winter, I expect to have a bit more downtime and hopefully I can share some cool things I have been working on in my spare time!

Today, I am excited to share with all of you a fun, but very basic (and I mean verrry basic) web app I wrote while trying to digest an exorbitant amount of Thanksgiving dinner. I was tired after Thanksgiving dinner and want to learn something new as well! Some backstory; every year, my family and I get together for Thanksgiving dinner and we do a yearly “Secret Santa” pool. With this being said, this is usually quite problematic as:

  1. Sometimes people draw their own name, thus making it public who is left in the pool
  2. Someone isn’t able to make it to dinner due to other arrangements so we need to draw the name and just tell them (but that is no fun…)
  3. Someone spills the beans on who they got thus potentially breaking the secret chain of who got who

In comes my idea; how about we do secret santa online this year? It sounded like a great idea, I would whip up a simple app that collect names and email addresses and shoots random emails out using Amazon SES. This would have worked if it wasn’t the fact that not everyone at dinner had an email address (primarily my grandparents). So I had to come up with a solution that solves all the three above existing problems, but also allowed folks without email to sign up as well.

With the goal set, I created a simple flask app that allows people to register their name and a unique passphrase. Once registered, users can check their status to see who they have been matched with. When it has been determined that all people have registered, the admin (me in this case) would go to a randomizer url and scramble all the people’s matches. Until the randomizer piece happens, users are told to check back later or poke the admin with a stick to kick off the match pairing. In my situation, I told everyone to register by noon Friday, I would do a shuffle at that time. Once the randomizer was complete, people can then check their pairing.

So after about 2 hours, I came up with the solution, implemented it, and had people up and running on AWS. It worked surprisingly well and even got a chance to show my younger cousin how it works! Best of of all, I have made the code open for you all to use and implement. I added a lot of “bootstrapping” files such as apache configs, sqlite3 setups, and even a sample WSGI file. Below you will find a list of technologies I used, as well as a number of improvements that could be done.

Hope this helps someone else out there as well! Happy Holidays all!

Technologies Used:

  • Python
  • Flask
  • Sqlite3
  • AWS (for EC2 primarily)

Potential Improvements:

  • Admin Interface
  • Secure Passwords
  • Allow for multiple pools
  • SQLAlchemy
  • Various Flask and Pythonic improvements


March Madness Payout Calculator

So it’s that time of year again, March Madness has come around! This means people spending countless hours researching teams, creating brackets, joining pools, etc. At work every year we start a pool for the scores of each round. Basically, you get assigned a random winning number and losing number. You look at the final box score of a given game, and if they match your assignment you win X amount of dollars based on the round! Simple right?

This year, I found myself busier than normal (basically I have other things to do than watch College Basketball all day) so I decided to write a quick app to determine how much I will win. I am leveraging a unOfficial NCAA API so the data might not be 100% accurate, but it will be good enough for my purposes! 🙂

Feel free to check out the source code below so you can use it too. Note: you might need to tweak payouts, and your magic numbers to your specs!


PyCon Day 4/5: The Synopsis

So…about those daily posts. 🙂 As you know, the blog life can be sometimes hard. I have been too busy learning and meeting some awesome people.

Day 2 (Saturday of Testing and Best Practices)


Great talk about getting Python into schools. Its just there for the taking! Very nice Keynote for the day. It was given by Jessica McKellar, and I even got to meet her! Very nice person, and I got a signed Twisted O’Reilly book! 🙂

Introduction to Docker

I think I am officially in love with Docker. Create images to make containers. These containers are not VMs but essentially spin up and just run. Much faster to run and very compressed. Also you can make containers as images and even use them as deployment mechanisms! Definately something I am going to look into!

So you want to build an API?

It was very flask heavy, was hoping for more generic based talk. It was pretty good none the less.

Getting Started Testing

Yes. Yes. Yes. Test. Test. Test. One of the best talks of the afternoon. Can’t wait to add some test cases for my code. Even covered some mocks testing too!

REST is not enough: Push notifications for Android and iOS

Gave a good overview of what one might do to get started with Android and iOS. Good news. Tons of support in Python! 😀

In Depth PDB

Very solid talk and highly recommended. Stop using the darn print statement already! 🙂

Python Packaging simplified

Good talk about packaging your app for the world.

Its Dangerous to Go Alone: Battling Imposter Syndrome

I will admit. For a while I hit a wall. I burned out. I was experiencing imposter syndrome. There I said it. This was an excellent talk for anyone out there trying to get better and feel good about coding. Don’t listen to anyone else, go and be the best you can be. Stop telling yourself you aren’t good enough. You may not understand something…yet. 😀 Great talk and 100% recommend.


Day 3 (final day):


Guido essentially had a txt file with a list of titles. He basically live coded a simple little script and had his talk on random topics. Quite fun, and kind of laid back….the most important thing:



Time to move to Python 3! Its official! Go out and help y’all! Also become a member of the PSF and join our awesome community!

Deliver your Software in An Envelope

Hitchhikers Guide to Open Source

Very fast paced talk but a feel good talk about committing to open source.

Set your code free: releasing open source code

Very nice presentation that really helped me structure my project. Ran through everything step by step, from License to Testing! 🙂

And that concluded the regular event! Wow that was a quick 7 days! I officially leave later today but just an amazing experience once again. Met a lot of smart and super talented individuals, and got to hang out and have fun with some great people too. I can’t wait til 2015! 🙂

PyCon Day 2

Come one, come all to day 2 of my PyCon experience!

Today was a lot more social, got to finally meet-up with @jeffknupp, writer of Writing Idiomatic Python, and a few other individuals including smortaz from reddit (who is from the Microsoft team and wrote the open source Python Tools for Visual Studio!)

In terms of tutorials and talks, I am going to follow the same format as last night. Today on the agenda? Flask and Intermediate Python!


Topic: Flask by Example

Speaker: Miguel Grinberg

General Overview:

In short, the speaker went over how to create a sample website like his using only flask and its various add-ons. Coming from a django perspective, this is exactly what I needed. I needed a quick browse over how to create forms, db models, routes, etc. The slides take you step by step from hello world to something pretty solid. Talked a lot of best practices and overall was a great talk! Very fast paced with TONS of information!


I want to take this flask knowledge and see if I can improve upon my automation portals that I have created for work. By doing this, I can make faster and more lightweight pages than my existing django setup. I love my django, but I think that at times it can be a tad “overkill.” There are tons of one off scripts I would love to just run from a GUI for end users, and this might help. An avenue for investigation is whether or not I can maintain user session persistence across both implementations (flask and django). I have been tinkering the idea of using redis to maintain a user session that can be referenced in both. Interesting stuff.



Topic: Hands On Intermediate Python

Speaker: Matt Harrison

General Overview:

In a very long, and full of content tutorial, Matt covered tons of material ranging from list comprehension, decorators, generators, you name it! Working through examples, talking about real world scenarios, this talk really clicked for me! Nothing really to share other than finally going to start using generators and decorators a lot more now that I understand them. The generator piece is huge as there are tons of code that I could actually improve on.


Get better at Python! This talk was awesome and broke a few misconceptions and barriers I had. Sometimes I would look at Python repo’s and be lost in the code. After today, I got some great take aways that I am going to look to take advantage. Time to get those generators and yields going! 😀



Talk Schedule for Tomorrow:

  • Breakfast!
  • Opening Keynote
  • Break!
  • Computer Science for self taught programmers
  • So You want to be a full stack dev?
  • Import-ant decisions -or- Python Scraping Showdown
  • Lunch!
  • Ansible -or- Twisted
  • Puppet Modules
  • Getting Started with SaltStack
  • Break!
  • Distributed Computing -or- App Deployment
  • External Talk: Writing Idiomatic Python
  • Lightning Talks!

Hello Montreal! PyCon 2014 underway!

So as many of you know I went to Montreal to attend PyCon 2014! As a up and coming “Pythonista,” this is very exciting. This is the first time I have travelled internationally, and also this is my first “major” conference! Looking to take in as much information as possible in these seven short days. Overall, Montreal is a great city. Everyone thus far is very nice, helpful, and understanding; despite my ability to speak the native tongue French. The weather is similar to that of Chicago, so not much to complain there 🙂

In terms of tutorials, I have attended the following thus far. I will give a title, a general overview, how I might apply it, and general reference links. I believe all the talks are recorded, I will share this as soon as I find out more information.


Topic: mrjob: Snakes on a Hadoop

Speaker: Jim Blomo

General Overview:

Essentially we walked through various examples, talking about MapReduce functions. We talked about how to orchestrate our logs in a manner that provides as much information in a single line vs multiple lines; Makes writing your jobs SO much easier. Essentially, Map and Reduce should be stateless; we are looking at an individual log line at a time, and the framework will merge values back together.


  • map(key1,value) -> list[key2,value2]
  • reduce(key2, list[value2]) -> list[value3]

We didn’t work with a direct Hadoop instance, but rather we worked in a simulated mode, where we had all the data locally. This was smart due to the possible instability of the wifi. (which if I might add has been kick ass! Great job PyCon team!) We worked through simple page visit MapReduce, to more complex multi step MapReduce jobs (get a list of users and their businesses reviewed, and convert it back to a match users together based on Jaccard Similarity). At the end, Jim talked about how to hook it up to a AWS instance of Hadoop and how to properly schedule your jobs. The nice advantage to AWS is that its easily scalable and takes a lot of the heavy lifting of getting Hadoop setup off your plate. Also if you need to spin up extra nodes, its just a nominal fee instead of having to possibly re architecture your own. Probably the biggest talk of the day for me because I am in a position to get more comfortable with Hadoop now. Before it just looked like a big scary elephant 🙂


Now while I don’t have TB of data on my personal machine….there are tons of big data possibilities at work! Looking to see if I can take some of this back to the office, and write some MapReduce jobs on a lot of our data logs. With all this being said, the more efficient your logs are the better results you can get (or at least the easier it is to interpret). So I think this is going to become a bigger project soon. Glad I took this course. Very informative and broke the initial “scary” barrier of big data. BRING IT ON!



Topic: Build your own PiDoorbell!


General Overview:

In short, we took a Raspberry Pi (a small microcomputer) and wired it to a breadboard using the GPIO pins on the board. By doing this, we can have all sorts of fun with the circuits and program some cool things. We setup some sample led’s, but I finally got the Pi to snap this picture! 🙂



So I plan on installing my PiDoorbell on my home’s door whenever someone gets closer than 24 inches away. This will allow me to snap and view a video stream of who is at the door before I get my lazy butt off my third floor apartment. (Remember, developers are supposed to be lazy ;)) The implementation in class only took a phone, and uploaded to Dropbox and set a SMS via Twilio. My plan is to tweak it to use the Google Drive API, and continue to get SMS or at least email alerts to my phone. This way, I can see when packages are delivered, or stolen O_O, even when I am not home. Long term, I want to add some way to interface with the person at the door; LED bar saying “I am on my way.” or “GO AWAY!” 🙂



Anyways that’s all I got for now! Looking forward to tomorrow’s tutorials on Flask and Intermediate Python! As always, learning all the time 🙂

How-To: Fix my Mac VPN DNS resolution

So I assume a lot of people who read my blog are techies (even if you are not feel free to read! This might help you!), but I had a rather odd issue with my Cisco VPN client and my Mac. It appears that I would be able to access my servers via their IPs no problem; why I know my servers by IP is a maddening thing, don’t ask. However, whenever I tried to reach my servers via their hostname, my Mac would just flat out reject it. It would sometimes auto correct itself, but I am in the tech field! I am spoiled by having the world at my fingertips, and want my information now! So after much browsing, I found a solution from my coworker vijay360!

sudo launchctl unload -w /System/Library/LaunchDaemons/

sudo launchctl load -w /System/Library/LaunchDaemons/

Basically, doing the above resets your Mac’s DNS 🙂 In short, for the non-techies out there, DNS is just a fancy way of saying what an IP should resolve to. For example, the internet would be a dark and scary place if was only accessible via: . DNS helps you as a human be able to enter and have the computer (and the internet) translate that for you! The story behind DNS is very simple, yet some facts about it are truly awesome and unbelievable. More on this soon 🙂

Hope this helps someone out there!

Original Source:

Updated: jQuery Loan Calculator

So thanks to all you loyal followers and users, I have updated the code behind my Mortgage Calculator. I have allowed users to either calculate their loan based on months or years. Also I updated the page to 2014 standards.

Want to play with it? Check it out live:

As always, browse the source:

Let me know what you think or report any bugs!

jQuery + web2py Storefront! (now with Stripe.js)

So I have been getting a lot of feedback from people about my storefront page (thanks for that!) and decided to place the code on Github! The code features some enhancements to the live demo below, but I will try to see if I can sync up a demo for you all! I added drag and drop functionality, real-time search, and some simple back end processing as well (ready for server side handling of Stripe payments). Hope this helps some people get started! As always feel free to reach out to me if you have any questions! 🙂

Source Code — Github


Installing cx_Oracle on a Mac

UPDATE: I have updated this article to reflect the state of cx_Oracle and MacOS in 2017!

Spoiler Alert: It is way easier and this guide should be considered outdated!

Installing cx_Oracle on a Mac: 2017 Edition

So as previously mentioned, I got a Macbook Pro. Nearly two months later, I am loving it more and more. The only gripe I had was installing a specific package called cx_Oracle; a Python Oracle DB connection package. After a lot of attempts, I finally got a working copy installed on my local machine. I noticed there are many tutorials around the web, but they are a bit outdated, I am on Mavericks, so I will create a nice article not only for you guys, but also for myself.

Necessary Downloads:

  1. cx_Oracle — Source Code Only Option — (
  2. Oracle Instant Client Basic 64-bit (
  3. Oracle Instant Client SDK 64-bit (

Next Steps:
Assuming you downloaded all the above files, and they are found in your Downloads directory, run the following commands as sudo:

sudo su
mkdir /Users/<username_here>/oracle
mv /Users/<username_here>/Downloads/instantclient-* /Users/<username_here>/oracle
cd /Users/<username_here>/oracle
cd instantclient_11_2/sdk
cd ..
cp -R ./sdk/* .
cp -R ./sdk/include/* .
ln -s libclntsh.dylib.11.1 libclntsh.dylib
ln -s libocci.dylib.11.1 libocci.dylib
vim ~/.bash_profile


Add the following lines (you may want to add these lines to your own accounts .bash_profile too):
export ORACLE_HOME=/Users/<username_here>/oracle/instantclient_11_2


Once you enter all the info, you should resource your bash_profile. After this, you setup instant client as well! I would validate all your settings are correct as well:

. ~/.bash_profile
echo $ORACLE_HOME # should be /Users/username_here/oracle/instantclient_11_2 if you followed this guide
echo $DYLD_LIBRARY_PATH # same as above
echo $LD_LIBRARY_PATH # same as above
which python # usually /usr/bin/python
which gcc # usually /usr/bin/gcc

If all of the above is set, then you are ready to proceed with the cx_Oracle Install!

. ~/.bash_profile
cd /Users/username_here/Downloads
tar -xzf cx_Oracle-5.1.2.tar.gz
cd cx_Oracle-5.1.2
sudo python build
sudo python install

If all went according to plan, it should have successfully installed! (if not post in the comments and I can help!) To test simply:

import cx_Oracle
# you may see some junk like:
/Library/Python/2.7/site-packages/cx_Oracle-5.1.2-py2.7-macosx-10.9-intel.egg/ UserWarning: Module cx_Oracle was already imported from /Library/Python/2.7/site-packages/cx_Oracle-5.1.2-py2.7-macosx-10.9-intel.egg/cx_Oracle.pyc, but /Users/username_here/Downloads/cx_Oracle-5.1.2 is being added to sys.path

Hope this helps someone out there! 😀

Seems like Oracle made a change to the basic zip since this was posted, the step when you are setting up symlinks. If you used my guide previously and you did:

ln -s libclntsh.dylib.11.2 libclntsh.dylib
ln -s libocci.dylib.11.2 libocci.dylib

you should unlink your symlinks and this should be…

ln -s libclntsh.dylib.11.1 libclntsh.dylib
ln -s libocci.dylib.11.1 libocci.dylib
I have updated the article since! 🙂

William Smith, a commenter on the article, said he still ran into an error where Oracle software could not be found. He was able to get past the issue by using “sudo -E” with when installing:

$ sudo -E python install

The “-E” flag on sudo ensures that the local environment variables are preserved with root when the command is run. Thanks! Check out his full comment: