Based on
this post .
In the past 2012, I, like millions of other users, discovered free online training. It all started with a great
Codecademy startup. Remarkable courses on JavaScript, jQuery, Python, Ruby and others took up all their free time. A side effect was the practice of reading in English. By the middle of the year, the available lessons were over and I became interested in other sites where you can continue self-study. Just at that time, articles about
Coursera became frequent on Habré and I decided to try.
The first course that drew attention was
An Introduction to Interactive Programming in Python from Rice University. Without thinking twice, I joined the slim ranks of online students.
Part 1. Back to school
From the very first video lecture, the teachers of the course (Joe Warren, Scott Rixner, Stephen Wong, John Greiner) have listeners to a friendly atmosphere and cheerful mood. Suffice it to say that the first project to study was writing a console version widely known among the Big Bang Theory fans of the game “Stone. Scissors. Paper. Lizard. Spock. " For those who are not aware of
its rules here .
All programming in this course takes place in a special online
sandbox , which is very convenient, since you do not need to carry source codes and distributions everywhere, and you can save all your experiments “in the clouds”. How the learning process in Coursera is arranged is surely already known to the local public. The lecture topics and weekly projects were as follows:
- Expressions, variables, functions, conditionals. (Project "Rock-Paper-Scissors-Lizard-Spock" game)
- Event-driven programming, local and global variables, buttons and input fields. (Project "Guess the Number" game)
- The canvas, static drawing, timers, interactive drawing. (Project Stopwatch: The Game)
- Lists, keyboard input, motion, positional / velocity control. (Project "Pong" game)
- Mouse input, more lists, dictionaries, images. (Project "Memory" game)
- Classes, tiled images. (Project "Blackjack" game)
- Acceleration and friction, spaceship class, sprite class, sound Spaceship from. (Project "RiceRocks" game)
- Sets, groups of sprites, collisions, sprite animation. (Project Full "RiceRocks" game)
Each project is described in detail by teachers at the end of the lecture. For projects, templates are provided that already contain global variables, class constructors and auxiliary functions. It remains only to write the necessary methods and implement the output to the screen. I will not give references to completed tasks in case someone decides to take this course. I did all the work as close as possible to the task. And this is what the final draft of a comrade looks like, which went beyond the required minimum and added all sorts of beautifulness:
http://www.codeskulptor.org/#user7-0WgaPD23z9-0.py . By the way,
-0
at the end of the URL is the file version. Each time you save a version is incremented and you can always see the previous iterations. Such is the elegant Source Control.
There is no exam at the end of the course, which is probably why no confirmation of its successful completion is given. However, during the course among students, a screencast contest was held, according to the results of which two winners received an iPad.
Part 2. Bydlocod
Having finished the course with an average score of 99.46 / 100, I certainly felt like an
all-powerful programmer. And just in time, a small task turned up, which I did not fail to solve, using the newly acquired knowledge.
The problem was the following: for the existing directory with a bunch of documentation in the .pdf format, generate an HTML page with a list of links to files sorted by sub-directories. Links must be readable, which means the file name is not good and you need to go into each PDF and read the title of the document.
A bit of smoking manuals on the pyPdf and markup modules and quite a bit of copy-paste, and something happened:
')
pdfdir2html.py import os import sys from datetime import date from pyPdf import PdfFileReader import markup import shutil def getPdfTitle(filename): if not filename.endswith('.pdf'): return "" input1 = PdfFileReader(file(filename, "rb")) if not input1 or input1.getIsEncrypted(): print ".file " + filename + " is encrypted..." return filename.split(os.sep)[-1] if input1.getDocumentInfo() == None or input1.getDocumentInfo().title == None: print ".file " + filename + " has no title..." return filename.split(os.sep)[-1] return "%s - %s" % (input1.getDocumentInfo().author, input1.getDocumentInfo().title) def create_html_list(rootpath): rootpath = rootpath.rstrip(os.sep) start_level = rootpath.count(os.sep) page = markup.page( ) page.init( title="Pdf File List", css=( 'bootstrap.css', 'style.css' ), script={ 'script.js':'javascript' } ) page.div(class_='wrapper') for root, dirs, files in os.walk(rootpath): present_level = root.count(os.sep) actual_level = present_level - start_level caption = os.path.realpath(root).split(os.sep)[-1] if actual_level == 0: page.h1( caption, class_='caption' ) elif actual_level == 1: page.h2( caption, class_='caption' ) elif actual_level == 2: page.h3( caption, class_='caption' ) elif actual_level == 3: page.h4( caption, class_='caption' ) else: page.h5( os.path.relpath(root), class_='caption' ) if len(files) < 1: continue file_list = [file for file in files]
The script scans subdirectories, reads the title of each PDF and creates an index.html file in the target folder. For greater beauty, I have added a bit of CSS to it, but these are details ...
As it turned out, among the documentation there are encrypted files, which, although they open normally with any PDF reader, do not, for some reason, allow you to read your title with
getDocumentInfo().title
. In this case, the link we will still have the file name.
For the generation of HTML code, markup came up perfectly, everything is simple and beautiful with it, for example:
page = markup.page( ) page.init( title="Pdf File List", css=( 'bootstrap.css', 'style.css' ), script={ 'script.js':'javascript' } ) page.div(class_='wrapper') ... page.div.close() print page
Part 3. Where to go
Suppose that the above code does not use the concepts of OOP studied in the course of Interactive Programming in Python, but this course spurred my interest in using new languages ​​and learning modern programming patterns. At the moment I have the following courses:
And this is only on Coursera, and in fact there is
Udacity , a fantastic
ode School ,
edX with amazing BerkeleyX and MIT courses, and the list goes on and on.
Not to mention also the initiative of the Russian-
speaking comrades from the startup “Free University” of
Hexlet University . I wish this development project an explosive pace!
Now the main problem was to find free time for all this study, as well as the painful choice of the best of several courses that are taking at the same time.