Create S3 Bucket with Boto3

How to use Boto3 to create S3 buckets.

Read More →

Create S3 Bucket with the AWS CLI

The simplest form of using the AWS CLI to create an S3 bucket is:

aws s3 mb s3://bucket-name

You can optionally specify the region:

aws s3 mb s3://bucket-name --region eu-west-1

If you don't specify the region, the default is us-east-1 (N. Virginia).

IAM

To be able to create buckets, you need an IAM role that has at least the following policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowCreateS3Bucket",
            "Effect": "Allow",
            "Action": [
                "s3:CreateBucket"
            ],
            "Resource": [
                "arn:aws:s3:::*"
            ]
        }
    ]
}
Card image cap

Back-end Validation for Django Model Field Choices

In Django, you can provide a list of values that a field can have when creating a model. This post shows a way to validate the values passed which creating a new instance or saving an existing one.

Read More →

Single-App Django Project Anatomy

With all the magic that comes packaged within Django, it's easy to forget that the code of a Django project is as malleable as any other Python project's code. This post shows how to simplify the structure of a Django project, when you will only ever have a single app.

Read More →

AWS

Non-Certification Training

The AWS Category of CBT Nuggets has both certification and non-certification training material.

Certifications

Useful stuff:

AWS Certified Solutions Architect - Associate

Tests your technical expertise in designing and deploying scalable, highly available, and fault tolerant systems on AWS. Meant for anyone with experience designing distributed applications and systems on the AWS platform.

Useful stuff:

Training material:

AWS Certified Solutions Architect - Professional

Tests your advanced technical skills and experience in designing distributed applications and systems on the AWS platform. Meant for an AWS Certified Solutions Architect - Associate with two or more years hands-on experience designing and deploying cloud architecture on AWS.

Useful:

AWS Certified Developer - Associate

Tests your technical expertise in developing and maintaining applications on the AWS platform. Meant for anyone with one or more years of hands-on experience designing and maintaining an AWS-based application plus in-depth knowledge of at least one high-level programming language.

AWS Certified SysOps Administrator - Associate

Tests your technical expertise in deployment, management, and operations on the AWS platform. Meant for anyone with one or more years of hands-on experience operating AWS-based applications.

AWS Certified DevOps Engineer - Professional

Tests your technical expertise in provisioning, operating, and managing distributed application systems on the AWS platform. Meant for achieved AWS Certified Developer - Associate or AWS Certified SysOps Administrator - Associate. Two or more years’ experience provisioning, operating, and managing AWS environments.

Useful stuff:

AWS Certified Advanced Networking - Specialty

Tests advanced technical skills and experience in designing and implementing AWS and hybrid IT architectures at scale. This exam is intended for individuals who perform complex networking tasks.

AWS Certified Security - Specialty

Tests ability in the area of security as it pertains to design, implementation, and troubleshooting. The exam is intended for individuals who perform a Security Specialist role.

Useful stuff:

AWS Certified Big Data - Specialty

Tests technical skills and experience in designing and implementing AWS services to derive value from data. The exam is for individuals who perform complex Big Data analyses.

Ad Hoc Data Analysis From The Unix Command Line

I am mirroring the book Ad Hoc Data Analysis From The Unix Command Line from Wikibooks, at Books / Ad Hoc Data Analysis From The Unix Command Line.

Control VLC with Python

VLC is an amazing media player, or rather a media-related Swiss army knife. It has a surprising number of different control interfaces, some of which allow access over a network, such as the HTTP, Telnet and RC interfaces. It also has a Python API but just looking at the documentation is terrifying...

Read More →

Mutagen ID3 Python Library

Mutagen is a Python module to handle audio metadata.

UFID: Unique File Identifier

The unique file identifier is a reference to an external database that may contain more information about the work tagged with it. Like many ID3 tags, it can have multiple values. For example, you can link the song "Black Sabbath" by "Black Sabbath" as mt0030286828 in AllMusic, and as 153a3596-af03-36ed-976a-83fec8745732 in MusicBrainz.

Note that according to the definition of the UFID ID3 frame, the URLs should not be queries themselves. I guess that it might be a feature of the software that reads this tag to transform it to direct links. In the example used, those links would be: http://www.allmusic.com/song/black-sabbath-mt0030286828 and https://musicbrainz.org/work/153a3596-af03-36ed-976a-83fec8745732.

Let's see how to write UFID and read it back in Python, with Mutagen.

{% highlight python %}

from mutagen import id3 song = id3.ID3('test.mp3')

Note that there is no UFID tag in the beginning:

song.keys() dict_keys(['TPE1', 'TALB', 'APIC:', 'TDRC', 'TRCK', 'TPE2', 'TPOS', 'TIT2'])

Let's add two references:

amurl = 'http://www.allmusic.com/' amref = 'mt0030286828' mburl = 'https://musicbrainz.org/' mbref = '153a3596-af03-36ed-976a-83fec8745732' song.add(id3.UFID(owner=amurl, data=amref.encode())) song.add(id3.UFID(owner=mburl, data=mbref.encode()))

There are now two UFIDs:

song.keys() dict_keys(['UFID:https://musicbrainz.org/', 'TRCK', 'TPE1', 'UFID:http://www.allmusic.com/', 'TPE2', 'TALB', 'TIT2', 'APIC:', 'TPOS', 'TDRC'])

Read them back:

song['UFID:https://musicbrainz.org/'] UFID(owner='https://musicbrainz.org/', data=b'153a3596-af03-36ed-976a-83fec8745732') song['UFID:https://musicbrainz.org/'].owner 'https://musicbrainz.org/' song['UFID:https://musicbrainz.org/'].data b'153a3596-af03-36ed-976a-83fec8745732' song['UFID:https://musicbrainz.org/'].data.decode() '153a3596-af03-36ed-976a-83fec8745732' {% endhighlight %}

Note the use of encode() and decode() methods of unicode used for the data part of the frame, as it expects its contents to be bytes.

Hexadecimal Primary Key in Django Model

The following snippet of code will make the primary key in a Django model to be a hexadecimal string of 8 characters instead of an integer.

Read More →
About

Hello, I'm Marios Zindilis and this is my website. Opinions are my own. You also find me on LinkedIn and GitHub.

Unless otherwise specified, content is licensed under CC0.

Search