Prez Play Pro Progress

Thus far, if I spend this much time fixing stuff, it’s really frustrating because I’m not learning anything, I’m just trying to figure out what’s broken and why — but it wasn’t my own mistake or lack of knowledge.

This time, however, it is TOTALLY my lack of knowledge so each time I hid a bump, I learn something. Each problem I solve — I learn how and why what I did wasn’t working and how to do it correctly!

A lot of my work super-recently has been learning and using Javascript‘s map, reduce, and filter methods. I was depending on SQL queries (my database being MySQL, if you’re curious … though I was using MariaDB before changing hosting plans) to get the exact results and data visualization I wanted but, for multiple reasons, I’d prefer getting all the results from my database and manipulate the data client-side with Javascript.

Much of what follows is actually from an email I just sent to the American Nazi Party replying to an answer they sent to a question I asked a couple weeks ago. Say what you want about nazis, whenever I’ve asked a question, they’ve sent a polite and meaningful answer. Not all candidates/parties are responsive, let alone courteous. Anyway, I was explaining why I asked my questions and what I was doing.

So, here are my latest screenshots along with what is still in progress, etc.

If only what I consider “right” candidates run — excluding Trump because, of course, he’d win every state, then Gary Johnson wins every state. If we exclude him as well, Darrell Castle (usually Constitution Party) wins all states in which he runs except Arkansas where Jim Hedges wins. The gray states have no conservative/right candidates.

Screen Shot 2018-11-17 at 10.17.24 AM.png

Whatever happened to the Natural Law Party and Reform Party? Maybe the former are all write-in candidates (Darn it! I need to get write-in data!). I know the Reform Party was only on a couple state ballots in the 2012 election — not only that but with two different candidates. I read somewhere at least one state Reform Party nominated a different candidate because, despite how conservative Andre Barnett was (and still is, I assume), they didn’t like that he was (and still is, I suppose) black.

If only “left” or even just socialist candidates run, Jill Stein wins every state except Nevada, South Dakota, and Oklahoma (off the top of my head I think it’s simply because no “left” candidates besides Clinton were on the ballot there). If we only include socialists except Jill Stein, these are the results:

Screen Shot 2018-11-17 at 10.24.07 AM.png

Michael Maturen looks like he wins the most states (I don’t have electoral college votes in the code yet) and there are five tied in second place for number of states. Again, gray means there are either no socialist candidates in those states (except Stein) or, if there are — I need to clean up my data to make sure — there are candidates but none received any votes (which I find difficult to believe).

Once I get these all working, I’ll start adding previous elections and, hopefully, the next one won’t take two years to put together (in my own defense, most of that two years was the learning curve).

Advertisements

PrezPlayPro Progress

I’ve made so much progress since I last revised my schema in Nov 2017. Most of that progress has been in the last week — two weeks at the very most. The Mobile Web Specialist nanodegree program I’m in as a Google Udacity Scholar via a Grow With Google scholarship has made my skillset and confidence go all supernova.

See also: I have a dream come true (2012 results made manually in Photoshop)

Here is what I’m up to:

pppProgress.png
Gray states are those with no socialist candidates (or there were socialist candidates but they received zero votes).

This query fetches only socialist candidates (excluding Hillary Clinton in one state where she’s actually on the ballot as a socialist — she’s not included because then she’d win all the states … until I fix my query by, hopefully, finally completing the affiliations table below) to see who among would “win” among the socialist candidates.

Here’s the new schema … I still haven’t added a stateAbbr column to the affiliations2016 table which, I think, is the reason for a problem I’m having with my first major query.

schema_061918.png

I need some buttons to change what results are fetched and displayed including but not limited to:

  • Results if all the “left-ish” third parties voted for a single candidate — would that candidate have beaten Trump?
  • If all the right-ish votes went to Trump, would he have have won the popular vote?

Mentor to the Masses

Check it out — I answered my first bona fide StackOverflow question!

stackAnswer.png

I’m practically the greatest programmer and teacher in history now.

Pretty much.

Data Journalism Roxor My Soxor

I think I’ve decided on my niche and what RoxorSoxor is to be.

Now going through Doing Journalism with Data: First Steps, Skills and Tools and the Google News Initiative‘s Fundamentals course while waiting to find out if I am among the #GoogleUdacityScholars selected for Phase 2 of the GrowWithGoogle scholarship.

Loving both.

While working on an exercise in lesson 11 of the GWG Challenge course, I learned that the Tampa Bay Times used to be the St. Petersburg Times and they are the ones who started Politifact!

The St. Pete Times bit is important to me because when I was a young teenager, I had the opportunity of getting to know an investigative reporter and ask him over the course of several conversations about what it would take for me to get into journalism. He recommended the St. Pete Times as a great paper to read and work for. It was led for decades by one Mr. Poynter, followed by his son who left all of his ownership stock in the paper to start the Poynter Institute.

They have a history of excellent journalism and they only got better over time. Even as they almost ceased to exist, they racked up a few Pulitzers and, while being a bit slow on the online uptake, they not only did that whole Politifact thing but kinda showed the world was data journalism was.

They really kick ass and … might make me feel like coming to this area is my destiny and not a big, fat mistake.

“Just in cases” – Aurelia from Love, Actually

I don’t want to go against all the advice in books like The Secret and You Are a Badass but I just answered a post in the Grow With Google Udacity Mobile Web Developer forums about what we’ll do if we don’t get selected to continue on with a nanodegree scholarship. Here are my “backup” plans in some sort of order of priority:

  • Google’s Data Journalism course
  • Data Journalism training/resources I found at ProPublica
  • Continue work on personal project using Spotify Web API – adding D3
  • Return to FreeCodeCamp to resume algorithms and start D3
  • Finish a couple other courses I’ve started at Udacity.
  • My wife’s Christmas present to me was 2-3 courses at Udemy so those are waiting.
  • Use all my new knowledge to rebuild-from-scratch an app I made for a client but could make much better now.

Also, continue After Effects courses at Lynda so I can crank up the quality of the videos and other eLearning I do at my day job until I find … let’s just say, “someplace else.” Some sections of the GWG course were pretty inspiring in this way …

sw_01.png

IndexedDB_01.png

They’re probably not that impressive because the screenshots are still images and taken out of context but I believe — unlike a former employer — it’s a no-brainer that appropriate animation adds a tremendous amount of value to any course especially what are otherwise powerpoint-based page-turners.

I just popped into a course at Khan Academy this morning while checking for something and saw this as well.

thisWasAnimated.png

In that case, the combination of animation with video probably didn’t actually add much to knowledge transfer but planted some seeds I’ll water and nurture. I do think there’s value in Over-the-Shoulder (or “all around his head”) graphics to enhance a talking head but, in this case, I think it was more eye-candy to keep peoples’ attention and, yes, there’s value in that too. Mostly, it was cool-looking and aesthetically done well so I wanted to remember it by placing it here.

Promises for Five-Year-Olds

This is a work in progress …

I’m happily going through the Grow with Google Challenge Scholarship: Mobile Web course at Udacity. We use javascript promises throughout which I kinda sorta basically understood the basic concept of. I didn’t completely get it but I knew we’d cover it later and everyone in the forums raved about Udacity’s standalone JavaScript Promises course so I planned on taking that after finishing Mobile Web. I wasn’t worried. I understood the structure just enough to put things together and pass the quizzes (eventually) by basing my answers on examples we were given.

I got the How (they worked structurally) but not the What (they were doing) or the Why (would I use them versus callbacks and/or Event Listeners).

I got to the Promises part of Mobile Web and it still didn’t really make sense to me. So I stepped out and started the JavaScript Promises course. That was great for a few minutes then I was lost again. I can’t tell you how many times in both courses I’d said, “Wait, wait … what?!”

This isn’t a criticism of those courses and sections. My learning style is just incompatible with certain teaching styles. I don’t do well when people say things like, “A promise is a promise that returns a promise—get it?”

No. No sir or ma’am, I don’t.

I posted a question in the forums, “ELI5 How Promises Work” and gave a couple examples of how I thought they worked based on the only thing I really knew about them – they were an ES6 replacement for callbacks … right?

I didn’t wait for answers because I was scared I’d get buried under other terminology and crap that meant nothing to me and would only confuse me more. I grabbed my Google Search box by the throat like Jacob wrestling with God and shouted, “I’m not letting go until you explain promises to me!”

The MDN documentation had me for just a moment or two as well but also lost me.

For the life of me, I couldn’t understand how Promises were related to Callbacks when (I thought) one was replacing the other and it seems to me callbacks were doing all the work anyway. And … eventListeners, right?

The ridiculously awesome Jake Archibald wrote a legendary thingy on Promises that finally started me down the road to understanding. First of all, I realized callbacks aren’t asynchronous … they’re merely blocking, meaning … well, I love Jake’s explanation (which I’ve paraphrased a wee bit):

Sneezing is a blocking function. All current activity must be suspended for the duration of the sneeze. You don’t want to write code that’s sneezy.

That made perfect sense to me. Callbacks aren’t asynchronous … nothing is happening and I’ll do other stuff while it’s happening and when it’s done it will let me know … everything stops while I do this thing and when I’m done doing this thing everything starts up again. Got it.

Jake also said,

“Promises are a bit like eventListeners except … we’re less interested in the exact time something becomes available than reacting to the outcome.”

Okay. That makes sense. Jake also gave a couple examples that, at first, smacked me into “Wait, what?” land again but I took a deep breath and re-read it … and felt I had a loose grasp on it all. I’ve been there before, though, and those cookies of understanding can crumble and fall through your grasp right before your eyes.

Sadly, Jake soon lost me.

As it turns out, Promises are pretty freakin’ easy … until people try explaining them. Eventually, I found two resources that changed all that. The two most valuable things I dug up:

Don’t just read the chosen answers at each. I read through all the comments and answers and replies and they are both a treasure trove.

Even just the titles made me feel much better about my confusion.

Aviv Cohn, the author of Aren’t Promises Just Callbacks? gave this ridiculously short and simple of a callback in his question and all of a sudden I finally understood callbacks so I made some real progress even before reading the replies! Cohn then explains promises in his own words,

“A Promise is an object that represents a value which might not yet exist [emphasis mine]. You can set callbacks on it, which will be invoked when the value is ready to be read.”

That sentence immediately made sweet love to things Jake had said and gave birth to some more understanding on my part. Cohn then gave the promise version of his callback code and concluded by asking,

Is there actually a real difference? The difference seems to be purely syntactical.

The first response started to beat the crap out of me with,

“Yes: callbacks are just [insert crap I couldn’t understand]. Promises are [more crap I didn’t understand] … a composable mechanism to chain operations on values.” [emphasis mine]

Oh. Okay. I don’t know what “composable” means (more on that later) but the rest of the bit in italics made more stuff click into place. Another answer blessed me with,

It is fair to say promises are just syntactic sugar. Everything you can do with promises you can do with callbacks … The deep reason why promises are often better is that they’re more composeable, which roughly means that combining multiple promises “just works,” while combining multiple callbacks often doesn’t.

First of all, thank you for defining “composeable.” Second, this person then goes on to drop a whole bunch of other magical wisdom explaining the difference and how they work and why — in freaking English — including working with values and errors and this:

For the example you gave of a single callback versus a single promise, it’s true there’s no significant difference. It’s when you have a zillion callbacks versus a zillion promises that the promise-based code tends to look much nicer.