Saturday, April 23, 2016

Creating a yum repository using AWS S3 buckets

Here's a short bash script I use to create a yum repo in an S3 bucket.  The script does five (5) things:

  1. creates a local repo in a temporary directory
  2. copies an RPM file to the local repo
  3. creates the yum repository using createrepo
  4. syncs the local directory with the S3 bucket
  5. sets public permissions for the bucket (make sure this is what you actually want to do)
Before you get started create the bucket and configure it to host a static website.  No worries if you don't actually have an index.html.

Create the bucket:

$ aws s3 mb s3://openbedrock-repo

Then configure it to host static files:

$ aws s3 website s3://openbedrock-repo --index-document index.html

Here's the bash script to create the repo:

1:  #!/bin/bash  
3:   # $ sudo $0 path-to-rpm [bucket]  
5:   # create a temporary repo  
6:   repo=$(mktemp -d)  
7:   mkdir ${repo}/noarch  
8:   if test -n "$2"; then  
9:    BUCKET="$2"  
10:   else  
11:    BUCKET=openbedrock-repo  
12:   fi  
14:   # create a temporary local repo and sync with AWS S3 repo  
15:   if test -e "$1"; then  
16:     cp "$1" ${repo}/noarch  
17:     createrepo $repo  
18:   # sync local repo with S3 bucket, make it PUBLIC  
19:     PERMISSION="--grants read=uri="  
20:     aws s3 sync --recursive --include="*" ${repo} s3://$BUCKET/ $PERMISSION  
21:     aws s3 ls s3://$BUCKET/  
22:   # cleanup local copy of repo  
23:     rm -rf $repo  
24:   fi  

Tuesday, April 12, 2016

Catching Exceptions in Bedrock

When things go wrong, it's a good idea to actually try to handle the mess.  Most higher level programming languages have exception handling built in.  While Bedrock is not a programming language, it is useful for a templating language to have the ability to catch exceptions.  Today's blog describes how Bedrock's <try/catch> blocks can be use with your Application Plugins.

Sunday, April 26, 2015

5 Reasons to Love Your Chromebook

I'm still adjusting to my gorgeous CB5-571 - Acer 15.6 Chromebook with 1080p Full HD display after using the

Acer C720 for nearly two years.  I love my itty bitty little C720 and it' still fantastic for traveling and throwing on the couch, but wait until you see the 15.6" Acer Chromebook.  Screen is amazing.  Videos and sound are awesome!  It's big, so if you want to lug a big laptop, this one's for you.  I'm holding off on the full review until I've had a full month with the beast, but it really is an amazing piece of technology for the money.  Gushing on my Chromebook made me list the 5 things I love about my Chromebook the most.

Thursday, April 16, 2015

Using Apache's Swiss Army Knife - mod_rewrite for RESTful endpoints (part III)

This is the last blog in my series on Apache's mod_rewrite.  In my previous blogs I've explained a little bit about how you can use this Apache module to redirect URLs both internally and externally.

Using Apache's Swiss Army Knife - Part II

I've provided a few examples and talked about some of the gotchas that I've encountered.  Today we're going to discuss how to use mod_rewrite to provide an API endpoint that is an alias for your web server's name without creating another virtual host.  In most cases, it makes sense to create another virtual host configuration file to implement your application API, however in the event you don't have access to Apache's configuration files, you can use mod_rewrite rules in an .htaccess file to achieve nearly the same operations.

Monday, April 13, 2015

Serving up POD & The five Cs of Good Documentation

I'm a fanatic about documentation.  As a developer that has been involved in creating tools for other developers all my career, I understand the importance of good documentation.  Creating good documentation is not easy, which is why so few people write good documentation.  Here's an easy to remember grading system for your documentation.  Does it meet the five Cs test?

 Is your documentation...

  1. Correct
  2. Complete
  3. Comprehensible
  4. Current
  5. Convenient

I probably don't need to go into too much detail here, but if ain't complete, correct, comprehensible and current it may be worse than no documentation at all.  If it ain't convenient it really doesn't matter how correct, complete, comprehensible or current it is, now does it?  It's not easy meeting all 5 Cs all of the time.  Most likely your documentation will transition through various permutations of those Cs during the software development lifecycle.  So how can we at least make our documentation more convenient and accessible and at least allows us to make an attempt to meet the 5Cs?

Thursday, April 9, 2015

What happened to MySQL TIMESTAMP columns?

Imagine you are using MySQL for some application (not so hard to do) and you're running successfully on version 5.x.  For some reason you are forced to, or decide to upgrade to 5.6.  As always, version upgrades of your software's dependencies should be done with your eyes wide open and your tests ready to run.  As the title of this blog entry suggests, MySQL TIMESTAMP column behavior has changed is some dramatic ways.

Monday, April 6, 2015

Using Apache's Swiss Army Knife - mod_rewrite (part II)

This blog was supposed to introduce some tricks to allow you to create a new subdomain for your RESTful endpoints, but I think before we launch into more details about creating your RESTful API endpoints I should share a few relevant discoveries regarding using mod_rewrite that might be of interest.