How to create visualization on the fly using a script

Most of the parameters you need to create visualizations and dashboards are stored in the URL state in Kibana 4. After creating a sample vis or dashboard, you should be able to examine the URL and decide what to parameterize.