Daily Learning Notes for May 31st, 2017

Today I spent most of the day coworking and collaborating with a couple friends from Hack for LA, the Los Angeles chapter of Code for America. They’re all about creating collaborations between technologists and local governments to solve community issues, increase civic engagement, and all that good stuff! I’ve been contributing to an open-source project called Food Oasis LA, a mobile-friendly website for collecting and mapping the best places to find affordable or free healthy food in Los Angeles – everything from farmers markets to food pantries to community gardens.

Today’s highlight: We pushed a new feature to the live site: a form to let anyone suggest new healthy food locations, using GitHub’s API to create pull requests!

Today I Learned

  • Using the <form> element adds some nice features for accessibility, like jumping from one form field to the next by pressing a button on mobile devices!

  • You can listen for the submit event with JavaScript, which fires whenever a form is submitted (as opposed to listening for the “click” event on a button inside the form). Then you can just use event.preventDefault() to stop the page from refreshing (if you’re using an AJAX call instead, for example). Here’s an example CodePen to demonstrate: https://codepen.io/anon/pen/jmgQgm

  • A quick way to check if a JavaScript library has been loaded is simply to do something like if (typeof googlemaps === object), as in this example on StackOverflow – it only works if the library is adding something as a global variable, of course.

  • I finally tried out interactive rebasing in Git to squash commits, which I first learned about earlier this year from Dirk Janssen’s “Git Squash” talk at Pivotal Labs for our Learn Teach Code show-and-tell meetup that I organized for our group’s 2-year anniversary. It all comes full circle! I had fun introducing that technique to my friends and getting a bit lost together – we had to relearn how to edit the commit messages in Vim, and honestly, I might have never had the guts to try it if I was by myself. (Funny how the tiniest things can be intimidating if they involve Vim, haha.) But it worked like a charm!

  • I learned a bit about the MapBox Geocoding API, which we’re using for Food Oasis, and I showed my friend how to test it out with cURL.

Miscellaneous Cool Stuff