From 0790e1e6f460ac0788389eae933cb093f3bc9b87 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 20 Jul 2014 23:21:23 -0600 Subject: [PATCH] initial commit --- README.md | 60 +++++++++++++++++++++++ adjectives.txt | 130 +++++++++++++++++++++++++++++++++++++++++++++++++ animals.txt | 102 ++++++++++++++++++++++++++++++++++++++ genids.js | 31 ++++++++++++ tpl.js | 7 +++ 5 files changed, 330 insertions(+) create mode 100644 adjectives.txt create mode 100644 animals.txt create mode 100644 genids.js create mode 100644 tpl.js diff --git a/README.md b/README.md index 9b489c5..92cae04 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,64 @@ +NOT YET PUSHED +==== + +I got tired last night and didn't finish the npm publish script. +Will do in the morning... + human-readable-ids-js ===================== Use JavaScript to generate human-readable ids from a lists of nouns and adjectives. + +Generate ids in the format of `adjective-noun-#` such as + +* silly-goose-37 +* quick-cobra-15 +* tricky-chicken-23 +* brave-ladybug-90 + +My problem is that I often want ids that I can type without having to +look at it twice (nor telling someone else twice). + +I should be able to shout one of these ids across the room to a co-worker +or spouse and have them be able to enter it in without any confusion. + +Currently the id space is aboutt 100 * 100 * 100. +The goal is to have several billion possible combinations. + +Install +======= + +``` +npm install --save human-readable-ids +``` + +``` +bower install --save human-readable-ids +``` + +Contributing +============ + +Please add more words that fit these criteria + + * Easy-to-spell - such that even my redneck dad can manage + * Phonetically distinct - no words like bore/boar + * Few syllables + * Well-known + +All of the words are sorted alphabetically (`sort -u`) and stored in +the `*.txt` files. +The pre-publish script outputs the formatted javascript. + +TODO +==== + +Acheive 1 trillion ids with a combination such as + +`number adjective noun verb adverb` + +And allow choosing various formats based on the desired +number of ids. + + * `adjective noun number` + * `number adjective noun verb` diff --git a/adjectives.txt b/adjectives.txt new file mode 100644 index 0000000..376cdea --- /dev/null +++ b/adjectives.txt @@ -0,0 +1,130 @@ +afraid +ancient +angry +average +bad +big +bitter +black +blue +brave +breezy +bright +calm +chatty +chilly +clever +cold +cowardly +cuddly +curly +curvy +dangerous +dry +dull +empty +evil +fast +fat +fluffy +foolish +fresh +friendly +funny +fuzzy +gentle +giant +good +great +green +grumpy +happy +hard +heavy +helpless +honest +horrible +hot +hungry +itchy +jolly +kind +lazy +light +little +loud +lovely +lucky +massive +mean +mighty +modern +moody +nasty +neat +nervous +new +nice +odd +old +orange +ordinary +perfect +pink +plastic +polite +popular +pretty +proud +purple +quick +quiet +rare +red +rotten +rude +selfish +serious +shaggy +sharp +short +shy +silent +silly +slimy +slippery +smart +smooth +soft +sour +spicy +splendid +spotty +stale +strange +strong +stupid +sweet +swift +tall +tame +tasty +tender +terrible +thin +tidy +tiny +tough +tricky +ugly +unlucky +warm +weak +wet +white +wicked +wise +witty +wonderful +yellow +young diff --git a/animals.txt b/animals.txt new file mode 100644 index 0000000..cdb9b97 --- /dev/null +++ b/animals.txt @@ -0,0 +1,102 @@ +ape +baboon +badger +bat +bear +bird +bobcat +bulldog +bullfrog +cat +catfish +cheetah +chicken +chipmunk +cobra +cougar +cow +crab +deer +dingo +dodo +dog +dolphin +donkey +dragon +dragonfly +duck +eagle +earwig +eel +elephant +emu +falcon +fireant +firefox +fish +fly +fox +frog +gecko +goat +goose +grasshopper +horse +hound +husky +impala +insect +jellyfish +kangaroo +ladybug +liger +lion +lionfish +lizard +mayfly +mole +monkey +moose +moth +mouse +mule +newt +octopus +otter +owl +panda +panther +parrot +penguin +pig +puma +pug +quail +rabbit +rat +rattlesnake +robin +seahorse +sheep +shrimp +skunk +sloth +snail +snake +squid +starfish +stingray +swan +termite +tiger +treefrog +turkey +turtle +vampirebat +walrus +warthog +wasp +wolverine +wombat +yak +zebra diff --git a/genids.js b/genids.js new file mode 100644 index 0000000..f2717f4 --- /dev/null +++ b/genids.js @@ -0,0 +1,31 @@ +'use strict'; + +var fs = require('fs') + , path = require('path') + , shuffle = require('knuth-shuffle').knuthShuffle + , animalsFile = path.join(__dirname, 'animals.txt') + , adjectivesFile = path.join(__dirname, 'adjectives.txt') + , animals + , adjectives + , numbers = [] + , i = 0 + , id + ; + +animals = fs.readFileSync(animalsFile, 'utf8').split('\n'); +adjectives = fs.readFileSync(adjectivesFile, 'utf8').split('\n'); +while (i <= 101) { + numbers.push(i); + i += 1; +} + +for (i = 0; i < 1000; i += 1) { + i += 1; + + id = shuffle(adjectives)[0] + + '-' + shuffle(animals)[0] + + '-' + shuffle(numbers)[0] + ; + + console.log(id); +} diff --git a/tpl.js b/tpl.js new file mode 100644 index 0000000..3027148 --- /dev/null +++ b/tpl.js @@ -0,0 +1,7 @@ +/*jshint -W054 */ +;(function (exports) { + 'use strict'; + + exports.humanReadableIds = exports.humanReadableIds || {}; + exports.humanReadableIds.{{setname}} = {{set}}; +}('undefined' !== typeof exports && exports || new Function('return this')()));