<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kathryn Hodge on Medium]]></title>
        <description><![CDATA[Stories by Kathryn Hodge on Medium]]></description>
        <link>https://medium.com/@blondiebytes?source=rss-df76b57e5595------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ejvJgcu2vG1BhZvh4TGuwg.png</url>
            <title>Stories by Kathryn Hodge on Medium</title>
            <link>https://medium.com/@blondiebytes?source=rss-df76b57e5595------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 15:50:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@blondiebytes/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Thursday Tech Tip!]]></title>
            <link>https://medium.com/@blondiebytes/thursday-tech-tip-4084e74571ee?source=rss-df76b57e5595------2</link>
            <guid isPermaLink="false">https://medium.com/p/4084e74571ee</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[women-in-tech]]></category>
            <dc:creator><![CDATA[Kathryn Hodge]]></dc:creator>
            <pubDate>Thu, 12 Apr 2018 18:25:40 GMT</pubDate>
            <atom:updated>2018-04-12T18:25:40.812Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PvP_UVYH21o1pDnr-QxPzw.jpeg" /></figure><p>THURSDAY TECH TIP! “When you’re stuck, write your program on paper. I’m serious. It’s magic. This is standard practice in programming competitions. (I think it works because when you don’t have to think about syntax you have more excess brain power to solve the actual problem.)” — Joseph Gentle ⚡<br><br>THE TRUTH IS SPOKEN. Stop jumping straight into the code! 🖥️ You have to analyze your problem and truly understand it before you can create a program or system that will help solve it. 👩‍💻</p><p>•<br>•<br>•<br>•</p><p><a href="https://www.instagram.com/explore/tags/womenintech/">#womenintech</a> <a href="https://www.instagram.com/explore/tags/tutorial/">#tutorial</a> <a href="https://www.instagram.com/explore/tags/technology/">#technology</a><a href="https://www.instagram.com/explore/tags/programming/">#programming</a> <a href="https://www.instagram.com/explore/tags/hacker/">#hacker</a> <a href="https://www.instagram.com/explore/tags/softwaredeveloper/">#softwaredeveloper</a><a href="https://www.instagram.com/explore/tags/code/">#code</a> <a href="https://www.instagram.com/explore/tags/howtocode/">#howtocode</a> <a href="https://www.instagram.com/explore/tags/coding/">#coding</a> <a href="https://www.instagram.com/explore/tags/learntocode/">#learntocode</a> <a href="https://www.instagram.com/explore/tags/developer/">#developer</a> <a href="https://www.instagram.com/explore/tags/learn/">#learn</a> <a href="https://www.instagram.com/explore/tags/technical/">#technical</a> <a href="https://www.instagram.com/explore/tags/learning/">#learning</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4084e74571ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When Beta iOS 11 Makes Your Phone a Brick]]></title>
            <link>https://medium.com/@blondiebytes/when-beta-ios-11-makes-your-phone-a-brick-6427ca551ae2?source=rss-df76b57e5595------2</link>
            <guid isPermaLink="false">https://medium.com/p/6427ca551ae2</guid>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[apple-watch]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[arkit]]></category>
            <category><![CDATA[ios-11]]></category>
            <dc:creator><![CDATA[Kathryn Hodge]]></dc:creator>
            <pubDate>Thu, 31 Aug 2017 19:51:57 GMT</pubDate>
            <atom:updated>2017-08-31T19:51:57.358Z</atom:updated>
            <content:encoded><![CDATA[<p>A couple of weeks ago, I was interested in messing around with Apple’s new ARKit, which allows third-party developers to create Augmented Reality experiences. In order to create these experiences and try them out yourself, you must download several beta products from Apple including beta Xcode and beta iOS 11. Downloading beta products is always a risk, but I figured ARKit was definitely worth it.</p><p>For the first few days, everything worked great. There were a couple of obvious bugs in the beta, but none that bothered me. I was able to use the Unity plugin to develop some basic AR experiences, including taking a picture with a 3-D model, but nothing too crazy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*PTQV1QhzPI-PfM5WV6ONrA.jpeg" /></figure><p>Then, one day, I was on the phone with a friend and the screen blacked out. The phyiscal buttons (Volume, Lock/Wake, and Home) all worked, but nothing happened when I touched virtual buttons on the screen.</p><p>This meant I could no longer use my phone productively and it was essentially no better than a brick.</p><p>Usually when an iPhone freaks out, the first thing you should do is a <strong>hard reset</strong>. On all previous phones, this meant pressing the Lock/Wake button and the Home button down at the same time until the phone restarted itself. Unfortunately, for the iPhone 7, the way to do a hard reset had changed and by pressing down the Lock/Wake and Home buttons, all I did was take a ton of screenshots of my phone background.</p><p>Luckily, I have an Apple Watch so I was still able to use some of the functionality of my phone, but not all. This meant..</p><ul><li>iMessage on the Apple Watch became my new messaging platform</li><li>I couldn’t accept vemno requests (sorry friends)</li><li>Amazon Echo became my morning alarm</li><li>Calling people via the Apple Watch became a regular thing</li><li>No more music during my runs :(</li></ul><p>After a day, I finally googled how to reset an iPhone 7, thinking it had to have changed, and all you have to do is press down the lower Volume button and the Lock/Wake button at the same time. With a hard reset, the phone was back to normal and I would never send messages with iMessage on the Apple Watch ever again.</p><p>Now a question for you! How would you adapt if your phone randomly broke during the day?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6427ca551ae2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Amazon Books?]]></title>
            <link>https://medium.com/@blondiebytes/what-is-amazon-books-d05283ef3eeb?source=rss-df76b57e5595------2</link>
            <guid isPermaLink="false">https://medium.com/p/d05283ef3eeb</guid>
            <category><![CDATA[shopping]]></category>
            <category><![CDATA[new-york-city]]></category>
            <category><![CDATA[columbus-circle]]></category>
            <category><![CDATA[amazon-books]]></category>
            <category><![CDATA[amazon]]></category>
            <dc:creator><![CDATA[Kathryn Hodge]]></dc:creator>
            <pubDate>Wed, 30 Aug 2017 21:37:58 GMT</pubDate>
            <atom:updated>2017-08-30T21:37:58.269Z</atom:updated>
            <content:encoded><![CDATA[<p>Amazon Books is a chain of stores owned by the technology giant Amazon. The first store opened in Seattle at the end of 2015, but recently, Amazon opened another in Columbus Circle in New York City.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nf4QeALpHQZx2bnLCcfs8w.jpeg" /></figure><p>It lies on the 3rd floor of Columbus Circle’s set of shops and is about 4,000 square feet. As you make your way in, you’ll notice about a fourth of the store is dedicated to Amazon’s technology products, including the Amazon Echo, Amazon Tap, Echo Dot, and the brand-new Echo Show.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hUkLMWA16YerM6UlJGkxzg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9gz6QEln6ifzdf999ANrFQ.jpeg" /></figure><p>This is the first time Amazon has been able to get their technology products in front of real people in their own branded space. There are also various Kindles and Amazon fire tablets in this section.</p><p>However, this “tech area” isn’t the only place where Amazon has technology. Throughout the entire store, Amazon uses data to help you decide if something might be worth buying. This starts with the prices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r3m-GFYd9_QuMZkME-ZKvg.jpeg" /></figure><p>Nothing in the store has a price tag. By removing the price from the main display, customers might be more tempted to pick up a bunch of things. With their prime membership usually giving them a deal, they feel good about their purchase, even though they might not have purchased books online in the first place. To find the price of an item, a customer can use their Amazon App or scan their item under one of these special wall-mounted scanners. Amazon Prime members usually get a steep discount (30% or more) on the list price.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QXU1ohGsCX16LqdkHm2OzQ.jpeg" /></figure><p>Amazon also uses the data they have collected from their online empire to inform customers of ratings, reviews, and other important information. Each section of their store nearly matches with a type of search you could make on their website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ZqrGzaZPoICipPprm4qyw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nhlE2-jT-RwVhpOZ7zthTQ.jpeg" /></figure><p>Each book is also accompanied with either a customer review or a data fact, such as “97% of reviewers rated this item 5 stars.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5hTYtCmyvCzUGbjkokYUcQ.jpeg" /></figure><p>Each card also states when it was last updated, so you have an idea of how recent the information is.</p><p>In the back of the store, Amazon provides in-store recommendations based on popular books you have probably read before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RyN6oFY4Wcrvw1QXQwec4w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*imzYb3wvovbMOIHC2q5U3A.jpeg" /></figure><p>Amazon truly uses the data they have collected in every possible way. Their shopping bags even include “Popular Highlighted Kindle Quotes!”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*864cevL5PLPwhWQXo22UHQ.jpeg" /></figure><p>This store could be seen as Amazon’s brick and mortar bookstore experiment, but rather, it’s testing a new way of selling merchandise. With the books are facing out, presence of reviews and data right next to the merchandise, and lack of price tags, it will be interesting to see if anyone else adopts a similar model in their stores.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d05283ef3eeb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Heroku Hosting: Put Your Website on the Cloud]]></title>
            <link>https://medium.com/@blondiebytes/heroku-hosting-put-your-website-on-the-cloud-cdc8729a7e09?source=rss-df76b57e5595------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdc8729a7e09</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[web-hosting]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Kathryn Hodge]]></dc:creator>
            <pubDate>Tue, 29 Aug 2017 18:14:21 GMT</pubDate>
            <atom:updated>2017-08-29T18:14:21.084Z</atom:updated>
            <content:encoded><![CDATA[<h4>Get your angular.js website on the internet with Heroku. Write a Node.js backend, use the command line, and more!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mnmdmkh70WiIuKnZEO6E9w.jpeg" /></figure><p><strong>Read the article or watch the video!</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FP86N9FqNqso%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DP86N9FqNqso&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FP86N9FqNqso%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6daa7f3985bd6aefb6f5e23de10f075e/href">https://medium.com/media/6daa7f3985bd6aefb6f5e23de10f075e/href</a></iframe><p>Today we are going to put a local web application on the Internet with Heroku. <strong>Heroku</strong> is a place we can host our code so that anyone around the world can see it. Let’s take the code from the Angular Endpoints tutorial and put it on the web. If you haven’t done the Angular tutorial, no worries! We will barely look at that code — we are just focused on getting it on the cloud. We’ll have to use Heroku because our angular code has directives, which are <strong>dynamic</strong> and won’t work on GitHub Pages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SEbso5YqYOONThjSecYO_g.jpeg" /></figure><p>Going into our folder, we’ll create a new file called <strong>package.json</strong>. This will contain all the <strong>metadata</strong> (details) about our application. Most importantly, it will list our <strong>dependencies</strong> that are needed to run our website and we will install those dependencies later. For now, just fill out your package.json like this…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zNyYP0TM0RH4J0CRoIHkUg.jpeg" /></figure><p>We name our app, give it a version, and tell it to start at the <strong>server.js</strong> file. We will be writing the <strong>back-end (or server-side)</strong> of our application in the server.js file with something called <strong>Node.js</strong>. Node.js is a platform that allows us to write our server-side in JavaScript instead of some other back-end language. Before, when we created the HTML, CSS, and Angular.js side of our application, we were creating the <strong>front-end</strong> — now we are writing the back-end.</p><p>We also have one dependency, <strong>Express (Version 4.13.3)</strong>, and this is a <strong>Node.js framework</strong> that makes it easy to get our server up and running. Next, we’ll create our <strong>Procfile</strong>, which will tell Heroku what command to run and where to look to start our server. In this case, it should look to the <strong>server.js</strong> file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wKLcdZ9EXgZTaFeI4I2XHA.jpeg" /></figure><p>Lastly, we will write out <strong>server.js</strong> file with <strong>Node</strong> and <strong>Express</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*718ow0p4NaaYSsy8DSR0OA.jpeg" /></figure><p>First, we require Express and create an Express application. Then, we set the <strong>port number</strong>, which could evaluate to one of two things. With <strong>process.env.PORT</strong>, we allow Heroku to set the port number (usually port 5000) and if that doesn’t work, then we default to port 8080.</p><p>Next, we write <strong>app.use(express.static(__dirname))</strong>s so that our <strong>static files</strong> (images, CSS) can be served and shown on the webpage. <strong>__dirname</strong> evaluates to the file path of the directory (folder) so all of our static files should be in or nested within this directory. With <strong>app.get()</strong>, we set up some routing for our application. When it is first loaded (‘/’), we run a function with the <strong>request</strong> and the <strong>response</strong> as parameters and tell the response to <strong>render the index</strong> (really index.html) file. This file will be able to access all of our front-end code, including our directives, since everything is <strong>linked</strong> inside of it.</p><p>Finally, we start our server. In the world of the Internet, users search a URL and by doing so, they send a <strong>request</strong>. The server, which is always <strong>listening</strong> for requests, sends a <strong>response</strong> that contains the webpage. To start our server, we have to get it to listen so we run the <strong>app.listen()</strong> function with the port number we set earlier and print out that the app is running.</p><p>Going to the command line, we’ll <strong>cd</strong> into our current directory <a href="https://www.youtube.com/playlist?list=PLcLMSci1ZoPvbvAIn_tuSzMgF1c7VVJ6e">(learn basic command line / terminal here on my channel)</a> and install our <strong>dependencies</strong>. We will be using <strong>npm</strong>, which is a part of the Node.js platform, so if you don’t have npm, you can download it <a href="https://nodejs.org/en/download/">here</a> with node. Once in your directory with the <strong>package.json</strong> file, write <strong>npm install</strong>. This will install all of our dependencies or in this case, Express.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3lnYloCbkzE0ZdbZdtot9g.jpeg" /></figure><p>With our local code set up, we’ll go to the internet and create a <strong>Herkou account</strong>. To do this, we’ll go to <a href="https://signup.heroku.com/login">https://signup.heroku.com/login</a> and enter our information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j2vFUKKX-N1DGEqW_b8-kw.jpeg" /></figure><p>For primary development language, we’ll choose <strong>Node.js</strong> and then, we’ll click submit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5lN-qchThab2C8AHkcYn7Q.jpeg" /></figure><p>Now, we need to <strong>confirm</strong> our email…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B_o9W6NTCqY5PpbWsyOqBw.jpeg" /></figure><p>And once it is confirmed, set the password and then proceed with the account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fOfMgbYKsaxRW7NrOFBWUw.jpeg" /></figure><p>Our Heroku account is set up! We just need to <strong>bring Heroku to our command line</strong> so we can push it up to the cloud. To do this, we’ll download the <strong>Heroku Command Line Tools</strong> at <a href="https://devcenter.heroku.com/articles/heroku-command-line">https://devcenter.heroku.com/articles/heroku-command-line.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zm157m4cJtz6jnHbgBSt4w.jpeg" /></figure><p>With the tools downloaded, double check to see if you have it by writing <strong>heroku — version</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H9C0I_Il2lRsS2ZKJJAuLQ.jpeg" /></figure><p>Next, from the command line, we will login with the command <strong>heroku login</strong>. After entering your information, you should see something similar to this…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nPrj_xGtrCkMqmJH24-P4w.jpeg" /></figure><p>We can see if this application works if write go <strong>heroku local web</strong> in the command line…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OOipZviFhXvY_xDXu5UJSw.jpeg" /></figure><p>… and then go to <a href="http://localhost:5000."><strong>http://localhost:5000</strong>.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fl67SiYhi4Q5zDxl7q8GoA.jpeg" /></figure><p>There’s our application! Now, this is only running <strong>locally</strong> on my computer — meaning if you go to localhost:5000, you will not see what I see. We’ll go ahead and stop our localhost with <strong>command (or control) C</strong> and get this code to the cloud where everyone can see it. To do this, we will deploy with <strong>Git</strong>. If you don’t have git, you can click <a href="https://git-scm.com/downloads">here</a>, download it, and come back to continue. You can check if you have git with <strong>git — version</strong> (similar to how we checked with heroku). Once you have git, you can intialize this directory as a GitHub repository with the command <strong>git init</strong>. To learn more about how git works, check out these <a href="https://www.youtube.com/playlist?list=PLcLMSci1ZoPvA0gXxT6iMz-IIY1e4wZhy">tutorials</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*blBpnzuJsCVSjq7lxPp6BA.jpeg" /></figure><p>Next, we’ll add all our changes to the staging area with <strong>git add .</strong> and then commit them with <strong>git commit -m “Initing”</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8EuUzBlm4mJu6802Fiisxg.jpeg" /></figure><p>Now, we are ready to <strong>push to the cloud (Heroku)</strong>, which will host our code! First, we’ll make this a Heroku application with the command <strong>heroku create</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ivF71lSRTACult9P3HN6Gw.jpeg" /></figure><p>This <strong>creates</strong> our application and names it <strong>guarded-brook-64454</strong>. If you are doing this tutorial along with me, yours will be named something else and that’s okay! If we go back to our Heroku dashboard, we’ll actually see our app created on the site — however, it doesn’t have our code yet!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VRGEmep4GM-5RCg3QpQbvQ.jpeg" /></figure><p>To get our code up on Heroku, we’ll write <strong>git push </strong><a href="https://git.heroku.com/guarded-brook-64454.git"><strong>https://git.heroku.com/guarded-brook-64454.git</strong></a><strong> master</strong>. If you are creating your own Heroku app, instead of guarded-brook-64454, you should put your own app’s name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8iWApO25dPwiK3hx5GcN8Q.jpeg" /></figure><p>It may take a minute for this command to run and so go get a coffee or something. Once it’s done you should see something like…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IvAfdRhXZE4iebSf0c_5oA.jpeg" /></figure><p>Notice, it says <a href="https://guarded-brook-64454.herokuapp.com/"><strong>https://guarded-brook-64454.herokuapp.com/</strong></a> deployed to Heroku. This means if we go to <a href="https://guarded-brook-64454.herokuapp.com/">https://guarded-brook-64454.herokuapp.com/</a>, we should see the result of our code — aka our website. Going to this URL…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4k82YyVmGeX-WJ8yuxTqDw.jpeg" /></figure><p>And we see exactly what we were expecting! If you go to this URL right now, you’ll also see this code (as I won’t be changing it). If we changed our code, added and committed the changes, and pushed the altered code up to this Heroku application, we would see something different (our altered app). That’s it for this tutorial! Check back next Friday for another post.</p><h4>Things to Remember:</h4><pre>&lt;!-- Package.json --&gt;<br>- This file holds the metadata for our application.<br>- All metadata is held within a JSON object.<br>- This also holds the dependencies that npm install will download.</pre><pre>&lt;!-- Back-End Files --&gt;<br>- package.json<br>- Procfile<br>- server.js</pre><h4>Plus a Little Extra:</h4><pre>&lt;!-- More on Heroku Command Line--&gt;<br>https://devcenter.heroku.com/articles/heroku-command-line</pre><pre>&lt;!-- What are Node.js, Express, and Procfile? --&gt;<br>Node.js - a platform that allows us to write our back-end in JavaScript<br>Express.js - a Node.js framework that makes writing our back-end easier<br>Procfile - allows us to declare what commands should be run by Herkou - here we are running a web application with Node.js that starts with the server.js file.</pre><p><a href="http://www.github.com/blondiebits/code-in-5">Code</a> from this blog post</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdc8729a7e09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get Your Website on the Web with GitHub Pages]]></title>
            <link>https://medium.com/@blondiebytes/get-your-website-on-the-web-with-github-pages-9bdc2886ae7a?source=rss-df76b57e5595------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bdc2886ae7a</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Kathryn Hodge]]></dc:creator>
            <pubDate>Wed, 16 Aug 2017 20:58:25 GMT</pubDate>
            <atom:updated>2017-08-16T20:58:25.667Z</atom:updated>
            <content:encoded><![CDATA[<h4>Put your content on the internet with GitHub Pages</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9pk7p1fqjTM1CUU521OUlA.jpeg" /></figure><h4>Read the article or watch the video!</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FhXorYP_HQtM%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DhXorYP_HQtM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FhXorYP_HQtM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfc18f4dd7982664af741f48588b9567/href">https://medium.com/media/dfc18f4dd7982664af741f48588b9567/href</a></iframe><p><strong>GitHub Pages</strong> is a <strong>static site hosting service</strong> that allows us to put our local webpages on the Internet. In order to use GitHub Pages, first you’ll need a <strong>GitHub account</strong>. GitHub is a website so we can just go to the <a href="http://blondiebits.herokuapp.com/www.github.com">www.github.com</a> and create a login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d2Vd2xYhFU_wgILvEIi_fQ.jpeg" /></figure><p>Here, keep your account <strong>public</strong>. It’s the free option and just means that anyone can see your projects (which isn’t a huge deal right now).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0H5odf2QuD1nG1MndvoxQ.jpeg" /></figure><p>Next, we’ll need to navigate back to the homepage by clicking the <strong>cat icon</strong> in the top left corner. Once on the homepage, go to your email and click the link to <strong>verify</strong> so we can create a new project. Once your email is verified, go ahead and press the <strong>Start a Project button</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dXkfIqWm2XEZ78GVbVdc5Q.jpeg" /></figure><p>Now, we can set up our project (website) that will be on the Internet. Here, it says <strong>Create a Repository</strong> and a repository is just another name for project or folder. Don’t get too caught up in the terminology for now — just know that this is where the code for our webpage is going to go.</p><p>Name your project your <strong>username.github.io</strong>. So if your username is harrypotter, your project name should be harrypotter.github.io. It is very important that it’s named this way because that’s how we get <strong>access</strong> to GitHub’s free hosting service (GitHub Pages). Go ahead and keep this project public — which just means anyone can see the code — and initialize it with a <strong>README</strong>. The README usually contains an in depth description of the project, which you can write later. Clicking submit…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hpchrQvquvTXEzuGuKbxiA.jpeg" /></figure><p>And now we have our project! Now how do we get our website code there? Well, we can just create new files and code it all here <strong>online</strong> or you could upload files from your computer. Another option is to use the <strong>command line</strong>, which would allow us to code this locally on our own computer with Sublime and then upload it to GitHub through the text-based terminal. If you are interested in that, check out <a href="https://youtu.be/yTt0-NBHQ4s">GitHub Terminal Pt. 2 video</a>. You could also do this with the <strong>applications that GitHub</strong> has, but doing it from the terminal feels a lot cooler.</p><p>To use the terminal with <strong>git</strong>, you’ll need to download the git. The easiest way to do this is to download the applications provided by GitHub by clicking <strong>Clone or Download</strong> and then <strong>Open in Desktop</strong>. For the purposes of this tutorial, we will just be using the github website to write our code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YEfWfSKw1pW-2Llwo-m69g.jpeg" /></figure><p>To start developing our website, we’ll go ahead and click <strong>Create New File</strong> and call it <strong>index.html</strong>. Inside of here, we’ll just create a simple header that says Hello World.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O16tAvTFtCsyXMaKqruYaQ.jpeg" /></figure><p>Then, we’ll scroll down and commit the change by pressing <strong>Commit new file</strong>. In the text box, you can add a description about the change you made, but we’ll just keep it blank for this tutorial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dha69BTZy1qSRzF5oqshuw.jpeg" /></figure><p>Now, if the go to our <strong>github.io website</strong>, we’ll be able see the results of our code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vHiVn9njS47dNi8da8iiRw.jpeg" /></figure><p>And there we see our <strong>Hello World</strong>. If we go to another computer and try to access this website, we’ll also see Hello World. Right now, anyone in the world can go to a <strong>yourusername.github.io</strong> website and they will see the results of whatever code is written in the yourusername.github.io repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LCADTEqtlaU0xhkgEsOFHw.jpeg" /></figure><p>What if we want this header to say <strong>Hello Bob</strong> instead? Well, we can go back to GitHub and click the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_jHl6uF0NUCECdZIuy9KIQ.jpeg" /></figure><p>Then, we can press the <strong>pencil icon</strong> and edit the file to have Hello Bob instead along with some extra text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7aPA4CdKObMeDEjgA21Njg.jpeg" /></figure><p>After committing the change, we can refresh the website and now we see <strong>Hello Bob</strong> and <strong>I am a hacker</strong>. If you don’t see this change immediately on your website, try waiting five minutes and refresh again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sXJI9Z4bcG1-3Y5-OW6BGg.jpeg" /></figure><p>You just learned how to use <strong>GitHub Pages</strong>!! Remember, this will only work with <strong>static sites</strong> so there can’t be any dynamic angular directives or routing going on because that won’t work. However, you can have directives and routing on other hosting sites, such as <strong>Heroku</strong>. Due to the fact that classes are back in session for me, tutorials might be coming out every two weeks instead of every week. However, the next post will be on <strong>how to use Heroku to host your Angular website</strong> so that anyone in the world can access that as well. See you then.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*G3xDFBPEXtW-C-r5qy2ZVw.png" /></figure><h4>Things to Remember:</h4><pre>&lt;!-- Repository Name for Free Hosting--&gt;<br>Given the username blondiebytes, the repo name should be...<br>blondiebytes.github.io</pre><pre>&lt;!-- How to Get Free Hosting --&gt;<br>1. Create GitHub Account<br>2. Make a project / repo with the appropriate name<br>3. Put HTML/CSS code in that repo<br>4. Go to the appropriate web URL and see your site!</pre><h4>Plus a Little Extra:</h4><pre>&lt;!-- More Information on GitHub Pages --&gt;<br>https://pages.github.com/</pre><pre>&lt;!-- How to Get More Free Hosting --&gt;<br>1. Create more accounts<br>2. Create multiple organizations with one account</pre><pre>&lt;!-- Example of a GitHub hosted-site --&gt;<br>https://blondiebytes.github.io/</pre><p><a href="http://www.github.com/blondiebits/code-in-5">Code</a> from this blog post</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bdc2886ae7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Add a Service to Your Angular Application]]></title>
            <link>https://medium.com/@blondiebytes/how-to-add-a-service-to-your-angular-application-18768564faf5?source=rss-df76b57e5595------2</link>
            <guid isPermaLink="false">https://medium.com/p/18768564faf5</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Kathryn Hodge]]></dc:creator>
            <pubDate>Mon, 07 Aug 2017 16:32:43 GMT</pubDate>
            <atom:updated>2017-08-07T16:32:43.149Z</atom:updated>
            <content:encoded><![CDATA[<h4>Figure out how to organize your data better with an angular service</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5PSV2Gl07Umc6vyVse9ZUA.jpeg" /></figure><h4>Read the article or watch the video!</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Frs8MbeCMeP8%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Drs8MbeCMeP8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Frs8MbeCMeP8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f283d03761cdbb1efc2d11348664a2bd/href">https://medium.com/media/f283d03761cdbb1efc2d11348664a2bd/href</a></iframe><p>Today, we’re going to talk about <strong>Angular services</strong>. A <strong>service</strong> is something that talks to our controller and helps us organize where we get our data. We have some code here that <strong>initializes</strong> an Angular application, has a <strong>controller</strong> that controls the data, and a <strong>simple index.html view</strong> to display the data. We are going to make it so that it will display the current top Technology stories from the New York Times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*081gjmXWVvz96N0q7QBPnQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OIs6hzNl2QGZbe1jU1WjDQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZZuPYsjiBgQ_jaGfD5bMTw.jpeg" /></figure><p>To get our data from the Times, let’s take a look at the <a href="http://developer.nytimes.com/"><strong>New York Times Developer website</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ebmg8ghiCxqHiopKEmkSlw.jpeg" /></figure><p>There’s a lot of data we can access from the New York Times, but first we’ll need an <strong>API Key</strong>. An <strong>API</strong> is an <strong>Application Programming Interface</strong> and it’s how we’ll get our data from the New York Times. We can access the API with an API key. This key that will be <strong>specifically assigned to us</strong> so if we try to hack anything or abuse the API or doing any suspicious, the New York Times will know that it is us and block our access. So let’s go ahead and get an API Key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wrDrOGlILRBJW6NlC5NXKA.jpeg" /></figure><p>We’ll fill out the form with <strong>Top Stories V2 selected</strong> in the dropdown and once we hit submit, the API key, which will consist of letters and numbers, will be emailed to us. For this tutorial, I’m going to <strong>block out</strong> my API key because it’s supposed to be a secret — kind of like a password. If I showed it here, you could do some hacky stuff and it would all be pinned on me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yd__7htC5reffCgJY8LvFQ.jpeg" /></figure><p>Once we get our key, we can have some fun. We’ll go ahead and go back to the main developer page and scrolling down, click on <strong>Top Stories V2.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GrRnD92JDfYX_nzDOAjnyg.jpeg" /></figure><p>We’ll click the <strong>Try It Out</strong> button and mess with their demo set up here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L56HT3mdez7Y5CVL29UHwA.jpeg" /></figure><p>Right now, we are <strong>unauthorized</strong>, but once we insert our API key on the left, we’ll be able to use the API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oJojZTRB7uivR0q3ZJnQeA.jpeg" /></figure><p>So inserting our key, we can see what this API does. For the <strong>Parameters</strong>, we have <strong>section</strong> and <strong>format</strong>, where section has the value <strong>home</strong> and the format is a <strong>JSON object</strong>. A JSON is just a way we can organize our data in JavaScript so don’t worry too much it for now, just know our data from the New York Times is formatted as a JSON. In this JSON on the right here, we can see what <strong>data</strong> this API returns. We get a status code, a copyright, and the number of results returned along with a bunch of other stuff. We only really care about the <strong>results</strong> aka our Top Stories from the Home section.</p><p>When we access this data in our Angular application, we will want to iterate through this <strong>results array</strong> (where each result is an article) showing the <strong>title</strong>, <strong>abstract</strong>, and a <strong>link</strong> to the article. Notice that the API does not give us the full article text since you have to pay to read the New York Times. In other words, the New York Times is allowing us access to some data (article titles, images, etc), but not all of the data it has. To get data on the <strong>Top Technology Stories</strong>, all we’ll have to do is change the <strong>value</strong> of the <strong>section parameter</strong> to <strong>Technology</strong> instead of Home</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dPpFLjH6FS41hiZRuJTt9Q.jpeg" /></figure><p>Now how do we get this JSON into our code? We’ll use <strong>$http</strong>, which is another service that allows us to get information from the Internet. We could get the data in the controller like we did in the <a href="http://blondiebits.herokuapp.com/#/8">previous tutorial</a>, but to make our application more organized, we’ll use a service. To do this, we’ll create a new folder called <strong>services</strong> and put a <strong>file</strong> called <strong>nyt.js</strong> inside of it. In the file, we’ll write some code that <strong>initializes a new service</strong> that uses <strong>$http</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T8GGMj9zNRczHYZ_rHbFbA.jpeg" /></figure><p>To get the New York Times data, we’ll need to add an <strong>HTTP GET Request</strong>. We can somewhat guess what the <strong>endpoint</strong> will be by looking at the sample code in the developer demo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fmDMLCLPJZXkmE7vaoLQPA.jpeg" /></figure><p>In the JavaScript sample code, the New York Times uses AJAX instead of Angular, but we can make it work for our purposes. We’ll make a <strong>GET Request</strong> with the URL shown in the demo and then add in our <strong>API key as an argument</strong> to the <strong>api-key parameter</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ryJrYcxeMD7xozaWGNU9ZA.jpeg" /></figure><p>Now our service is set up — it gets data from the New York Times and returns it! With this the service ready-to-go, let’s access it and use it in our <strong>controller</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2bkirZDSekEJMa5r-gub5Q.jpeg" /></figure><p>Here, we insert the service as a <strong>dependency</strong>, meaning the application won’t work if we don’t have the code for the service. In the controller, we run the service and if it is successful, the function with the data will be run. To see if any of this works so far, we <strong>print out the data</strong> inside the function. Now, let’s import the service into our view, open a web browser, and see what happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9FAvK_09ovF_pB45LRuXFA.jpeg" /></figure><p>And we get the <strong>JSON</strong> we saw in the demo — except a lot less formatted. Let’s go back to the code and change it so we take what we want from this data, put it in scope, and then access it in view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vMMnlZsD7x54fUFG0EsFcw.jpeg" /></figure><p>If you look back at the JSON object, you’ll see that it had an <strong>attribute</strong> called <strong>results</strong> that was an array. Each item in the results array has a <strong>title</strong>, <strong>abstract</strong>, and <strong>url</strong>. Here, we create an <strong>object</strong> called <strong>story</strong> and put these properties into it. Finally, we add the story to the <strong>list</strong> attribute in the scope, which will contain all of our stories (aka our <strong>Top Technology articles</strong>) in the end.</p><p>Now with the data in our scope, we just need to access it in our <strong>view</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JCeARbo8OjOJILGFHjrTDQ.jpeg" /></figure><p>Here, we access the <strong>list attribute</strong> from the <strong>scope</strong> and <strong>iterate</strong> through all the stories inside of it. We display each story’s title and abstract and give a link to where the user can access the full text. Let’s open this up in the browser and see what we get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xiULZyWM2S54e2nVdw__tQ.jpeg" /></figure><p>There we go! Now, we have a list of the <strong>most recent Top Technology stories</strong>, each given with a title, abstract, and a link to their full text. That’s all for now, but next time, we’ll talk about <strong>how to host</strong> your webpage on a server with <strong>GitHub pages</strong> and make it available to everyone around the world! See you then.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*-49PPk6gyfKlBOxouQqSYg.png" /></figure><h4>Things to Remember:</h4><pre>&lt;!-- Example Endpoint for NYT Top Stories V2 API --&gt;<br>https://api.nytimes.com/svc/topstories/v2/technology.json</pre><pre>&lt;!-- How to Create a Service --&gt;<br>app.factory(&#39;serviceName&#39;, [&#39;$http&#39;, function($http) {<br>	// go get data with HTTP request and return it<br>}])</pre><pre>&lt;!-- How to Make a GET Request with Parameters--&gt;<br>return $http.get(&quot;https://api.nytimes.com/svc/topstories/v2/technology.json&quot;, <br>       {params: {&#39;api-key&#39;: &quot;keyHere&quot;}})<br>		.success(function(data) {<br>                    	return data;<br>        	})<br> <br>        	.error(function(err) {<br>                    	return err;<br>        	})</pre><h4>Plus a Little Extra:</h4><pre>&lt;!-- More Documentation on the New York Times API --&gt;<br>http://developer.nytimes.com/</pre><pre>&lt;!-- How to Access a Service inside of a Controller --&gt;<br>app.controller(&#39;MainController&#39;, [&#39;$scope&#39;, &#39;serviceName&#39;, function($scope, nyt) {<br>	serviceName.success(function(data) {<br>    	// do stuff with returned data<br>    })<br>}])</pre><pre>&lt;!-- Example of JSON Object --&gt;<br>{ <br>	&quot;day&quot; : &quot;August 5&quot;,<br>	&quot;favorite_memory&quot; : &quot;Going to the Store&quot;<br>	&quot;favorite_food&quot; : &quot;Pizza&quot;<br>	&quot;favorite_candy&quot; : &quot;Skittles&quot;<br>	&quot;favorite_activity&quot; : &quot;Filmmaking&quot;<br>}</pre><p><a href="http://www.github.com/blondiebits/code-in-5">Code</a> from this blog post</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18768564faf5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Access an Endpoint with Angular.js]]></title>
            <link>https://medium.com/@blondiebytes/access-an-endpoint-with-angular-js-ac18739c434c?source=rss-df76b57e5595------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac18739c434c</guid>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[endpoints]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[Kathryn Hodge]]></dc:creator>
            <pubDate>Mon, 07 Aug 2017 16:32:20 GMT</pubDate>
            <atom:updated>2017-08-07T16:32:20.826Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to get data from the internet via endpoints with Angular.js</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JqCh3tP5RhPWX2-FP1EGDQ.jpeg" /></figure><h4>Read the article or watch the video!</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F9XqIk2Tzvqc%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D9XqIk2Tzvqc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F9XqIk2Tzvqc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1527d053b9aa3682150ea705e566163c/href">https://medium.com/media/1527d053b9aa3682150ea705e566163c/href</a></iframe><p>Here, we have our <a href="https://github.com/blondiebits/code-in-5/tree/master/Directives%20in%209"><strong>list application</strong></a> from <a href="http://blondiebits.herokuapp.com/#/7">last time</a>. We have our to-do list and our books list and when we add an item, it gets added to the list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V8f2rwMMocU9ugAf6tkB5A.png" /></figure><p>But what if we had an <strong>ISBN number</strong> of a book and needed to add that to our books to buy list? We wouldn’t want just the number to show up. We’d want the title and author of the book to show up instead and we can do this by using the <strong>Google Books API</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nJyv5QAfsCHaKXiYeTpKdQ.jpeg" /></figure><p>In our index.html, we call a method called <strong>addItem</strong> that adds the book to the list. We can change this method so that when it takes the user input, we use the <strong>Google Books API</strong> to change it and add the result to our list versus just adding the number to the list. To do this, we’ll need to go to our <strong>MainController</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5PG1bgwcvJgu1Qx-xYqyjA.jpeg" /></figure><p>We’ll need to change the <strong>addItem method</strong> so that it checks if the input is an ISBN number and if it is, add the appropriate title and author to the list. What defines an <strong>ISBN number</strong>? Well, for this case, we’ll say it’s an item that is <strong>10 or 13 characters long</strong> and <strong>consists of all numbers</strong>. If it’s an ISBN number, we’ll print that it is an ISBN number and if it’s not then we’ll print that it is not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vtu6mGqA2TLVE-4DLG1Myg.jpeg" /></figure><p>Now, with this in place, we should define the <strong>hasAllNumbers function</strong>. This may look a little strange at first, but it will make sense in a minute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tMXD9VqTUIqyJz_6c792UA.jpeg" /></figure><p>Here, we have something called a <strong>regular expression</strong>. Basically, it will return true or false, based on whether the input <strong>matches</strong> this expression.</p><ul><li><strong>/</strong> means the start of an expression that we are about to define.</li><li><strong>^</strong> means that we will start our “matching” at the beginning of the input versus in the middle or at the end.</li><li><strong>[0–9]</strong> means the input should match any digit 0–9 and combined with the caret in front means the first character should be a digit.</li><li><strong>*</strong> means we can have any number of the previous expression, which means in this case, we can have as many digits as we want.</li><li><strong>$</strong> means this should be the end of the input</li><li><strong>/</strong> closes the regular expression.</li></ul><p>If this is all true for the input and the input <strong>matches the rules</strong> in the regular expression, then <strong>/^[0–9]*$/.test(item);</strong> will return true, otherwise it will return false. In other words, our expression above tests if the input <strong>consists of all digits</strong> — it will return true if it does and false if it doesn’t. It may consist of no characters or 15 characters, but our other test in the if statement checks if it is the appropriate length so we don’t need to worry about that here.</p><p>So let’s save this, stop our http-server, and close our browser. The reason we must do this is because of <strong>caching issues</strong> — the browser still thinks we are running an older version of the code. We’ll restart our http-server, open a browser in incognito mode, and go to our local host URL. Next, we’ll add an ISBN number and if we open the <strong>console</strong>, we should see <strong>“Is an ISBN number”</strong> printed out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BhcAXifmXCPFjWk3fLNRPA.jpeg" /></figure><p>If we add something that is not an ISBN number, then <strong>“Not an ISBN number”</strong> will be printed out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XimcHuHNiC1ONAGr2YGfNg.jpeg" /></figure><p>So our test for ISBN numbers works! Now, we just need to use the <strong>Google Books API</strong> to convert the input and then add that converted input to the list. Going back to our controller, we’ll add a <strong>service</strong> called <strong>$http</strong>. We’ll talk more about services in the next video, but this allows us to hit the <strong>endpoint</strong> for the Google Books API and get data from the internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XEdLg2qs2jYON6jKD0jqQw.jpeg" /></figure><p>After doing some research, I found that if we go to the URL <a href="https://www.googleapis.com/books/v1/volumes?q=isbn:"><strong>https://www.googleapis.com/books/v1/volumes?q=isbn:</strong></a> where the ISBN number is after the colon, we get a JSON object that gives us a bunch of data about a given book. A <strong>JSON</strong> is just a way of ordering data in JavaScript and we won’t worry about it too much for now. So if we just use a random ISBN number here and open the page, we’ll see some data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tx8zlnhR2RunNz6qBMkphg.jpeg" /></figure><p>Going back to our <strong>MainController</strong>, we can get this data into our code by going…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Uh5640RvBNpUDDZBSFAAw.jpeg" /></figure><p>Here, we use the <strong>$http service</strong> and make a <strong>GET request</strong> to get data from the <a href="https://www.googleapis.com/books/v1/volumes?q=isbn:">https://www.googleapis.com/books/v1/volumes?q=isbn:</a> + item webpage. The data we get <strong>depends on what ISBN number (item) the user inputs</strong>. If the GET request is <strong>successful</strong>, then we will run the function with data as a <strong>parameter</strong>. The value of this parameter will be the data from the webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tx8zlnhR2RunNz6qBMkphg.jpeg" /></figure><p>Going back to the JSON object displayed <a href="https://www.googleapis.com/books/v1/volumes?q=isbn:0747532699">here</a>, we can see that the <strong>title</strong> is nested within <strong>volumeInfo</strong>, which is nested within the <strong>first element</strong> of the data’s <strong>items</strong>. We can also see that the <strong>author</strong> or authors are <strong>nested</strong> within volumeInfo as well. To access these specific things, we can add some more code to our <strong>MainController</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z6ELJyDw8wXmNMGh-HbHsA.jpeg" /></figure><p>We’ll want to push a new item to our <strong>itemList</strong>, but what is this item? It should be a <strong>String</strong> consisting of the <strong>title</strong> and <strong>author</strong> from the data we just got from the internet. We have the data so to access the title we’ll write <strong>data.items[0].volumeInfo.title</strong> and to access the author we’ll write <strong>data.items[0].volumeInfo.authors</strong>. Now, we’ll just move the <strong>itemList.push(item);</strong> to the <strong>else clause</strong> and we will be good to go!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZtLB-hSugBs7xTTBncZbag.jpeg" /></figure><p>Now, if we go ahead and <strong>close</strong> all of our windows, stop <strong>http-server</strong>, start it again, and open an <strong>incognito window</strong>, we’ll be able to test our new code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aDQtmsjgKkaUP_-5lta76A.jpeg" /></figure><p>And it works! I hope you learned something in this tutorial and next week, we’ll go more into <strong>Angular services</strong>. See ya then.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*lsifjxXshJCWxUtrK2X3jQ.png" /></figure><h4>Things to Remember:</h4><pre>&lt;!-- Example Endpoint for Google Books API --&gt;<br>https://www.googleapis.com/books/v1/volumes?q=isbn:0747532699</pre><pre>&lt;!-- How to Add $http --&gt;<br>app.controller(&#39;ControllerName&#39;, [&#39;$scope&#39;, &#39;$http&#39;, <br>	function($scope, $http) { /* implementation */ }])</pre><pre>&lt;!-- How to Make a GET Request --&gt;<br> $http.get(&#39;https://www.googleapis.com/books/v1/volumes?q=isbn:0747532699&#39;).<br> 	success(function(data){<br> 		// access data and do something with it<br>    })</pre><h4>Plus a Little Extra:</h4><pre>&lt;!-- More Documentation on the Google Books API --&gt;<br>https://developers.google.com/books/docs/v1/using</pre><pre>&lt;!-- Example of JSON Object --&gt;<br>{ <br>	&quot;day&quot; : &quot;August 5&quot;,<br>	&quot;words_of_the_day&quot; : [<br>				&quot;firecracker&quot;, <br>				&quot;computer science&quot;,<br>				&quot;software development&quot;<br>			]<br>}</pre><p><a href="http://www.github.com/blondiebits/code-in-5">Code</a> from this blog post</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac18739c434c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use Angular Directives]]></title>
            <link>https://medium.com/@blondiebytes/how-to-use-angular-directives-2777a16dd757?source=rss-df76b57e5595------2</link>
            <guid isPermaLink="false">https://medium.com/p/2777a16dd757</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[directives]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[angularjs]]></category>
            <dc:creator><![CDATA[Kathryn Hodge]]></dc:creator>
            <pubDate>Wed, 02 Aug 2017 11:46:31 GMT</pubDate>
            <atom:updated>2017-08-02T11:46:31.710Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to add an angular directive to simplify your code</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XX0wJjnEBRDB30tPrWz3NQ.jpeg" /></figure><h4>Read the article or watch the video!</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKfZzqKgrrnI%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKfZzqKgrrnI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKfZzqKgrrnI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/eaada395a27a2ef2c2fefd990c965f56/href">https://medium.com/media/eaada395a27a2ef2c2fefd990c965f56/href</a></iframe><p>Angular helps us build <strong>dynamic web applications</strong>, but we haven’t seen all that it can do just yet. Today, we’ll be using a <strong>directive</strong> to help <strong>simplify</strong> our code and make it more <strong>modular</strong>. We will be building off of our To-Do list application from last time so feel free to download the code <a href="https://github.com/blondiebits/code-in-5/tree/master/Basic%20Angular%20in%208">here</a> if you don’t have it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xr6Uyk924lGrcGXO4IzqiQ.png" /></figure><p>Right now, we have a to-do list, but what if we wanted to add a to-buy list? Or even better a <strong>“Books I Need to Buy”</strong> list since school is coming up. We can do this by adding some more code to our <strong>index.html</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZofYJv38pu3l6UBTe0lVSg.jpeg" /></figure><p>These two lists may have <strong>different content</strong>, but the way they are coded will be <strong>very similar</strong> — why write the same code twice? That’s where our <strong>directive</strong> will come in! More on that later, but for now, let’s go to our <strong>MainController</strong> and mess with some code. We’ll change the way our data is stored, add a new variable, and change our <strong>addItem</strong> function a bit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8M0_sYYYVaUrlFRnn3h3wA.jpeg" /></figure><p>Here, we created two new scope attributes called <strong>‘todo’</strong> and <strong>‘books’</strong>. Each of these has its own list property that has an array inside of it. We also changed the <strong>addItem function</strong> so that it has two <strong>parameters</strong> and those parameters are accessed inside of the function. Why change addItem? Well we are going to need to add items to both our to-do list and our books list. Why not use the same function for both? By adding parameters, we can specify what item gets added to what list. This will make more sense in a minute. Going back to our HTML, we <strong>call</strong> our addItem function — however, we don’t call it will any parameters. All we need to do is add our <strong>to-do list</strong> and our <strong>addToDo variable</strong> as <strong>arguments</strong> of the function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JpvAwblsGqe9wGX-iQyoVQ.jpeg" /></figure><p>This may look a little strange, but remember, our actual list is stored inside the <strong>‘todo’ attribute</strong> of the scope. When we click the button, we’ll go to the controller and run the body of the addItem method. <strong>The parameter itemList</strong> will get the value of our <strong>first argument (todo.list)</strong>, item will get the value of <strong>second argument (addToDo)</strong>, and addToDo will be added to todo.list. Now, in our HTML, we can write some code for the list of books we need to buy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ROrIlJ0c4xQpcwDShtd-g.jpeg" /></figure><p>As we said before, the code for the book list and the todo list will look similar, even though the content is different. Looking at our code now, it is a bit <strong>repetitive</strong>. Can we make this more concise? Yes! With directives. <strong>Directives</strong> help us make our code modular and concise and allow us to <strong>bind certain behaviors to HTML elements</strong>. We’ll create a <strong>new folder</strong> called directives inside of our js folder and put two new files inside of it — <strong>singlelist.html</strong> and <strong>singlelist.js</strong>. Starting with the <strong>singlelist.html</strong>, we’ll write some HTML code that will be the <strong>template</strong> for our directive. We will want this code to work for our to-do list and our books list — meaning that each will run this directive to show the contents of their list. This means we are going to need some parameters as they won’t have the same data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CYXUfWmQaR8kzqnuK6GI1A.jpeg" /></figure><p>The code looks pretty similar to what we did in the index.html. We show some kind of title and then iterate through a list. The difference is that first, <strong>we only have to write this code once</strong>, and second, <strong>it’s in a different file</strong> — meaning that not everything is in our index.html. This makes our code more modular. Above, <strong>mylist</strong> is a parameter and its value will change based on what argument we call the directive with. Going to our <strong>singlelist.js</strong> file, we set up the JavaScript portion of our directive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tJndyqSqxmZIx4Snaoqx8g.jpeg" /></figure><p>Here, we name our directive <strong>singlelist</strong> and set up how it will work. We set the value of an <strong>‘mylist’</strong> in our scope and set the <strong>templateUrl</strong> to be the singlelist.html’s file path. Basically, when the directive is called in our view, the argument will be bound to the parameter (mylist), which will be added as an attribute to the scope. Then, with the parameter’s value set in scope, the directive will take the code in our templateUrl and insert it into wherever the directive was called. All we need to do now is <strong>import this directive</strong> and call it in our HTML code. To import the directive, we’ll write…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D7wwLIekxRDvE5Dp1vNilQ.jpeg" /></figure><p>Next, we call it in our <strong>index.html</strong> so that it will actually impact our webpage. Right now, the code for our directive is written, but it isn’t being used in our living breathing webpage — our view — our index.html. To do this, we’ll delete some of our previous code and write…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5P69_GBgtGND86fYopGjmg.jpeg" /></figure><p>Notice, we use the <strong>same directive</strong> for both lists. Here, <strong>‘mylist’</strong> is a parameter that will hold the relevant data (‘todo’ or ‘books’) for a given list. In the first call, <strong>‘todo’ is the directive’s argument</strong> and in the second call, <strong>‘books’ is the argument</strong>. Right now, the ‘todo’ and ‘books’ objects in scope only have a list inside of them, but we could add more data, such as a title, to beef up these objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mcOlvaoH2cV6--mjZqAhBA.jpeg" /></figure><p>Now, when we <strong>retrieve the title</strong> from ‘mylist’ in the directive’s template (singleList.html), we will get the actual title. So if we open the webpage…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xWj53n2_TK4G8GtxSAN5KA.png" /></figure><p>We have some <strong>security issues</strong>. We can fix this by using a module called <strong>http-server</strong>. To do this, we’ll open the terminal, navigate to our folder with the <strong>cd command</strong>, and use npm to get our module. If you don’t have <strong>npm</strong>, you can download it <a href="https://coolestguidesontheplanet.com/installing-node-js-on-osx-10-10-yosemite/">here.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YClkzXF0rLCHcFBzJCX9fg.jpeg" /></figure><p>Now that we have the module, we can go ahead and write <strong>http-server</strong> in our command line and access our webpage. Make sure you are in the folder with the index.html when you run this command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JCo9jZU1a4mhUGCRdO2YrA.jpeg" /></figure><p>Opening the webpage, now we have our items and our code looks awesome and efficient!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zvmevckfoby8HNlO7IAWAA.png" /></figure><p>Let’s think about how we did this. First, we had our index.html, which is like the <strong>headquarters</strong> of our code. We wrote some code and then <strong>added angular</strong> by <strong>linking</strong> it in the index.html, <strong>initializing a module</strong> in the app.js file, and then <strong>creating a controller</strong> that would handle our data. We set the <strong>ng-app</strong> and <strong>ng-controller</strong> attributes in the index.html and then <strong>set data in the scope</strong> from the controller file that would eventually be accessed in the view — our index.html. When we saw our code was repetitive, we added a <strong>directive</strong> that would allow us to <strong>use the same block of HTML code in different places</strong>. We <strong>called</strong> the directive from the index.html, the parameter got the value of the argument in <strong>singlelist.js</strong>, and the code from the <strong>template</strong> (singlelist.html) was run and <strong>inserted</strong> into the index.html document.</p><p>So far, our code is short and sweet and does everything we want it to do.We have our two lists, one for to-do’s and another for books. However, professors often only post the ISBN number for required books, which means nothing if the user can’t convert the number to a title. <strong>What if when we added an ISBN number to our books list, it changed into a little blurb with the title and author?</strong> That’s what we’ll do next week with the <strong>Google Books API</strong>. See ya then!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*cEc1r0sGMjx0iZRrstevOA.png" /></figure><h4>Things to Remember:</h4><pre>&lt;!-- Create a Function with Parameters --&gt;<br>$scope.myfunction = function(n, m) {<br>  		return n * m;<br>}</pre><pre>&lt;!-- How to Call a Function with Arguments --&gt;<br>myfunction(5, 10);</pre><pre>&lt;!-- Create a Directive JS File --&gt;<br>app.directive(&#39;nameofdirective&#39;, function() {<br>	return {<br>		restrict: &#39;E&#39;,<br>		scope: {<br>			paramone:&#39;=&#39;<br>		},<br>		templateUrl: &#39;js/directives/templateName.html&#39;<br>	}<br>})</pre><pre>&lt;!-- How to Call a Directive with Parameters&lt;<br>&lt;nameofdirective paramone=&quot;dataVariableNameFromScope&quot;&gt;&lt;/nameofdirective&gt;</pre><h4>Plus a Little Extra:</h4><pre>&lt;!-- What restrict = &#39;E&#39; means? --&gt;<br>It means we can only invoke the directive through elements <br>(instead of through attributes or something else). This <br>makes it so all of our code invokes this attribute in <br>the same way. </pre><pre>&lt;!-- How to Call a Directive without Parameter --&gt;<br>&lt;mydirective&gt;&lt;/mydirective&gt;</pre><pre>&lt;!-- Parameters VS Arguments --&gt;<br>The formal parameter is what&#39;s given in the function <br>declaration/definition where as the actual argument is <br>what&#39;s passed when calling the function.</pre><pre>&lt;!-- What is http-server? --&gt;<br>Http-server creates a web server that responds to requests <br>from web browsers and serves up local files.</pre><pre>&lt;!-- More Tutorials About Command Line? --&gt;<br>Check out more terminal tutorials on my YouTube Channel!<br>http://bit.ly/1ZD8CcG</pre><p><a href="http://www.github.com/blondiebits/code-in-5">Code</a> from this blog post</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2777a16dd757" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use a JavaScript Library: jQuery]]></title>
            <link>https://medium.com/front-end-weekly/how-to-use-a-javascript-library-jquery-75d0b6d50b5a?source=rss-df76b57e5595------2</link>
            <guid isPermaLink="false">https://medium.com/p/75d0b6d50b5a</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[jquery]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Kathryn Hodge]]></dc:creator>
            <pubDate>Tue, 25 Jul 2017 15:21:52 GMT</pubDate>
            <atom:updated>2017-08-07T16:32:07.022Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to dynamically change a website with the jQuery library</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*48rEiGiAu9QbjcdpR_mDKw.jpeg" /></figure><h4>Read the article or watch the video!</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJjIvF0yikGU%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJjIvF0yikGU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJjIvF0yikGU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5593d164ceecc1051f930b7442e7ea7/href">https://medium.com/media/d5593d164ceecc1051f930b7442e7ea7/href</a></iframe><p><strong>JQuery</strong> is a <strong>library</strong> that contains lots of methods which make it much easier to manipulate HTML documents, add animation, along with a bunch of other things. Since JQuery is a library, it has an <strong>API</strong> that we can use to access its functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mrnNjezpE3Dsfulf_W7yjA.png" /></figure><p>API stands for <strong>Application Programming Interface</strong> and it basically states the methods or functions we can call inside our code if we import the library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EpNKOgwUcdcvxkMbn3YTNg.png" /></figure><p>Let’s click on <strong>.addClass()</strong> method and see what it does.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s5s_3aCY2jUAIGO5VJKiUw.png" /></figure><p>Say we had a class named <strong>blue</strong> that made its elements have blue text. We could use the .addClass() method and add the blue class to all of the <strong>p</strong> elements with something similar to this where we’d have <strong>$(“p”).addClass(“blue”)</strong>. This may be confusing right now, but don’t worry, we’ll figure it out.</p><p>To start, we first need to create an <strong>index.html</strong> and a <strong>script.js</strong> file. We’ll also put the script.js file in a folder named <strong>js</strong> and then <strong>link</strong> our script.js file in our index.html file. This should look pretty familiar since we’ve done it in <a href="http://blondiebits.herokuapp.com/#/4">other tutorials</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_-K73A4yBj1Vo6eFoQbLA.png" /></figure><p>Just like we imported bootstrap in the <a href="http://blondiebits.herokuapp.com/#/2">bootstrap tutorial</a>, we need to <strong>import jQuery</strong> in this post. We can either download it from the Internet and link it locally or we can link it from the Internet. We’ll do the second and after searching for the jQuery <a href="http://www.webopedia.com/TERM/C/CDN.html">CDN</a>, we’ll add it to our code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cZ9Y1bRiseVc53YxLECooA.png" /></figure><p>Make sure to add it <strong>above</strong> the our script.js link because we will need to use jQuery in this file. With our jQuery in place, we’ll add one line of HTML code, a header. We’ll add some <strong>styling</strong> that puts it in the center of the page and gives it a white text color. We can also give it the <strong>id hidden</strong> and the header will say “I was hidden!”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UUnPz_WIPXaDaTfj7jwxQg.png" /></figure><p>Now, when we refresh the page, we’ll see that the header text is there, but we can’t see it unless we highlight it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TsSl3NcmjeIhuWE68c45tw.png" /></figure><p>With jQuery and CSS, we could make it so that when we hover over it, the text of the header becomes black. To do this, we’ll go into our <strong>script.js</strong> file and write some code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FgM37ubZyNE-BSciFdSIDg.png" /></figure><p>Here, the <strong>ready function</strong> makes sure that the <a href="https://www.w3.org/DOM/">DOM</a> (for now, our HTML elements) have loaded. Once they are loaded, we <strong>select</strong> our element with the hidden id and call the <strong>hover function</strong> on it. This means when we over hover the element, the function on lines 2–4 will be run. The function will select <strong>“this”</strong> element (the element with the id hidden) and in the element’s CSS, the <strong>color property</strong> will be set to the <strong>value black</strong>. You could do this for any element, ID, or class and set any property to any value. Next, we have the <strong>callback function</strong> on lines 5–6 and this is something you have to write out even if you don’t use it. We will leave it empty for now and come back to it later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UEwckFVnaYn3RUvE4Q6nNA.png" /></figure><p>Now, when we refresh the page and hover over the header, the text turns black. However, when we stop hovering over the header, the text remains black. What if we want to <strong>“re-hide”</strong> our message after hovering over it? Going back to the code we can implement our callback function. This will be called once we <strong>“leave”</strong> or stop hovering over our header, the element with the ID hidden. Let’s add some more code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IObF5MVw2w8EnORBgVxQcQ.png" /></figure><p>Here, we select “this” element again, which is the element with the ID hidden, and hide it from the viewer. This function as with the .css, .hover, and .ready function are built into the jQuery library so <strong>we don’t need to worry about how they are implemented</strong>. We just need to know the end result. Here, the <strong>hide function</strong> hides “this” element on the webpages. Essentially, this just sets the <strong>display property</strong> of “this” element to none, but using .hide() makes the code a bit more concise. Let’s see what happens when we refresh the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pb9888jHIiAQF_Rl-oSNcw.png" /></figure><p>We hover over the header and leave it. After, the header element is gone — even when we try highlighting it, it cannot be found. With this program, we hid a message in plain sight, displayed the message while the mouse was pointed on it, and then made it disappear when the mouse left it.</p><p>For another quick example, we’ll add a <strong>button</strong> back in our HTML and make it so an alert shows up on the page when we click the button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O-DDUKlMn7I7I5yzFZ8vdw.png" /></figure><p>Now, we’ll write the JavaScript using the jQuery library to make the button <strong>interactive</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LGf59OjpApo6RJcxSCjDQg.png" /></figure><p>Here, we <strong>select</strong> all the buttons on the page and when one is <strong>clicked</strong>, we run the function. The function uses the <strong>alert method</strong> (built into HTML) to alert the user on screen with the message “I’m alerting you!”. Going back to our webpage, we’ll refresh and see what our alert looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yRG64R-VtU0x4cjfiSaWkg.png" /></figure><p>And there’s our alert! Could we have done this with <strong>plain vanilla JavaScript</strong>? Yes, but using the <strong>jQuery library</strong> makes a lot of this much <strong>easier</strong> to code and easier to read later on. Next week, we’ll talk about <strong>angular.js</strong>, which is a structural JavaScript <strong>framework</strong> that helps you build dynamic web apps. For the first time in the series, we won’t be hard-coding our content — but we will be getting it from somewhere else. I hope you learned something in this week’s post and I’ll see you next time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*qwW536U6ct9ZkbCWT3xcow.png" /></figure><h4>Things to Remember:</h4><pre>&lt;!-- How to Import jQuery --&gt;<br>&lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js&quot;&gt;&lt;/script&gt;</pre><pre>&lt;!-- How to Use a jQuery Method --&gt;<br> $(&quot;button&quot;).click(function() {<br>	// what you want to do when button clicked<br>});</pre><pre>&lt;!-- How to Create a Callback Function --&gt;<br>$(document).ready(function(){<br>    $(&quot;#idName&quot;).hover(function(){<br>      // do this when we hover over the element with id idName<br>    },<br>  function(){ // <br>  	  // body of a callback function<br>  	  // do this when we stop hovering over the element with id idName<br>    });<br>});</pre><pre>&lt;!-- How to Dynamically Set CSS in jQuery --&gt;<br>$(p).css(&quot;font-style&quot;, &quot;italic&quot;);<br>$(#hidden).css(&quot;display&quot;, &quot;none&quot;);</pre><h4>Plus a Little Extra:</h4><pre>&lt;!-- How to Select a Class in jQuery --&gt;<br>$(&quot;.className&quot;).fadeIn();</pre><pre>&lt;!-- How to Animate Text --&gt;<br>$(&quot;p&quot;).animate({left: &#39;250px&#39;});<br>// this uses animation to move all of the p elements left by 250px</pre><pre>&lt;!-- Reveal Text After Some Time --&gt;<br> $(&quot;p&quot;).show(1000);</pre><pre>&lt;!-- Modify Input Fields --&gt;<br>$(&quot;input&quot;).focus(function(){<br>    // do this when user clicks the input field<br>});<br>$(&quot;input&quot;).blur(function(){<br>  // do this when input field is not clicked<br>});</pre><p><a href="http://www.github.com/blondiebits/code-in-5">Code</a> from this blog post</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75d0b6d50b5a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/how-to-use-a-javascript-library-jquery-75d0b6d50b5a">How to Use a JavaScript Library: jQuery</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn the Basics of Angular.js]]></title>
            <link>https://medium.com/@blondiebytes/learn-the-basics-of-angular-js-17523690594e?source=rss-df76b57e5595------2</link>
            <guid isPermaLink="false">https://medium.com/p/17523690594e</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Kathryn Hodge]]></dc:creator>
            <pubDate>Thu, 20 Jul 2017 20:11:48 GMT</pubDate>
            <atom:updated>2017-07-20T20:11:48.584Z</atom:updated>
            <content:encoded><![CDATA[<h4>Create your first Angular.js application in this tutorial. Learn about controllers, scope, and more!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JUO493cjSvwF2arLZpsuLA.jpeg" /></figure><h4>Read the article or watch the video!</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fl23KYiM5Se0%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dl23KYiM5Se0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fl23KYiM5Se0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0c91e92981f6294cdcbe898a45c6d36/href">https://medium.com/media/b0c91e92981f6294cdcbe898a45c6d36/href</a></iframe><p><strong>Angular.js</strong> is a <strong>structural framework</strong> for dynamic web apps. If that is confusing, don’t worry! Basically, it means we can extend HTML’s syntax to express an application’s components more fully. To start, we’ll create an <strong>index.html</strong> document and a <strong>js folder</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BwWMnBvpKFpTvgDZdVv8Pw.png" /></figure><p>Next, we’ll import the Angular.js framework just like we did for Bootstrap and jQuery. For this tutorial, we will be using <strong>Angular 1</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XsfOFV1WPmj-ECp9ZW6odw.png" /></figure><p>In this tutorial, we’ll be making a <strong>to-do list application</strong>. To do this, we’ll make an <strong>app.js</strong> file inside of our js folder and write a line of code that <strong>initializes</strong> our app (also called <strong>module</strong>) for us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x6df66M2E0YCBg33oTZRNA.png" /></figure><p>To connect our app.js file to the HTML code, we’ll <strong>link</strong> it over in our index.html. Usually, we put this type of import towards the end of the body.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RPHOecFmYElZBaPNHegUMw.png" /></figure><p>Although our app.js is imported, there’s still more to do (no pun intended). We need to connect our ToDoList module to our HTML code. To do this, we’ll write <strong>ng-app=”ToDoList”</strong> as an <strong>attribute</strong> of the body. This states that everything in the body will be a part of the ToDoList application. Furthermore, this attribute is called an <strong>angular attribute</strong> because it is part of angular and not plain html.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JM8wg9fFLa5UefllVw-lSw.png" /></figure><p>Next, we’ll create our <strong>controller</strong>, which will handle the data for our application. To do this, we’ll make a <strong>controllers folder</strong> inside of our js folder and add a <strong>MainController.js</strong> file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yt0YmjnpfoGyoMk9KSf34g.png" /></figure><p>Now, we can write some code for our <strong>MainController</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7zeft2Cqq5OlSTqrN_cFA.png" /></figure><p>Just like most of our files, we’ll <strong>import</strong> this into our index.html and put it right before the <strong>closing body tag</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dq5FRlE_d1jxJciYTXmP2w.png" /></figure><p>Now, going back to the MainController, we can <strong>set</strong> some values in the <strong>scope object</strong>. For now, we can think of the scope object as something everything in our program can talk to. The <strong>view</strong> aka our index.html can <strong>see what’s in the scope</strong> and our <strong>controller</strong> can <strong>set what’s in the scope</strong>. This is how the two files communicate and can pass information to and from each other — through the scope object! Thinking in this way, we’ll write some “to-do list” items and put them in the scope of our controller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J6PyQCn8IkAdI6jQ0JFgGg.png" /></figure><p>Here, we added a <strong>list attribute</strong> to the scope and set the value of this attribute to an array containing “Clean my room”, “Go to the store”, and “Study Cracking the Coding Interview”. Now, how does our view (our index.html) know about this controller? Sure, the file is imported, but there’s one other thing we have to do. We need to attach it to an element in the HTML code. We’ll attach it by creating a div, accessing its ng-controller controller attribute, and giving it the value “MainController.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7N8fPniuS963LMBhWcqJfg.png" /></figure><p>To <strong>access</strong> the to-do list items in <strong>scope</strong>, we can write some more code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NVN0WGm_zz77mTMybkKEww.png" /></figure><p>The <strong>curly braces</strong> are called <strong>handlebars</strong> and they note that these items are coming from the scope object. Without them, our list items would have the literal text list[0], list[1] instead of our actual to-do list items. Refreshing the page, we see the items in our list!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IAnSTi8x3DKjAX0EhWSZPQ.png" /></figure><p>However, looking back at our code, this is somewhat <strong>inefficient</strong> and only works if we have exactly three items in the list. Instead, we can use an <strong>angular directive</strong> called <strong>ng-repeat</strong> to iterate through the items in the list. We’ll learn more about directives later, but for now, just think of them as a tool that helps make our code more modular and concise. We’ll create another div and add <strong>ng-repeat</strong> as an attribute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6fz44IAFaoIV2JfjshBXkQ.png" /></figure><p>Here, we name each thing in the list an <strong>item</strong> and <strong>for each item</strong>, we put it in a <strong>li tag</strong>. Again, we are accessing the <strong>list attribute</strong> from the <strong>scope object</strong>, which was set in the <strong>controller</strong>. The list attribute has the <strong>value of an array</strong> that has our to-do’s inside of it. We use the <strong>ng-repeat directive</strong> to go through the items and put each in their own li tag.</p><p>One last thing before we go! We can also add an <strong>input field</strong> in our HTML so we can add things to our to-do list from the webpage. To do this, we’ll write some more code in our index.html.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qT44fUmcF3jNiVxlZnQmfQ.png" /></figure><p>This creates an <strong>input field</strong> and <strong>ng-model</strong> (another angular directive) binds the input to the <strong>variable addToDo</strong>. This addToDo is an <strong>attribute</strong> of the <strong>controller’s scope</strong> object so it can be accessed again in the index.html file and in the MainController. We’ll also create a <strong>button</strong> so when the button is pressed, the item in the input is added to the list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M9jDNey2OiWi4jwlDKNJKg.png" /></figure><p>When we click the button, the <strong>addItem()</strong> function will be run — but this function doesn’t exist yet! Going back to our MainController.js, we’ll add some more code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uD0ZRW_RnXESs_M_M2zHKg.png" /></figure><p>Here, we add a new <strong>attribute</strong> to our scope, <strong>addItem</strong>, and give it the value of a <strong>function</strong>. Inside the function, we access our list and push on the addToDo variable, which has the value of the input field from the index.html. Now, if we refresh our page and try to add a to-do… we can!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LMaYbtPIULOUKCJMbl_Yng.png" /></figure><p>However, when we refresh the page, our added data will disappear because we haven’t saved it anywhere. Something to think about. In next week’s tutorial, we’ll talk more about <strong>angular.js</strong> and go into directives, services, routing, and accessing an endpoint from your code! See you next time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*IHp95dpQv1vwHudPycAV3A.png" /></figure><h4>Things to Remember:</h4><pre>&lt;!-- How to Import Angular.js --&gt;<br>&lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js&quot;&gt;&lt;/script&gt;</pre><pre>&lt;!-- How to How to Initialize a Module --&gt;<br>var app = angular.module(&#39;ModuleName&#39;, []);</pre><pre>&lt;!-- How to Create a Controller --&gt;<br>app.controller(&#39;ControllerName&#39;, [&#39;$scope&#39;, function($scope) { <br>  	$scope.text = &quot;Value for Text Attribute in Scope&quot;<br>  	$scope.method = function() { <br>  	/* body of function */ }<br>}]);</pre><pre>&lt;!-- What You Need To Import --&gt;<br>1. angular framework<br>2. app.js (modules)<br>3. controller files</pre><pre>&lt;!-- What You Need To Attach in index.html --&gt;<br>1. application with ng-app<br>2. controller with ng-controller</pre><h4>Some Built-in Directives:</h4><pre>&lt;!-- ng-repeat --&gt;<br>// loop through a collection / array<br>&lt;div ng-repeat= &quot;color in colors&quot;&gt;<br>	&lt;li&gt; &quot;&quot;color&quot;&quot; &lt;/li&gt; // except with handlebars instead of quotes<br>&lt;/div&gt;</pre><pre>&lt;!-- ng-click --&gt;<br>// execute a method or expression when element is clicked<br>&lt;button ng-click=&quot;changeBackgroundColor()&quot;&gt;&lt;/button&gt;</pre><pre>&lt;!-- ng-src --&gt;<br>// use angular to set a source path for an image<br>&lt;img ng-src=&quot;http://www.myblog.com/article/images/&quot;&gt;</pre><pre>&lt;!-- ng-href --&gt;<br>// use angular to set the source for a link<br>&lt;a ng-href=&quot;http://www.myblog.com/article&quot;&gt;click here!&lt;/a&gt;   </pre><pre>&lt;!-- ng-model --&gt;<br>// bind input elements to scope attributes<br>&lt;input ng-model=&quot;name&quot;&gt;&lt;/input&gt;</pre><p><a href="http://www.github.com/blondiebits/code-in-5">Code</a> from this blog post</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17523690594e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>