Working on that right now.
Also, I had uninstalled Rescuetime due to a bug it was causing, but I reinstalled it today, because it's really nice to have an app that tracks my activity, to hold myself accountable. We'll see if the bug returns.
I learned that gulp and grunt are built with Node.js.
node -v tells us the version of node we're running (I'm running 6.2.2). In the command line, entering node app.js or node index.js will run your node file (assuming your put your Node code in that file).
To exit the Node repl, do this:
If you're in a Unix terminal or Windows command line and want to exit the Node REPL, either...
- Press Ctrl + C twice, or.
- type .exit and press Enter, or
- press Ctrl + D at the start of a line (Unix only)
That gets you out. The tutorial says console.dir() (as opposed to console.log()) will print out more to the console, but when I tested this with a variable, the results were the same. We also used console.error(), but again, I saw no difference between that and console.log().
We went over the four P's of problem solving:
Preparation
Plan
Perform
Perfect
Okay, I'm still working on that tutorial, but we did a Node app for class, so now I've got the basics down!
Here's my Node application for class (it pulls the keys from another file):
var fs = require('fs'); | |
var argOne = process.argv[2]; | |
var argTwo = process.argv[3]; | |
var request = require('request'); | |
var keys = require('./keys.js'); | |
var Twitter = require('twitter'); | |
var client = new Twitter({ | |
consumer_key: keys.twitterKeys.consumer_key, | |
consumer_secret: keys.twitterKeys.consumer_secret, | |
access_token_key: keys.twitterKeys.access_token_key, | |
access_token_secret: keys.twitterKeys.access_token_secret | |
}); | |
var params = {count: 20}; | |
// spotify | |
var spotify = require('spotify'); | |
function getTweets(){ | |
client.get('statuses/user_timeline', params, function(error, tweets, response){ | |
if (!error) { | |
for (var i = 0; i < tweets.length; i++) { | |
console.log(tweets[i].text + " Created on: " + tweets[i].created_at); | |
fs.appendFile('log.txt', tweets[i].text + " Created on: " + tweets[i].created_at + "\n"); | |
} | |
fs.appendFile('log.txt', "================================================================="); | |
} else { | |
console.log(error); | |
} | |
}); | |
} | |
function getSong() { | |
var queryInput = "what's my age again"; | |
if (argTwo !== undefined) { | |
queryInput = argTwo; | |
} | |
spotify.search({ type: 'track', query: queryInput}, function(err, data) { | |
if ( err ) { | |
console.log('Error occurred: ' + err); | |
return; | |
} | |
console.log("Artist: " + data.tracks.items[0].artists[0].name); | |
console.log("Song Name: " + data.tracks.items[0].name); | |
console.log("Spotify Preview Link: " + data.tracks.items[0].external_urls.spotify); | |
console.log("Album: " + data.tracks.items[0].album.name); | |
fs.appendFile('log.txt', "Artist: " + data.tracks.items[0].artists[0].name + "\n" + "Song Name: " + data.tracks.items[0].name + "\n" + "Spotify Preview Link: " + data.tracks.items[0].external_urls.spotify + "\n" + "Album: " + data.tracks.items[0].album.name + "\n" + "================================================================="); | |
}); | |
} | |
function getMovie() { | |
var queryInput = "Mr. Nobody"; | |
if (argTwo !== undefined) { | |
queryInput = argTwo; | |
} | |
request('http://www.omdbapi.com/?t=' + queryInput + "&tomatoes=true", function (error, response, body) { | |
if (!error && response.statusCode == 200) { | |
var movieData = JSON.parse(body); | |
console.log("Title: " + movieData.Title); | |
console.log("Year: " + movieData.Year); | |
console.log("IMDB Rating: " + movieData.imdbRating); | |
console.log("Country: " + movieData.Country); | |
console.log("Language: " + movieData.Language); | |
console.log("Plot: " + movieData.Plot); | |
console.log("Actors: " + movieData.Actors); | |
console.log("Rotten Tomatoes Rating: " + movieData.tomatoUserRating); | |
console.log("Rotten Tomatoes URL: " + movieData.tomatoURL); | |
fs.appendFile('log.txt', "Title: " + movieData.Title + "\n" + "Year: " + movieData.Year + "\n" + "IMDB Rating: " + movieData.imdbRating + "\n" + "Country: " + movieData.Country + "\n" + "Language: " + movieData.Language + "\n" + "Plot: " + movieData.Plot + "\n" + "Actors: " + movieData.Actors + "\n" + "Rotten Tomatoes Rating: " + movieData.tomatoUserRating + "\n" + "Rotten Tomatoes URL: " + movieData.tomatoURL + "\n" + "================================================================="); | |
} | |
else { | |
console.log(error); | |
} | |
}); | |
} | |
function getRandom() { | |
fs.readFile("random.txt", "utf8", function(error, data) | |
{ | |
// If an error was experienced we say it. | |
if(error){ | |
console.log(error); | |
} | |
else { | |
var dataArray = data.split(','); | |
var argOne = dataArray[0]; | |
var argTwo = dataArray[1]; | |
switch(argOne) { | |
case "my-tweets": | |
getTweets(); | |
break; | |
case "spotify-this-song": | |
function getSong() { | |
var queryInput = "what's my age again"; | |
if (argTwo !== undefined) { | |
queryInput = argTwo; | |
} | |
spotify.search({ type: 'track', query: queryInput, count: 1 }, function(err, data) { | |
if ( err ) { | |
console.log('Error occurred: ' + err); | |
return; | |
} | |
console.log("Artist: " + data.tracks.items[0].artists[0].name); | |
console.log("Song Name: " + data.tracks.items[0].name); | |
console.log("Spotify Preview Link: " + data.tracks.items[0].external_urls.spotify); | |
console.log("Album: " + data.tracks.items[0].album.name); | |
fs.appendFile('log.txt', "Artist: " + data.tracks.items[0].artists[0].name + "\n" + "Song Name: " + data.tracks.items[0].name + "\n" + "Spotify Preview Link: " + data.tracks.items[0].external_urls.spotify + "\n" + "Album: " + data.tracks.items[0].album.name + "\n" + "================================================================="); | |
}); | |
} | |
getSong(); | |
break; | |
case "movie-this": | |
function getMovie() { | |
var queryInput = "Mr. Nobody"; | |
if (argTwo !== undefined) { | |
queryInput = argTwo; | |
} | |
request('http://www.omdbapi.com/?t=' + queryInput + "&tomatoes=true", function (error, response, body) { | |
if (!error && response.statusCode == 200) { | |
var movieData = JSON.parse(body); | |
console.log("Title: " + movieData.Title); | |
console.log("Year: " + movieData.Year); | |
console.log("IMDB Rating: " + movieData.imdbRating); | |
console.log("Country: " + movieData.Country); | |
console.log("Language: " + movieData.Language); | |
console.log("Plot: " + movieData.Plot); | |
console.log("Actors: " + movieData.Actors); | |
console.log("Rotten Tomatoes Rating: " + movieData.tomatoUserRating); | |
console.log("Rotten Tomatoes URL: " + movieData.tomatoURL); | |
fs.appendFile('log.txt', "Title: " + movieData.Title + "\n" + "Year: " + movieData.Year + "\n" + "IMDB Rating: " + movieData.imdbRating + "\n" + "Country: " + movieData.Country + "\n" + "Language: " + movieData.Language + "\n" + "Plot: " + movieData.Plot + "\n" + "Actors: " + movieData.Actors + "\n" + "Rotten Tomatoes Rating: " + movieData.tomatoUserRating + "\n" + "Rotten Tomatoes URL: " + movieData.tomatoURL + "\n" + "================================================================="); | |
} | |
else { | |
console.log(error); | |
} | |
}); | |
} | |
getMovie(); | |
break; | |
} | |
} | |
}); | |
} | |
switch(argOne) { | |
case "my-tweets": | |
getTweets(); | |
break; | |
case "spotify-this-song": | |
getSong(); | |
break; | |
case "movie-this": | |
getMovie(); | |
break; | |
case "do-what-it-says": | |
getRandom(); | |
break; | |
} |
We also worked on constructors, but that's basic stuff, so I won't go into it too much.
Now, I'm going to keep studying Node.js, but I'm going to put in 4 hours a day of React.js, every day (Monday through Friday) from 10 a.m. to 2 p.m., no matter what. I'll start going over that with the next entry.
Also, on our next class, we're going into mySQL.
SUMMARY OF CODING SKILLS
Books: Status
"Head First HTML and CSS," by E. Robson & E. Freeman Complete
"Head First HTML and CSS," by E. Robson & E. Freeman Complete
"A Smarter Way to Learn JavaScript," by Mark Myers Complete
"HTML and CSS," by Jon Duckett Complete
"JavaScript and JQuery," by Jon Duckett Complete
Team Treehouse (Front End Web Dev Track Complete): Status
How to Make a Website Complete
HTML Complete
HTML Forms Complete
HTML Tables Complete
HTML Video and Audio Complete
CSS Foundations Complete
CSS Basics Complete
CSS Layout Techniques Complete
CSS Layout Basics Complete
CSS Selectors Complete
Responsive Layouts Complete
CSS Flexbox Layout Complete
Framework Basics (Bootstrap and Foundation) Complete
Framework Basics (Bootstrap and Foundation) Complete
Git Basics Complete
Console Foundations Complete
Introduction to Programming Complete
JavaScript Basics Complete
JavaScript Loops, Arrays, & Objects Complete
AJAX Basics Complete
JQuery Basics Complete
Interactive Web Pages With JavaScript Complete
Object-Oriented JavaScript Complete
Accessibility Complete
Website Optimization Complete
Front End Performance Optimization Complete
Aesthetic Foundations Complete
Design Foundations Complete
Adobe Photoshop Foundations Complete
Adobe Illustrator Foundations 66% Complete
Other Courses: Status
HTML and CSS (Codecademy) Complete
Introduction to Web Dev (The Odin Project) Complete
Web Dev 101 (The Odin Project) 33% Complete
Free Code Camp (FCC) Status
1. Get Started with Free Code Camp Complete
2. HTML5 and CSS Complete
3. Responsive Design with Bootstrap Complete
4. Gear up for Success Complete
5. jQuery Complete
6. Basic Front End Development Projects Complete
7. Basic JavaScript Complete
8. Object Oriented and Functional Programming Complete
9. Basic Algorithm Scripting Complete
10. JSON API's and Ajax Complete
11. Intermediate Front End Development Projects Complete
5. jQuery Complete
6. Basic Front End Development Projects Complete
7. Basic JavaScript Complete
8. Object Oriented and Functional Programming Complete
9. Basic Algorithm Scripting Complete
10. JSON API's and Ajax Complete
11. Intermediate Front End Development Projects Complete
12. Intermediate Algorithm Scripting Complete
13. Advanced Front End Development Projects Complete
14. Claim Your Front End Development Certificate Complete
The Coding Boot Camp at UT Austin Status (starts 4/19/2016)
Week 1-6: Mastering the Browser (HTML, CSS, JavaScript, JQuery) Complete
Week 7-10: API & JSON (RESTful API"s, parsing JSON, AJAX) Complete
Week 11-14: Server Side (Node.js, MySQL, MongoDB) In Progress
Week 15-18: PHP (WordPress, CodeIgniter, Laravel)
Week 18-21: Full Stack Coding
Week 22-24: Final Project
My Web Dev Portfolio: www.adamcamacho.com
CodePen Projects: http://codepen.io/Adancode/
Week 22-24: Final Project
My Web Dev Portfolio: www.adamcamacho.com
CodePen Projects: http://codepen.io/Adancode/
GitHub Projects: https://github.com/Adancode
LinkedIn Profile: https://www.linkedin.com/in/adamcamacho1
Team Treehouse Profile: https://teamtreehouse.com/adamcamacho
Free Code Camp Profile: http://www.freecodecamp.com/adancode
Team Treehouse Profile: https://teamtreehouse.com/adamcamacho
Free Code Camp Profile: http://www.freecodecamp.com/adancode
Hours Spent Coding During This Blog Entry: 30
Total Hours Coding: 1,400