Monthly Archives: April 2017

Spring 2017 – Week 12 Class Notes

We are getting towards the end – keep up the good work!

Programming

This week we worked with Google Maps API to put a marker on a map, and do things when the marker is clicked on. We learned a bit about API keys, and that certain APIs require generating a key to verify who is using their system. We talked about JavaScript vs. web (XMLHttpRequest) APIs. We also discussed the “defer” keyword in a script tag for running a script after the HTML page is processed by the browser. The getting started guide for Google Maps is here. It is very similar to the program that we did in class, but it is all in one file.

Also check out their tutorial on Adding a Marker to a map.

The Google API key we used for class is
AIzaSyC7GVgqtLehWpNQ6-0ryq3BsDjHu3d8DSI
and if you missed class or used one of our computers, you can retype the code we finished with by looking at the images below:

Note that if you type this in and you get the error “Oops something went wrong” instead of your map, that means you typed in the API key wrong when loading that Google Maps Javascript.

Homework:

  1. Add another marker to the map. Additionally, you should try to put the data in an array, and read the data in a loop.
  2. Keep working on your carts! I have seen many of you making good headway. Bring your current versions to class and we will keep working on them, or send me an email!

Electronics

This week we covered a little bit more about frequency response for capacitors and inductors, the basics of reactance and impedance, and what a resonant frequency is. We also started talking about transistors. My goal is to have the transistor chapter done for you by Saturday. There is a transistor chapter in the book right now, but it is incomplete and probably not very readable. I will update here when the new version is in. Homework will be for the transistor chapter.

Calculus

There was no calculus this week. I will try to get your chapter done shortly.

Spring 2017 – Week 11 Class Notes

Sorry I did not get this out in a timely manner. However, there is not much to talk about.

Programming

Be working on your shopping cart this week. Almost out of class days!

Electronics

This week do the next chapter – “Inductors and Capacitors in Circuits” and do the problems.

Calculus

There is no class this week so I will post the assignment in the next class notes.

Spring 2017 – Week 10 Class Notes

Great week everyone! We only have five classes left!

Programming

First of all, if anyone needs to send a program via email, this is sometimes more difficult than it should be. Email programs tend to be wary of people attaching programs to emails. Therefore, to send one, you need to (a) rename the file so it doesn’t end in .js or .html. Just rename the file to .txt. Then (b) compress the file into a zip file (this can usually be done by right-clicking on the file).

Now to this week. For those who missed it, this week we practiced using the programmable web – using URLs to fetch JSON files, parse them, and use their data in our own programs. Below are the two files we typed in:

What this code does is go to the EventElf website, get a JSON feed of an event, and pull down some of the information into a web page. The things we used are:

  • XMLHttpRequest – this object allows us to make connections to other websites for data.  We have to use new to get a new copy of this object.  The onload property should be set to a callback that will trigger when the data is finished loading, and then the actual data itself will be in the responseText property.  The open function tells the method (usually “GET” sometimes “POST”) and the URL to obtain.  Then, the send function actually makes the call.
  • JSON.parse – the data retrieved from XMLHttpRequest is just a string.  JSON.parse will take the string and, if it is a JSON object, parse it into a JavaScript object.

From there, we just use document.getElementById like we normally do.

There are a huge number of things on the web accessible by JSON feeds in this way.  When you find one, you read the documentation, and it will tell you how to construct URLs to access their data, and what the data looks like.  This is known as the API.  Unfortuantely, a lot of APIs require you to perform tasks to authenticate yourself and your program, which adds a lot of complexity to the task, especially for new programmers.

We did not talk much about our web store system, but will get more into that next week.

HOMEWORK FOR THIS WEEK:

  1. Work on your cart program
  2. Modify the program we typed in this week to display even more data about the event (the pieces of data you want to display are your choice).  The easiest way to see what data is available is to either log the parsed javascript object to your console, or just go to the feed URL in your browser to see what it is giving you.
  3. Alternatively, you can find another API to interface with.  I have been trouble finding an API that is all of (a) easy to use, (b) works with your browser’s security, and (c) does not have any inappropriate content.  That is proving difficult 🙂  I will update this if I find one.  I found several joke APIs, but they often have both regular and inappropriate jokes.  I found a “cat facts” API, but it doesn’t work with your browser’s security.  Anyway, if you find one you want to use, feel free to do so!

Electronics

This week we went into further depth on inductors.  If you have not read chapter 22, you should do so.  The “apply” section at the end is this week’s homework.  I should have the next chapter out this weekend, but the homework will be for chapter 22, which is already there. UPDATE – chapter has been updated on the site.

Calculus

This week we covered trig substitutions in more depth.  I am still working on plans for this week’s homework and next week’s lesson.  More information hopefully over the weekend.