Skip to content

Instantly share code, notes, and snippets.

View trishankkarthik's full-sized avatar
🐢
This account is not currently active.

Trishank Karthik Kuppusamy trishankkarthik

🐢
This account is not currently active.
View GitHub Profile
@trishankkarthik
trishankkarthik / admin.py
Last active October 15, 2017 02:58
The “simplest” 12-digit username model for Django 1.11
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import User
# Register your models here.
# https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project
@trishankkarthik
trishankkarthik / models.py
Last active October 15, 2017 02:58
The “simplest” 12-digit username model for Django 1.11
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib.auth.models import AbstractUser
from django.core.validators import MinLengthValidator
from django.db import models
from django.utils.translation import gettext_lazy as _
from .validators import TwelveDigitUsernameValidator
# Create your models here.
@trishankkarthik
trishankkarthik / validators.py
Last active October 15, 2017 02:58
The “simplest” 12-digit username model for Django 1.11
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.core import validators
from django.utils.deconstruct import deconstructible
from django.utils.translation import gettext_lazy as _
# https://github.com/django/django/blob/c1fa6672dd995e5ab4e06d5132db40ed0f41a47e/django/contrib/auth/validators.py
@deconstructible
class TwelveDigitUsernameValidator(validators.RegexValidator):
@trishankkarthik
trishankkarthik / tap4.py
Last active January 27, 2017 00:38
Pseudocode for TAP 4
import fnmatch
import json
import os.path
import tuf.client.updater
import tuf.settings
def get_targetinfo(target_filename):
'''Return the TARGETINFO, if any, for a target with the given filename.'''
with open('map.json', 'rb') as map_file:
@trishankkarthik
trishankkarthik / targets.json
Last active December 23, 2016 20:08
An example of the targets metadata file on the supplier repository (UPTANE)
{
"signatures": [
{
"keyid": "93ec2c3dec7cc08922179320ccd8c346234bf7f21705268b93e990d5273a2a3b",
"method": "ed25519",
"sig": "e9fd40008fba263758a3ff1dc59f93e42a4910a282749af915fbbea1401178e5a012090c228f06db1deb75ad8ddd7e40635ac51d4b04301fce0fd720074e0209"
}
],
"signed": {
"_type": "Targets",
@trishankkarthik
trishankkarthik / targets.json
Last active December 23, 2016 20:08
An example of the targets metadata file on the director repository (UPTANE)
{
"signatures": [
{
"keyid": "93ec2c3dec7cc08922179320ccd8c346234bf7f21705268b93e990d5273a2a3b",
"method": "ed25519",
"sig": "e9fd40008fba263758a3ff1dc59f93e42a4910a282749af915fbbea1401178e5a012090c228f06db1deb75ad8ddd7e40635ac51d4b04301fce0fd720074e0209"
}
],
"signed": {
"_type": "Targets",
@trishankkarthik
trishankkarthik / README.md
Last active December 20, 2015 23:59
A simple Bash script to find out whether pip with TUF fails where pip without TUF does not.

Stress test pip without and with TUF.

Scripts

  • environment.sh: Shared environmental variables.
  • test-pip-without-tuf.sh: Stress test pip without TUF.
    • simple.py: Print all known PyPI packages.
  • test-pip-with-tuf.sh: Stress test pip with TUF.
  • destroy.sh: Delete all logs and virtual environments.