JSON, API. Also, snow.

As I was writing this code, the data turned suddenly from “overcast” to “snow.” I thought to myself, “what am I doing wrong now?” And then I looked out my window, and swore. Repeatedly.

See the Pen Wunder Thunderground by Garrison LeMasters (@Garrison) on CodePen.

Regarding openweather API

Note that upon reading the fine print of the openweather API documentation, it is obvious that the code will fail frequently: 1st, they have a fairly steep limit upon “calls per minute / hour”, and 2nd, they only guarantee 95% availability at any time. So if you’ve been having trouble getting things to work… that’s why.

I’ve signed up for a Weather Underground API — although they haven’t sent it to me yet. I encourage you to do the same: It is free, and it seems more robust.

Visit: https://www.wunderground.com/weather/api

OOPs in JS

Here is a short three-part tutorial on how I can make and use Classes and Objects via JavaScript and P5JS.  

Note that I’m experimenting again with JSFiddle, because if I can make it work here we can use it for collaborative coding experiments, and that would be a good thing.  So if three sketches don’t appear below this text, please let me know.

To see the JS run, choose “RESULT” (look for the menu bar that includes JavaScript, HTML, CSS, and RESULT).

Part One

Part Two

Part Three

The Interns Are Running Things, Now

Is it me, or does this graphic suggest that the graphics and data departments at Quartz.com are spending way too much time at lunch?  C’mon, guys!  Bonus question:  What is the logic behind the ordering of the rows and columns on this graphic?  Is Carson to the right of Kasich because of poll results (probably not); alphabetical order (nope); projected total votes (huh-uh).  Because of the random decision of some graphics intern?  Probably, yes.

superTuesday

And what about the order in which the states are presented?  Are they arranged according to when their polls close?  Or does the list reflect the order in which the editorial assistant remembered the states that were participating?  If the former, then could you at least make note of this?  (Go ahead and use Ben Carson’s column — he won’t be needing it).  If you’re going to rearrange things on the Y-axis in order to group participants according to availability of information (the top states are reporting in; we’re still waiting to hear from Vermont and Arkansas, for example), then why leave an empty-handed Marco Rubio between Trump and Ted Cruz?  Shouldn’t we consolidate with an even-handed approach?

Video, demos, and more from 25 Feb

A number of things to share from Thursday’s class (25 February 2016).

The video on FTP-ing is at the end of the post.

Sentiment analysis.  The files we made use of in class for our natural language processing / sentiment analysis experiment are available from Bing Liu’s site.  You can open the .txt files in your browser and then choose “File > Save as… >”.  Make sure you do not save it as a webarchive:  It needs to be saved as raw text.

These opinion lexicons originally appeared in the following:

Minqing Hu and Bing Liu. "Mining and Summarizing Customer Reviews." Proceedings of the ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD-2004), Aug 22-25, 2004, Seattle, WA.

Remember that this is a novel form of scholarship, and the authors deserve credit for their labor:  It is imperative that you leave the file intact, including the header information, if you post a program that makes use of it.

Here’s a version of the simple natural language processing approach we took, making use of arrays.  Be sure to look at the javascript code itself.

Finally, for your amusement, here are two other recent experiments in javascript:  The Romeo + Juliet visualization, and the (unfinished) Solar System Construction Set.