Skip to content

Latest commit

 

History

History
94 lines (72 loc) · 7.1 KB

developer_notes.md

File metadata and controls

94 lines (72 loc) · 7.1 KB

Developer notes

Welcome, adventurer! Here's a guide to how this code works.

Commands

  • Build / run environment is managed by Pipenv. You might need to install it.
  • Make a haiku on the command line with pipenv run haiku
  • Run the tests on the command line with pipenv run tests
  • There's type checking and pep-8 style checking, with pipenv run typecheck and pipenv run stylecheck.
  • All those commands are defined in the Pipfile.

Package structure

Python code

  • emoji/: For parsing / working with the unicode spec and rendering emojis. It's pretty application-specific, but you might learn a trick or two about how Unicode works from it!
  • haiku.py: For generating emoji haikus.
  • syllables.py: For counting syllables in a string.
  • api/: All the stuff that interacts with web services, e.g. AWS Lambda. You can ignore this if you're just generating Haikus on the command line.
  • tests/: Woah, yes! Tests! They're not super comprehensive, but pipenv run tests will run them.

Other stuff

datasources/ is where a downloaded set of data sources is kept. This is:

  • files from the unicode spec.
    • emoji-unicode-11/ contains a dump of this directory: unicode.org/Public/emoji/11.0/.
      • According to their FTP server, this was last modified 2018-02-07.
      • I downloaded it 2018-11-19.
    • unicode-english.xml is the English language unicode CLDR localization datasource, downloaded from here
      • Note that there's some emoji that aren't in this file - notably, flags and keycaps. They're in this file instead.
    • The CMU pronunciation dictionary, which I modified a little, in order to remove some dodgy pronunciations. Download the original here.

Deploy to AWS lambda?

  • This gets done with serverless! Which I think is a silly name for a framework. Let's see if it works.
  • Set up your credentials from Amazon Web Services (because you can host this on AWS Lambda): serverless config credentials --provider aws --key [key] --secret [secret]
  • You'll probably need to install the plugins using serverless plugin install --name serverless-prune-plugin && serverless plugin install --name serverless-python-requirements (see the severless.yml for plugin names; this all uses npm under the hood)
  • You can deploy it with serverless deploy -v
    • To deploy to production, add --stage production
  • After deploy, check it works with serverless invoke -f haiku -l
    • This is "invoke -function haiku -logs"
    • If something isn't working, serverless.yml is where the config is at.
    • Remove old versions with sls prune -n 0 --stage [dev|production]

Tweeter credentials

If you want to set up tweeting every 6 hours, you need to add twitter configuration variables. These are stored in twitter-config.json, which is in .gitignore, so you probably won't have this file on your machine when you checkout the code. Here's what to do:

  • cp twitter-config.json.template twitter-config.json
  • Create a new app, and get the config values from the Twitter Developer Site
  • Fill them in
  • You should be good to go.
  • (Note to self - if you lose this file - check the emojihaikus account in 1password).

References / resources I used on the way

Here's everything you might need to know about the unicode spec.

TODO / possible enhancements

  • [refactor] Rework the way we distinguish between gendered emojis. Goodness gracious; there's so many if/else statements here. They're not really the same thing, they just implement the same interface.
  • [emoji] We're missing flags and families. I don't know if they're super necessary, but I sorta liked the flags in v1.
  • [language] Maybe Re-gender some of the words, some of the time.
    • I think it adds flavour for the verbs - Maybe add something that randomly changes 'person running' to 'man running' and 'woman running'.
    • I'm pretty keen to keep the professions non-gendered.
    • I'd love to actually use merman / mermaid in addition to merperson 🧜‍♂️ 🧜‍♀️
  • [api] Support supplying a gender or a skin color as an HTTP arg and having that applied consistently to everyone in the haiku.
  • [haikus] Maybe modify the weights so that it favours nature and people, and less symbols. I'd want to go digging more into the philosophy behind Haikus for this, though.

Stuff to talk about in a blog post

  • Stuff that's happened since I wrote the first Emoji Haiku:
    • Multiple versions of the Emoji Spec!
    • Apple changed the pistol to a water gun.
    • People started to become more observant about how weird emoji names sound on twitter, thanks to Kai on Twitter:
      • Apologies to people looking at Emoji Haiku on a screen reader.
      • Note also that people who historically haven't used screen-readers are now affected by this too, e.g. in-car reading of text messages
  • I originally thought that gendering was either SIGN MODE or OBJECT MODE. Turns out OBJECT MODE is really really complicated, and isn't really a mode, but actually an entirely different way of thinking. The official spec treating them very differently should have probably been a hint for this. There's probably something interesting to talk about here, though I haven't distilled what exactly.
  • It's super hard to get these details right: