WTF Is My Generic Thing?

Mostly an excuse for me to learn JavaScript (and now pjax) TBH. See it in action:

How to use it

You should probably fork it first, then

git clone
cd wtfismygenericthing
bundle exec rake

You'll want to do some customisation or it'll be a bit shit


There are some sample data files in data. The key ones are:


A list of titles, one of which will be randomly chosen. Probably something along the lines of

  - Stop what you're doing and look at this, my blockchain strategy is

Note: EVERYTHING gets upcased when it's rendered, it's just easier that way


A list of skeletons for the robots to randomly select and then populate, with hilarious effect. Maybe

  - to use @animals and @people to mine bitcoins

or similar

Note: those @placeholder words are important, more later


One of these will be randomly picked as the text for the 'Give me another' link.

  - this is shit, try again

you know the sort of thing

Populate the templates

The rest of the data files will be used to randomly populate the templates. I've used the convention of one-file-per-list, but the code does not care TBH - you can mash them all into the same YAML file as long as they're namespaced like this

  - dogs
  - cats

  - Edsger Dijkstra
  - Beyoncé

Repeated placeholders

You can have something like @things and also @things in a template, which will replace each occurrence with a different item from things as long as there are enough items in things to cover the bet. More on How Not To Fuck Things Up below

Recursive templates

It's perfectly cromulent to put @placeholders in these lists, so you can have:

  - @adjective bananas

  - furry
  - straight

or whatever. In theory, this works to arbitrary depth (the tests go 2 levels down, at least) but it will presumably explode in your face if you attempt to take the piss. Speaking of which:


I can think of at least these things that will make it not work:

  • Nesting templates to stupid depths, as mentioned above
  • Using a particular @placeholder more times than there are items in that list - items are removed from the lists as they're subbed into the template. On that note:
  • Using a @placeholder for which you have no items at all - it blew up for me because of a stupid typo

Breaking the tests

Your customisations will have broken the tests, specifically this Cuke (yes, the app generates JSON underneath, all the fun stuff happens client-side). You may not really care, but you won't be able to get Travis to automatically deploy to Heroku with a failing test. The (terrible, but easy) solution is to copy-actual-to-expected (or delete that line) and just move along


There's also a config/config.yml:

title: Wtfismygenericthing

#ga_tag: UA-1974-1

  colour: '#fa8100'

  name: sam

bootswatch: flatly
  • title is for the <title> tag
  • ga_tag is for a Google Analytics tag, if you have one
  • github_corner takes a URL and a hex colour for the Fork me on Github thing
  • homepage is for your homepage and name, to go in the footer
  • bootswatch is an entirely optional identifier for a Bootstrap theme from Bootswatch

Running it

You should be able to run it with

bundle exec rackup

and then point your browser at http://localhost:9292/. And it should deploy straight onto Heroku no bother


As ever, I regret nothing

WTF Is My Generic Thing? on Github