• Stars
    star
    131
  • Rank 275,867 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created over 8 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate consistent easier-to-remember codenames from strings and numbers.

Codenamize

Generate consistent easier-to-remember codenames from strings and numbers.

Overview

Codenamize is a command line tool and Python library that returns consistent names for objects, by joining adjectives and words together. These are easier to remember and write down than pure numbers, and can be used instead or along UUIDs, GUIDs, hashes (MD5, SHA...), network addresses and other difficult to remember strings.

This can be used to replace identifiers or codes when presenting those to users. As words are easier to identify and remember for humans, this module maps Python objects to easy to remember words.

There are also Ruby, and JavaScript ports available.

How to install

1. easy_install codenamize
2. pip install codenamize
3. git clone http://github.com/jjmontesl/codenamize
    a. cd codenamize
    b. run python setup.py
4. wget https://github.com/jjmontesl/codenamize/zipball/master
    a. unzip the downloaded file
    b. cd into codenamize-* directory
    c. run python setup.py

Usage from Python

Import the codenamize function:

>>> from codenamize import codenamize

Consecutive numbers yield differentiable codenames:

>>> codenamize("1")
'familiar-grand'
>>> codenamize("2")
'little-tip'

If you later want to add more adjectives, your existing codenames are retained as suffixes:

>>> codenamize("11:22:33:44:55:66")
'craven-delivery'
>>> codenamize("11:22:33:44:55:66", 2)
'separate-craven-delivery'

Note that integers are internally converted to strings before hashing:

>>> codenamize(1)
'familiar-grand'

Other options (max characters, join character, capitalize):

>>> codenamize(0x123456aa, 2, 3, '', True)
'SadBigFat'
>>> codenamize(0x123456aa, 2, 0, '', True)
'BrawnyEminentBear'
>>> codenamize(0x123456aa, 5, 0, ' ', True)
'Spotty Disagreeable Modern Brawny Eminent Bear'
>>> codenamize(0x123456aa, 4, 0, ' ', False)
'disagreeable modern brawny eminent bear'

Usage as command line tool

After installing, run codenamize --help for help:

usage: codenamize [-h] [-p PREFIX] [-m MAXCHARS] [-j JOIN] [-c] [--space]
                  [--tests] [--version]
                  [strings [strings ...]]

Generate consistent easier-to-remember codenames from strings and numbers.

positional arguments:
  strings               One or more strings to codenamize.

optional arguments:
  -h, --help            show this help message and exit
  -p PREFIX, --prefix PREFIX
                        number of prefixes to use
  -m MAXCHARS, --maxchars MAXCHARS
                        max word characters (0 for no limit)
  -a HASH_ALGO, --hash_algorithm HASH_ALGO
                        the algorithm to use to hash the input value
                        (default: md5)
  -j JOIN, --join JOIN  separator between words (default: -)
  -c, --capitalize      capitalize words
  --space               show codename space for the given arguments
  --tests               show information and samples
  --list_algorithms     List the hash algorithms available
  --version             show program's version number and exit

Examples

For numbers 100000-100009, show codenames with 0-2 adjectives and different options:

OBJ       ADJ0-MAX5    ADJ1-MAX5         ADJ2-MAX5  ADJ-0, ADJ-1, ADJ-2 (capitalized, empty join character)
100001         boat   funny-boat   real-funny-boat  Community, RacialCommunity, PluckyRacialCommunity
100002        award  first-award  tidy-first-award  Repeat, UptightRepeat, HelpfulUptightRepeat
100003         rush   super-rush  equal-super-rush  Intention, ExpensiveIntention, JazzyExpensiveIntention
100004        uncle   calm-uncle   icky-calm-uncle  March, SubduedMarch, AdamantSubduedMarch
100005        salad   warm-salad   true-warm-salad  Plant, QuickestPlant, ReminiscentQuickestPlant
100006         gift   witty-gift    odd-witty-gift  Estimate, CreepyEstimate, SpectacularCreepyEstimate
100007          son     zany-son    gaudy-zany-son  Truck, MiniatureTruck, OptimalMiniatureTruck
100008        angle   damp-angle  dusty-damp-angle  Steak, SpectacularSteak, RightfulSpectacularSteak
100009         link   utter-link   null-utter-link  Bike, ImportantBike, SweetImportantBike

Codename space sizes

In selecting the number of adjectives and max chars to use, consider how many codenames you need to fit the number of objects you'll handle, since the probability of collision increases with the number of different objects used.

0 adj (max 3 chars) = 115 combinations
0 adj (max 4 chars) = 438 combinations
0 adj (max 5 chars) = 742 combinations
0 adj (max 6 chars) = 987 combinations
0 adj (max 7 chars) = 1176 combinations
0 adj (max 0 chars) = 1525 combinations
1 adj (max 3 chars) = 2760 combinations
1 adj (max 4 chars) = 56940 combinations
1 adj (max 5 chars) = 241150 combinations
1 adj (max 6 chars) = 492513 combinations
1 adj (max 7 chars) = 789096 combinations
1 adj (max 0 chars) = 1701900 combinations
2 adj (max 3 chars) = 66240 combinations
2 adj (max 4 chars) = 7402200 combinations
2 adj (max 5 chars) = 78373750 combinations
2 adj (max 6 chars) = 245763987 combinations
2 adj (max 7 chars) = 529483416 combinations
2 adj (max 0 chars) = 1899320400 combinations

An example is shown by running codenamize --tests .

Other versions

  • Concode - Ruby port (thanks to Danny Ben Shitrit)
  • Codenamize JS - JavaScript port (by Steven Barlow)

License

Codenamize is released under MIT license.

For full license see the LICENSE file.

More Repositories

1

cubesviewer

Explore and visualize analytical datasets
JavaScript
439
star
2

cubesviewer-server

CubesViewer server-side app and backend (optional)
Python
50
star
3

ddd

Procedural generation of 2D and 3D geometries and scenes (EXPERIMENTAL CODE!)
Python
44
star
4

home-assistant-config

My home automation configuration for Home Assistant
Makefile
38
star
5

cubetl

CubETL - Framework and tool for data ETL (Extract, Transform and Load) in Python (PERSONAL PROJECT / SELDOM MAINTAINED)
Python
24
star
6

ddd-viewer

Web viewer for 3D scenes generated by DDD, currently for OpenStreetMap 3D scenes only (EXPERIMENTAL CODE)
TypeScript
12
star
7

python-clementine-remote

Python library and command line tool for the Clementine Music Player remote protocol
Python
9
star
8

ddd-viewer-app

DDD Viewer Application (3D OSM maps viewer), using the ddd-viewer library (EXPERIMENTAL / WIP)
Vue
6
star
9

cubesviewer-utils

Cubesviewer tools and integration with Pandas, Django, Jupyter Notebook.
Jupyter Notebook
4
star
10

awesit

Awesit is a tool to manage website backups, deployment and update workflows.
Python
3
star
11

datospublicos

Datos Pรบblicos ETL processes [Archived Repo]
Shell
2
star
12

jgf

Java Game Framework: Java game development framework (Archived Project)
Java
2
star
13

competition-tables

HTML5 library to draw result tables, classification, schedules and rankings for sport and game organizations from CSV data.
JavaScript
1
star
14

talk-cubes-olap-pydaygalicia2017

Slides for the OLAP data analysis and visualization with Cubes and CubesViewer talk
Jupyter Notebook
1
star
15

ddd-docker

Docker container configuration to run ddd, including all OSM/GIS related dependencies
Makefile
1
star