The Little Owl Programmer

I am a teacher, teaching myself to code. Oh, and I like owls.

Old School - a Nod to the Tutorial That Taught Me HTML

As I am going back and attempting to help my blog catch up to my skills I gained this past year, I suddenly felt obligated to give a small nod to the original reason I wanted to build web applications in the first place. It’s a little embaressing to be honest, but it’s the truth and I felt a relatively cute story so I wanted to share.

When I was 11 (so 2001), I was very much into Neopets. When you created one of your own virtual pets, the pet got it’s own webpage. The purpose of that webpage was you could put stories up, picture’s you’ve drawn, and tell the whole world how awesome your pet was. I being 11, thought this was a very important aspect of my virtual pets fake life and felt very strongly about giving her the best website ever. To edit their page, at the time required HTML knowledge and Neopets conviently provided a full HTML 101 Tutorial. Though this tutorial, looking at it now, it is extremely outdated, but if you were completely new to HTML I would still reccomend it as it covers the basics. Though I’ll admit, I am bit bias, and also not really an expert on HTML for Beginner Tutorials anymore.

Neopets HTML Tutorial

Also, out of embaressment, my pet’s pages will not be disclosed, but there are definitly maquee’s and glitter gifs and it screamed early 2000 web design.

Tabby

This past year I began a job at a company where I currently work from home and teach math. I must say, the commute is significantly better then my old job. The 4 feet from my bed to my desk is much more enjoyable then my 40 minute drive to Towson. Regardless, I love my job very much as I mentioned before because of the amount of time I now have outside of work to focus on programming.

Now, not to get too much into the details of my company and how it works, I will say I developed Tabby out of my own personal need for a new project. Tabby, is a small web application that pulls data from a spreadsheet and updates it in real time. It changes the title of the webpage, to whatever the contents of the cell are and thus it changes what is in the tab. This is extremely useful when you have some small data you want to keep updated on but don’t want to open another window to see it. I could see it being very useful for people who work in stocks, or anything piece of data that changes over the course of the day.

Tabby provided me with a lot of knowledge and was the springboard into my current projects. For Tabby I learned Javascript, much to the glee of my inner twelve year old who spent far too much time trying to learn it. I also learned JSON which is, in the most basic terms, a fancy javascript dictionary with key/value pairings.

As I am a bit new on the rules of programming and companies using stuff I created/ownership, so I will not be disclousing source code at this time.

I will provide a screencase of if it in action though.

Udacity: The Belated Review

Udacity

I started this blog as a way to combine my two loves, education and programming. I spent several posts reviewing useful tools and classes to help anyone learn how to program. The one post I never wrote, but always meant to was the review on the one course the literally taught me all of my basics on programming skills.

Udacity Computer Science Course

I can not even begin to talk about how much I love this course. At the time it was free, and now costs several hundred dollars to take which I believe prove it’s quality! They had visuals, they had audio, they have several puzzles/drills after each lesson so you could apply the content you just learned versus one singlar problem as with most tutorials. There were tests, quizzes, and I honestly felt like I was in a classroom. The content was laid out and well organized and thought out.

The whole course is designed to teach you to build a functioning search engine. Each completed chapter you add a new aspect to the search engine and everything slowly builds upon each other. For example during the first part they teach you had to parse through strings, and in the second chapter you learn how to use loops and then apply the parsing you learned in the first chapter to parse through some HTML to find paticular strings. They go over the history of programming, and at one point you go a virtual field to google! If you have 2 weeks, do the free trial full time, and complete it. You will learn so much and feel confident when you are done.

In a Years Time

I must say a lot has happened in the year and half since I last updated this blog. The biggest thing was I got a job teaching math and science, when I was not certified nor taken a class in either of those since high school. So I spent the 2013-2014 school year working the normal 60 hour first year teacher hours on top of spending all of my spare time teaching myself algebra 1, algebra 2, pre-calc, physics, and chemistry.

Over this nine month period my coding experience was limited to small projects, or mostly just maintaining what I had learned through puzzles and drills.

In the summer of 2014, I set my eyes north and started looking for new jobs in Pittsburgh and found one. I currently work as an online math teacher which is amazing as I finally have something called “spare time”.

With this spare time I was able to dive back into teaching myself to code regularly, usually an hour before work, an hour during my break, and then an hour or so after work depending on how I am feeling.

In the past couple months since I have had this new time I have learned a lot. I finally completely understand git and github(I honestly have no idea why I struggled with it before). I have also taught myself javascript, jquery, ruby, a little bit of Flask (a python webframework), and am currently working on learning rails.

The largest accomplishment in all of these past months is I developed a web application that all of my co-workers now use daily. I have affectionally named it Tabby and it pulls information from a spreadsheet and changes the title of a webpage to the contents of an assigned cell. When the web page title changes, the strings inside of the tab also change. It’s useful to use when you need want to see small bits of changing information and don’t need to travel to a different page to see it.

The fact people are actually using something I wrote, has deeply isnpired me to delve back into teaching myself to program but with a focus on web applications.

Octopress and My New Blog

Welcome to the brand spankin new “The Little Owl Programmer”. I am currently blogging with Octopress on my own site powered by Github pages! How exciting is that? I feel pretty proud of myself, I must confess, considering my experience with using the command line and git were pretty much that of 0 and I did it with (okay almost) no help from my own personal Python tutor!

You may be asking yourself “Why Anne, but I am new to all of this. What exactly is Octopress!?”

I am so glad you asked! And using my awesome teacher explination powers, I shall explain what it is, and more importantly, why it’s awesome!

Think of it this way. With github pages you basically get a wonderful free place to put your website. You can upload a file called index.html and type out all of your html and have it reference a css.css file. Now if you want to create a blog on that site it’s kind of a pain, especially if you are like me who has a pretty solid knowledge of HTML and CSS but once we hit anything outside of it (using Javascript to help make a site better or something else along those lines) you kind of go “Umm…huh!?”

Octopress is a blog GENERATOR. So it does all of that work for you. All I have to do is type “rake new_post [“title name”] in my command line under the Octopress folder, and BAM. I open up the my post folder and there is a blank txt file with all of the backend stuff done for you.

Hehehehehe! I am as giddy as a school girl with just how awesome octopress is. Granted it’s not for everyone. I did have to spend an entire day just trying to get it up and working (mostly because of my lack of experience with Git) and you do need to learn how to use some basic command line. But, if I can pick it up in a day, I am sure you can too!

Useful Links (including the tutorials I wished I had found first):

Octopress Site — Start here for installation. I reccomend you completely start from the beginning. If you already have a .io site. Delete it. It may not be nessecary but I personally had a lot of trouble until I followed these directions EXACTLY. But I am also a newbie, so you may have better luck then I do.

Instructions for Creating Posts — I personally had a hard time getting Octopress to work because of my inexperience with git. If you look at this guys instructions for creating posts, it helps a lot. Lots of times, Octopress and other “hard” programmer related instructions lack basic instructions because they assume you know things. These instructions are what saved me.

Print to Files: The File Series

Now that you can open and close a file in python, I’m sure you want to print your text.

Step 2: Printing Your File

To print your file you need to use the .read( ) command on your file. Think of this way, your computer is a person and your file is a book. To get your computer to spit out your file back to you, the following things must happen.

To open the book Have your computer read the book (opening the file was merely your computer opening the book, now it actually needs to READ it) Have your computer re-iterate the book back to you (or print it on the screen). So to do this you need the command

print f.read ( ) or

print f.readline () Note Inside of the paranthesis you have the option of putting the number of bytes your computer reads from the file. This is not lines, characters, but BYTES. Since we are working (or well I am working) with such smile file sizes, lets ignore this option for now and leave it blanks.

Now looking at these two commands they actually do two very different things. Can you guess what?

the .read( ) reads the ENTIRE file (unless you would tell it otherwise with the btyes paramator)

while the .readline reads EACH line. So if you had a 4 line text file, and you called upon it once, it would print the first line. If you called upon it twice, it would print line 1 and then line 2.

Exercises

For these excercises I would like you to go back to your text file and make sure it is at least 3 lines long.

.Read() Excercises

Guess what you think will happen when you run each of the following code. Then run them yourself to see the answer.

In the FileTest.Py try typing this out

1)

f=open('link to test.txt')
print f.read ( )
f.close

2)

f=open('link to test.txt')
    print f.read ( )
    f.close
    print f.read ( )

3) with open(‘link to test.text’) as f: print f.read() print f.read() 4)


with open('link to test.txt') as f:
    print f.read()

.readline Excercises

1)


f=open('path to test.txt')
print f.readline( )
print f.readline()
f.close

2)


f=open('path to test.txt')
print f.readline( )
f.close

3)


with open('link to test.text') as f:
print f.readline()


4)


with open('link to test.text') as f:
print f.read()

5)


with open('link to test.text') as f:
print f.read()
print f.read()

6)


f=open('path to test.txt')
print f.readline( )
print f.readline()
print f.readline()
print f.readline()
f.close

7)


f=open('path to test.txt')
print f.readline( )

Some Questions to Think About

Some of these received errors.

What was the error? Why did you receive the error? Why did some of these not receive errors? How is this relevant to what we’ve talked about in previous posts? When you didn’t receive an error what happened? What happened when you ran f.readline() more times then the actual number of lines you had? What happened when you didn’t close the file? Did it still run? Is this a good practice to not close the file?

Opening and Closing Files: The File Series

The latest thing I have learned in Python is how to edit a text file. So, because I am an educator and also the best way to learn something is to teach it, I am going to create a series of posts that instruct you how to edit text files in python as well. These posts will be broken down to the most minimal of steps, the reason being, my biggest issue so far with “learn how to python” sites is they really don’t do this (but that is another post).

First you need to open the text file and set it in a certain “mode”. These modes we will get to in a later post. For now, lets just open and close text files.

Step 1: Opening and Closing Text File

You can open a text file in various ways. The first is the “with open” command.

The “with open” command opens a text file, and then everything indented after it, will be code that can play with the file. Once you leave that block, the file will close. This is nice because it closes the file for you.

with open(‘path to text file”,“mode you are in) as variable you are storing the text file in: code that does stuff with the text file. the text file is open the text file is STILL open code (and not the text file is closed or for example

    with open(’/home/civetta/code/address.txt') as f:
        print "The file is OPEN” #The file is open
        print “The file is STILL open” #The file is open
        if 1+1=2: #the file is open
            print “The file is STILL OPEN cause I am still inside the block #the file is open
    print "Thanks!” #The file is CLOSED because it is outside the above block
You can open it another way with the command: f=open(‘path to file’,‘mode’) However with this way you HAVE to have another command to close it that says: f.close()

However, unlike the other one, this one doesn’t care if it’s outside or inside a block for example.

    f=open(‘/home/civetta/code/address.txt’)
    print “Hello the file is open” #the file is OPEN
    if 1+1=2: #the file is OPEN
        print “Still open” #the file is OPEN
    f.close( )#the file is now CLOSED
    print “Thanks!” #The file is CLOSED 
Here is a great quote from another Python site I’ve discovered recently that explains the purpose and importance of opening and closing a file. “Working with files is a lot like working with a notebook. To use a notebook, it has to be opened. When done, it has to be closed. While the notebook is open, it can either be read from or written to. In either case, the notebook holder knows where they are. They can read the whole notebook in its natural order or they can skip around.” Open Book Project

Exercises

Here are some exercises for you guys to try it out.

Create a .txt file, name it test.txt, here type out whatever you like. Create a .py file, name is “FileTest.py” Copy and past the following code

f=open(‘link to test.txt’) print f f.close print f

Run it in your command line (change directories to the folder your .py file is in. Then type “python FileTest.py”)

Now try it again, but this time type out this code underneath FileTest.py

with open(‘path to text.txt) as f:
    print f
print f
Some Questions to Think About

What do you see? What did you expect to see?

The Importance of Practice When Learning to Program – CodingBat

Currently, I am going back and reviewing some of the basic material I have learned in Python. I feel as if I have reached a point of basic proficiency and want to solidify my own knowledge base before going further. In addition, I am also using this as an opportunity to review various online courses that teach python. And the one thing I am finding all of these classes lack, is an ample amount of practice problems to apply the knowledge they have taught you. Sure, they’ll offer one or two, but once you complete them, you are pushed on to the next concept. Thus, in my journey to learn Python, I took a break from actual classes online to complete multiple practice problems.

As anyone who has learned a new language (or most subjects really) before knows, practice is what gives the concepts “stickeyness”. With practice it will be second nature to know that when indexing strings you start at 0 versus 1. Or when you have a while loop, and you are looking for a final product out of that loop, make sure the return is outside of the loop versus inside, otherwise it’ll only run once. In other words, it’s good to complete multiple practice problems when you are first starting because you’ll get out of the habit of making beginner mistakes.

My favorite “practice problem site” for beginners that I found was CodingBat. They provide you with a problem and an in-browser interpreter. You click “go” and it shows you on the right a table with various inputs it ran through your program, the expected output, your output, and if it is wrong or right. For the first few sets of problems they even provide you with an answer! There are 72 problems total, and split it up into categories (Lists, Strings, Booleans) and then levels of sorts (string problems with loops, string problems without loops, etc).

I highly suggest you check it out if you are a beginner like me . Because of that site, I feel significantly more prepared to continue on in my journey to learn Python!

Links In this Blog Post: [www.codybat.com “CodingBat Python” ]

Python Tutor and Immediate Feedback

The hardest part of learning to code is often times, it doesn’t give you immediate feedback. There is no scaffolding, there are no clues. All you get is an error and no matter how often you look up what it means, it still doesn’t make sense. Where did I go wrong? Why isn’t this working? Do I really want to punch through my computer screen right now because I am so frustrated? (The answer is often yes).

Yesterday, I was very lucky to discover a tool that can solve all of these problems. Pythontutor shows you exactly what is going on in your code as it runs. It’ll tell you when it’s adding items to a list, and go through every step of a while loop, using arrows and labels telling you exactly what’s going on.

It also has the very neat capability of sending code to other people who can also go through it step by step!

For example here is a piece I wrote for a Udacity quiz where I had to add a keyword and corresponding keyword to an index. If that keyword already existed in the index, then I would just add the url to the already existing keyword.

Check it out, it’s best if you see it yourself rather then me explain it.

Links Mentioned in This Post: [Python Tutor] (www.pythontutor.com)

What Makes a Good Online Course

As an education major and someone who has taught professionally ) I am kind of a stickler when it comes to education. I can be really critical of online education sites and am able to look at them as someone who has taken years of education classes. So when I decided to teach myself code this summer, I was a bit hesitant about which site to choose to tackle this project. I knew of several courses and have tried several in the past, and I have found each course has their own strengths and weaknesses.

First, for you non-education majors out there, let me state, a good education site should be similar to a good classroom in the sense that they provide some if not all of the following things. (While there are a LOT of attributes to a good classroom, the following are what I feel are, the most important in an online setting)

Scaffolding: A fancy teacher term that means kind of what it sounds like. Scaffolding is the ability to give learners what they need to accomplish goals on their own. Aka, it’s hint giving. It’s the ability to guide students in the right direction without giving them answers.

Multiple Types of Learners: It is difficult to address all of the three types of learners in an online format (With the three types being audio, visual, and tactile). However, a decent online course does attempt it which prevents the course from being too boring and leaning towards one learning type . If you are unsure of your own learning type, I suggest you take the time to take this quiz here. Learning types are a scientifically backed and may make your own learning easier.

Direct Learning: The direct instruction model lesson plan goes along the lines of this, the teacher to goes through how to solve a problem completely, then allows students to solve part of the problem through guided learning, and then gives students a problem and has them solve it completely on their own.

Indirect Learning: This is extremely vital because programming is one of those things that requires learning by doing. One of the best ways is to provide students with the tools they need (so how to assign a variable, a while loop,etc) and give them a problem to solve with those said tools.

Immediate Feedback: A dire trait of any good teacher is the ability to give immediate feedback to their students. This can vary in the online environment to a few seconds to a few days depending on if it’s a “live” classroom like an e-mail course or a blackboard course. Or you are doing it through videos and preset program and tutorials.

Creating Purpose: Creating/acknowledging purpose is the ability to answer “why” you are learning what you are learning. Every step of the way a good tutorial explains this, often times with examples. Several courses I have seen have made this easy, but creating “project oriented lessons” meaning there is one big project you are building towards and everything you are learning is aiming towards that goal.

Over the next couple of days I will be reviewing and rating several online courses using these elements as criteria, as I struggle to find the right one for me personally. Though, what I am finding so far, is that a combination of multiple classes that teach the same material is beneficial, but that alas, is another post.