IMDB non-commercial datasets schema

IMDb provides a subset of their data in tab-separated format for personal and non-commercial use. You can find more information, including legal, at IMDb Non-Commercial Datasets. These are some notes on the schema.

Read More →
Card image cap

Create an EC2 key pair with ssh-keygen and deploy with AWS CDK

You can create a key pair that will be used to SSH into EC2 instances with:

ssh-keygen -m PEM -b 4096 -f ~/.ssh/my-key-pair -t rsa

This will create two files in ~/.ssh/, one with the private key named my-key-pair and one with the public key named my-key-pair.pub. Parameters:

  • -m: The key format.
  • -t: The key type. At the time of this writing on 2023-06-13, EC2 supports RSA and ED25519 keys.
  • -b: The key bits.
  • -f: The file name in which the key will be stored. Two files will be generated, one for the private and one for the public key.

You can use the public key to create an EC2 key pair and associate it with your EC2 instances. Here's a minimal CDK code snippet for this:

import { Stack, StackProps } from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import { Construct } from 'constructs';

export class MyStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const cfnKeyPair = new ec2.CfnKeyPair(this, 'MyCfnKeyPair', {
      keyName: 'keyName',
      publicKeyMaterial: [
        'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCtS/sY98Yk6RqJXrWQIqMrRoesRKTI0s6xRUlSPJzx7G8kbWKEH1YS+kE0xFOfdbo/MpXpU',
        'yFf9vTIKS5HEG5ZKhFnLpbh3fBBfFmkFNazJcxpyu4yGQyy8SEhavM8xMl1NCpIhBmg8fccn78FwHVjrwBDaXlLkCkHkQf5AM+Fgx2lEOuSNz',
        '4NmIvDBAEzJi8gixgKlZM5wnyEOHXyUQ04Xs+vS6RHLxmBQ90ncmMga9FhflqfmSC8r/1uMVQYgW+8/pXOGvbMRmdy9zxxnIz6EBcNtAyWhGO',
        'sWB743fdXpCpbIqtiMXImkpjnItU15ar9ij+vkgB5nKBBqFbIvlQ0IKYZ5VJxZMFlpRNZAVyEDedcDWSvc8As5APYau/UgdEv73ingEZpqZR5',
        'VcpKQfP4F3psgHtIO+cyPvKss0Q0vKPMwmpl7z5RRcbKxWGXizsQ+B9kvVs3HzK8gu4qaDW1RbEyWkdIzOkV+ovnhqzbn9o6078hkdIU62wix',
        'k7fI9ugiOEFLoTiiAUo2H/nQ+Z06I+rxrOgF3ucGpBmAm6VaIO0upjysbKL+g05WRj5BKsHp2a2DfMlzp+TcDbpMcy/4YXYwA+BGIilIKeFbR',
        'AkWDT6MP/mLfh0ud4+xZpdymS1Qvq4AzasRVQatVWZpaVWOpGzjF5KJkzhWz4DHAnL5Q== m@e'
      ].join('')
    });
  }
}

References:

Image credit: Kylemore Abbey, by Lode Van de Velde. In the Public Domain. Source.

Card image cap

Migrations, tests and runserver in Django reusable apps

How do you create migration files, run unit tests and preview your Django app in the browser when developing a reusable app that is not nested inside a Django project?

Read More →
Card image cap

Validate that only one of many parameters was provided in Python

Sometimes, a function or class constructor can take many possible parameters, but only one parameter can have a value at any one time, excluding all others. One way to validate this is included in the Python standard library. Copying from the uuid.py module:

class UUID:
    def __init__(self, hex=None, bytes=None, bytes_le=None, fields=None,
                       int=None, version=None,
                       *, is_safe=SafeUUID.unknown):
        if [hex, bytes, bytes_le, fields, int].count(None) != 4:
            raise TypeError('one of the hex, bytes, bytes_le, fields, '
                            'or int arguments must be given')

The idea here is that since all five mutually exclusive parameters hex, bytes, bytes_le, fields and int have a default value of None, when one of them is specified during instatiation, there will then be four parameters left with value None.

Image credit: Wicklow Mountains, by Marcus Tan. In the Public Domain. Source.

Card image cap

Apache host configuration for a Django website

This is the Apache virtual host configuration for an older project that I don't use any more.

Read More →
Card image cap

Mount an NTFS disk in Ubuntu

On a system that dual boots Windows and Ubuntu, I use this line in /etc/fstab to have the NTFS Windows disk mounted permanently in Ubuntu:

/dev/disk/by-uuid/1EBB57A121AFC448 /mnt/1TB auto nosuid,nodev,nofail,x-gvfs-show,uid=marios,gid=marios,permissions,dmask=022,fmask=133 0 0

Here's a list of options used in that line:

  • nosuid: this is a security enhancement, preventing execution of files under the files' owner's permissios, from users other than the owner
  • nodev: this prevents the mounted filesystem from containing device files
  • nofail: prevents error reports when the device is missing, but can mask failures
  • x-gvfs-show: makes the device visible in the user interface, in the file explorer
  • uid=marios and gid=marios: assign user and group ownership of new files to a specific user
  • dmask=022 and fmask=133: default permissions for newly created files and directories

Image credit: Library At Trinity College. In the Public Domain. Source.

Card image cap

My .vimrc

This is my pretty basic ~/.virmc. Lines starting with a double quotation mark are comments:

" Make text pop out on dark backgrounds:
set bg=dark

" Always display line numbers:
set number

" TAB width is 4:
set tabstop=4
" ...and so is an INDENT:
set shiftwidth=4
" Make TAB insert an INDENT at the beginning of a line:
set smarttab
" TAB is 4 SPACES instead of one \t:
set expandtab
set modeline

Image credit: Wild Grazing - Sheep grazing on the southwest coast of Ireland. In the Public Domain. Source.

Card image cap

A small web application with Angular5 and Django

Django works well as the back-end of an application that uses Angular5 in the front-end. In my attempt to learn Angular5 well enough to build a small proof-of-concept application, I couldn't find a simple working example of a combination of the two frameworks, so I created one. I called this the Pizza Maker. It's available on GitHub, and its documentation is in the README.

If you have any feedback for this, please open an issue on GitHub.

Bootstrap

Dashboard Templates

This is a list of free (an in beer) Dashboard or Admin templates build on Bootstrap4. Some are released under well-known open source licenses (mostly MIT), and some have other restrictions, however all are gratis. These links tend to break over time, but often there are mirrors of the themes elsewhere, at least for the open source ones.

Read More →

Angular

Getting Started with Typescript

A series of videos from codingforentrepreneurs.com on getting started with TypeScript.

  1. Welcome
  2. Install Node.js
  3. Configure TypeScript
  4. Classes - Part 1
  5. Classes - Part 2
  6. Getting Started with Typescript - Declaring Variables - let vs var
  7. Getting Started with Typescript - Run & Compile with Webpack
  8. Getting Started with Typescript - TypeScript - Classes - Part 3
  9. PackageJSON - npm init
  10. jQuery, Typings, & npm
  11. Thank you

Try Angular 4

A good series of videos from codingforentrepreneurs.com guiding through the creation of a complete application in Angular 4:

  1. Welcome (2:40)
  2. Getting Started (5:53)
  3. App Module & Component (8:13)
  4. Ng Generate New Component (5:46)
  5. Selectors & Components (2:08)
  6. ngFor and ngIf (7:57)
  7. Mapping Urls with RouterModule (9:17)
  8. Dynamic Routing of Components (7:38)
  9. Safely Embed a Video (8:38)
  10. Pipes & Custom Pipes (9:11)
  11. Rapid Bootstrap 3 Overview (15:14)
  12. Bootstrap for Angular // ngx bootstrap (11:39)
  13. ngx bootstrap carousel (11:56)
  14. Angular Click Events (14:17)
  15. Http Requests (17:02)
  16. Http & Featured (6:22)
  17. Two Way Data Binding (4:22)
  18. ngForm Basics (7:55)
  19. Search Detail (12:09)
  20. Passing Data to Components (12:08)
  21. Video Service (16:47)
  22. Search Video List (8:01)
  23. Video Item Model (7:19)
  24. Router Link & Improved Navigation (4:16)
  25. Improve Styling (11:06)
  26. ngClass (6:49)
  27. ngBuild and Deploy to Heroku (22:16)
  28. Thank You and Next Steps (1:43)

These instructions should get this up and running on Ubuntu:

git clone https://github.com/codingforentrepreneurs/Try-Angular-v4.git
cd Try-Angular-v4
npm install
ng serve

Et Cetera

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