Skip to content

Instantly share code, notes, and snippets.

@pavlov99
pavlov99 / ansible-galaxy-find-role-id.sh
Created March 27, 2017 07:11
Find your role's id in ansible-galaxy
$ ansible-galaxy info YourUser.RoleName | grep -E 'id: [0-9]' | awk {'print $2'}
@gengue
gengue / serializers.py
Last active February 2, 2023 03:50
Django Rest Framework user endpoint with change password
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from rest_framework import serializers
from .models import User
class UserSerializer(serializers.ModelSerializer):
"""
User accounts serializer

Basic opinionated Python code technique guide. For lower level naming and structure, see https://github.com/amontalenti/elements-of-python-style

Don't overuse the batteries

Install deps with pip managed by virtualenv, this decouples the VM from the runtime. Try not to target the latest VM release, this prevents your code from being trivially installable on existing Ubuntu and Centos systems. Use tox and py.test (see below) to confirm that decoupling.

namedtuple

Immutable, named lightweight composite containers for your data. Removes magic numbers from your code.