Skip to content

Commit

Permalink
Merge branch 'gh-pages' of github.com:shiffman/A2Z-F16 into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
shiffman committed Sep 27, 2016
2 parents 60620b4 + 0f61e48 commit 0e5d981
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 51 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This course focuses on programming strategies and techniques behind procedural a
- Daniel Shiffman, Tuesdays, 9:00am-11:30am
- [All class dates](http://help.itp.nyu.edu/curriculum/fall-class-dates)
- [Office Hours](https://itp.nyu.edu/inwiki/Signup/Shiffman)
- In addition to the ITP physical class, I am running an online version of the class for [Patreon](patreon.com/codingrainbow) subscribers. ITP students will receive a slack invite should they want to participate. YouTube live stream sessions TBA.
- In addition to the ITP physical class, I am running an online version of the class for [Patreon](https://www.patreon.com/codingrainbow) subscribers. ITP students will receive a slack invite should they want to participate. YouTube live stream sessions TBA.

## Mailing List
* [Join ITP A2Z Google Group](https://groups.google.com/a/nyu.edu/forum/#!forum/a2z-group/). This is for the ITP physical class only.
Expand Down Expand Up @@ -44,6 +44,7 @@ This course focuses on programming strategies and techniques behind procedural a
* [Homework Assignment](https://github.com/shiffman/A2Z-F16/wiki/Week-2-Homework)

## Week 3 -- Data/API Workshop
* [Notes and Examples](http://shiffman.net/a2z/data-apis/)
* JSON basics
* [Corpora maintained by tinysubversions](https://github.com/dariusk/corpora)
* JavaScript libraries
Expand All @@ -55,7 +56,7 @@ This course focuses on programming strategies and techniques behind procedural a
* [wikipedia api](https://en.wikipedia.org/w/api.php)
* Working with google sheets: [tabletop.js](https://github.com/jsoma/tabletop)
* machine learning as service: [clarafai](https://www.clarifai.com/)
* Homework TBA
* [Homework Assignment](https://github.com/shiffman/A2Z-F16/wiki/Week-3-Homework)

## Week 4 -- Intro to Node and Twitter Bots
* Server side programming with Node
Expand Down
2 changes: 1 addition & 1 deletion week3-apis-data/02_nlp_compromise/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h3>Type a sentence</h3>
<p>
<button id="pluralize">pluralize nouns</button>
<button id="negate">negate</button>
<button id="tense">past tense</button>
<button id="tense">future tense</button>
</p>

</body>
Expand Down
6 changes: 3 additions & 3 deletions week3-apis-data/03_wordnik_randomwords/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
// Developer documentation: http://developer.wordnik.com/

// Call to get a random noun
var randomNounURL = "http://api.wordnik.com/v4/words.json/randomWord?" +
var randomNounURL = "https://api.wordnik.com/v4/words.json/randomWord?" +
"&excludePartOfSpeech=proper-noun,proper-noun-plural,proper-noun-posessive,suffix,family-name,idiom,affix&" +
"&includePartOfSpeech=noun" +
"&minLength=5&maxLength=-1" +
"&api_key=48dd829661f515d5abc0d03197a00582e888cc7da2484d5c7";


// A random Adjective
var randomAdjURL = "http://api.wordnik.com/v4/words.json/randomWord?" +
var randomAdjURL = "https://api.wordnik.com/v4/words.json/randomWord?" +
"&includePartOfSpeech=adjective" +
"&minLength=5&maxLength=-1" +
"&api_key=48dd829661f515d5abc0d03197a00582e888cc7da2484d5c7";


// A random word
var randomWordURL = "http://api.wordnik.com/v4/words.json/randomWord?" +
var randomWordURL = "https://api.wordnik.com/v4/words.json/randomWord?" +
"&minLength=5&maxLength=-1" +
"&api_key=48dd829661f515d5abc0d03197a00582e888cc7da2484d5c7";

Expand Down
2 changes: 1 addition & 1 deletion week3-apis-data/04_wordnik_word_info/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Developer documentation: http://developer.wordnik.com/

// Main API URL
var wordnik = 'http://api.wordnik.com/v4/word.json/';
var wordnik = 'https://api.wordnik.com/v4/word.json/';
// API Key
var api_key = '/?api_key=48dd829661f515d5abc0d03197a00582e888cc7da2484d5c7'

Expand Down
2 changes: 1 addition & 1 deletion week3-apis-data/05_wordnik_related/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Daniel Shiffman
// http://shiffman.net/a2z

var url1 = "http://api.wordnik.com/v4/word.json/";
var url1 = "https://api.wordnik.com/v4/word.json/";
var word = "rainbow";
var url2 = "/relatedWords?useCanonical=false&limitPerRelationshipType=10&api_key=a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5"

Expand Down
2 changes: 1 addition & 1 deletion week3-apis-data/06_nytimes_articles/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function search() {
var term = input.value();

// URL for querying the times
var url = 'http://api.nytimes.com/svc/search/v2/articlesearch.jsonp?'
var url = 'https://api.nytimes.com/svc/search/v2/articlesearch.jsonp?'
+ 'callback=svc_search_v2_articlesearch&api-key=sample-key'
+ '&q=' + term;

Expand Down
2 changes: 1 addition & 1 deletion week3-apis-data/07_wikipedia/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function search() {
var term = input.value();

// URL for querying wikipedia
var url = 'http://en.wikipedia.org/w/api.php?action=opensearch&format=json&search='
var url = 'https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search='
+ '&search=' + term;

// Query the URL, set a callback
Expand Down
2 changes: 1 addition & 1 deletion week3-apis-data/08_nytimes_word_counts/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var start, end, total, w;
// Make a url that searhces for term appeared in a given year
function makeURL(term,year) {
var apikey = '&api-key=sample-key';
var api = 'http://api.nytimes.com/svc/search/v2/articlesearch.jsonp?callback=svc_search_v2_articlesearch&';
var api = 'https://api.nytimes.com/svc/search/v2/articlesearch.jsonp?callback=svc_search_v2_articlesearch&';
var query = 'q='+term+'&facet_field=source&begin_date='+year+'0101&end_date='+year+'1231&facet_filter=true';
var url = api+query+apikey;
return url;
Expand Down
73 changes: 33 additions & 40 deletions week3-apis-data/11_clarifai_test/sketch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// A2Z F16
// Daniel Shiffman
// Programming from A to Z, Fall 2014
// https://github.com/shiffman/Programming-from-A-to-Z-F14
// https://github.com/shiffman/A2Z-F16
// http://shiffman.net/a2z

var clientID = '9XnrhLXdHu1Dg0TSrK6dImCv-7VzCyhNRKJcl86E';
var clientSecret = 'hIqUOlreTW0Zlm0rcPR-v9hkfu1oJo9dmbmR3fDK';
Expand All @@ -17,46 +18,38 @@ function setup() {
'client_secret': clientSecret
}

// httpPost(baseUrl + 'token', data, success);
// function success(response) {
// console.log(response);
// accessToken = response;
// askClarifai();
// }

$.ajax(
{
'type': 'POST',
'url': baseUrl + 'token',
'data': data,
success: function (response) {
console.log(response);
accessToken = response;
askClarifai();
},
error: function (err) {
console.log(err);
}
});

// get authorization token and call askClarifai() on success
httpPost(baseUrl + 'token', data, "json", success_token, error);

}

function askClarifai() {
$.ajax({
url: 'https://api.clarifai.com/v1/tag/',
type: 'GET',
beforeSend: function(xhr) {
xhr.setRequestHeader('Authorization', 'Bearer ' + accessToken.access_token);
},
data: {
url: 'http://shiffman.net/images/dan_shiffman.jpeg'
},
success: function (response) {
console.log(response);
},
error: function (err) {
console.log(err);
},
});
var data = {
access_token : accessToken.access_token,
url: 'http://shiffman.net/images/dan_shiffman.jpeg'
}

httpGet(baseUrl + 'tag', data, "json", success_tag, error);
}

function success_token (response) {
console.log("success_token");
console.log(response);
accessToken = response;
askClarifai();
}

function success_tag (response) {
console.log("success_tag");
console.log(response);
results = response["results"];
tags = results["0"].result.tag.classes
for (var i = 0; i < tags.length; i++) {
createP(tags[i]);
}
}

function error (response) {
console.log("error");
console.log(response);
}

0 comments on commit 0e5d981

Please sign in to comment.