Category Archives: Programming

Automatically Generating an HTML5-style Cache Manifest from the Command Line

HTML5 introduces the ability to cache content client-side so that often-used resources can be used without re-downloading them. This also enables a site to be viewed from the client when no network connection is available (i.e., offline viewing of the site).

In order for this to work, there are a few things one must do:

  1. Create a plain text file listing all of the resources that should be cached by the user agent (e.g., a web browser)— the cache manifest.
  2. Refer to that file in the opening html tag of every page that will use cached resources.
  3. Configure the web server so that the file is sent to the user agent with a specific MIME type: text/cache-manifest
  4. Regenerate the cache manifest any time you change the files in your site.
Once everything is setup properly, you can visit the site using your favorite web browser. Then, to test whether the caching has worked, you can turn off the network connection to your web browser’s computer and try reloading the page.

Continue reading Automatically Generating an HTML5-style Cache Manifest from the Command Line

Thinking Through A Basic Pong Game in Processing

The Problem: Create a basic 1970s style Pong game for one player using the Processing programming language. The paddle will be on the right and the ball will bounce off of the three other sides. If the ball passes the paddle while the ball is traveling to the right, game play ends. The paddle will be controlled by the keyboard’s UP and DOWN arrow keys.

Continue reading Thinking Through A Basic Pong Game in Processing

Computational Efficiency

I’d like to give a brief overview of computational efficiency, since it’s a topic that has come up in a few conversations recently. The super short version is this: it’s often helpful to understand the resource (time, space, or power) needs for a given algorithm. Why? Because we want the fastest algorithm, or the one that uses the least amount of storage on our hard drive. In extreme computing environments (think Mars Rover, Apollo capsules, etc), we many have very limited resources available. For example, your digital wrist watch almost certainly has more memory than the Apollo capsules, which only had about 32KB of RAM. How can you possibly land a person on the moon with only 32KB?!!
Continue reading Computational Efficiency

Goodbye, Hello World?

Alfred Thompson questioned on his blog today whether the customary first programming exercise, Hello World, should be replaced with something that’s more flexible and calls on students to engage in a short, non-trivial first act as a programmer. I admit, I’ve used Hello World myself with students, but usually not as a first activity. Instead, I use Hello World to help students who have had some hours or days of programming instruction understand that they now know quite a bit about how programming languages express an intention. I ask students to visit the ACM Hello World web page and compare and contrast that simple program in different languages. How are code blocks started and ended? How is output generated? How is an infinite loop expressed? How are strings represented?

Continue reading Goodbye, Hello World?

Learning to Write in English like Learning to Program

Imagine for a moment that you were going to teach writing in standard English in the same way we tend to teach computer programming.

Alright… Let’s learn to write. Before you can write, you need to know about the fundamentals of the language we’re going to use. A language is a collection of words and rules for how you combine those words. Words can be thought of as being of different types that determine the purpose and meaning of the words. For example, two types we’ll work with are nouns and interjections. There are other types, too, but we’ll get to those later.

For now, let’s write your first sentence. A sentence is a valid sequence of words. By valid we mean that the sentence would be recognized by an expert speaker of the language as being acceptable.

So, we need an example of a noun and an interjection to get us started… One frequently used noun is the word WORLD and a common interjection is HELLO.

Continue reading Learning to Write in English like Learning to Program

Media-Propelled introduction to Computational Thinking

Eric Freudenthal of the iMPaCT: a Media-Propelled introduction to Computational Thinking project spoke at SIGCSE 2010 about how to engage students who are math phobic with computation and, thereby, with math. Using Python and computation about dynamic systems, students work to understand how code == math == concepts. One issue raised was how ethical it is to mislead students initially about whether they’re learning “math”. Eric’s argument: if students know they’re learning math, they fallback on unsuccessful rote memorization techniques. If, however, they believe they are working with dynamic systems to understand how the system changes as parameters are adjusted, then students engage and experiment.

iPhone Web App Development

This 4-week workshop, hosted by CreativeTechs and O’Reilly Media is an excellent introduction to how to create website-based applications for use on the iPhone. Website-based apps don’t need to go through the notorious Apple review process for applications, since they are essentially web pages built using standard HTML, CSS, and JavaScript tools and are accessed using Mobile Safari. Once on your app page, users can choose to add the page to their iPhone apps list as an icon, which allows the page to appear without the browser’s chrome (the standard widgets that appear in a web browser: address bar, back/forward buttons, etc.).

Led by Elisabeth Robson, coauthor of Head First HTML with CSS & XHTML, these sessions have been wonderful and are well worth your time. Until 2010 February 5, the entire set of recorded sessions + sample book chapters + sample code can be purchased either from Creative Techs or O’Reilly for just 35$.

KUIT245: Web Development

Location: Kaplan University, Online
Terms: 3
Class size: ~ 20 students/term

Students in IT245 create websites using standards-compliant technologies: XHTML, CSS, and JavaScript. Students learn about site planning, page design, site development, and workflow control. They also implement basic forms processing using hosted forms solutions.

Reading Materials

  • Adobe Systems. (2009). Adobe Dreamweaver CS4: Classroom in a book. Berkeley, CA: Adobe Press.

KUIT250: Enhancing Websites with PHP

Location: Kaplan University, Online
Terms: 1
Class size: ~ 10 students/term

Students in IT250 learn the fundamentals of programming in PHP to enhance websites. Topics covered include fundamentals of programming, processing HTML form data, database connections using MySQL, and using MySQL as a backend data store.

Reading Materials

  • Meloni, J. C. (2004). PHP 5: Fast & Easy Web Development (3rd ed.). Boston, MA: Thomson Course Technology.

R Statistical Programming Language

The R Project provides a comprehensive, free, open source statistical programming language and environment based on the S language. R is the name of both the language and the environment in which you generally use the language. It’s an interactive environment where the commands you enter generate immediate results that you can use to guide your analyses.

Your Best Starting Point

Download and install R. Download and install RStudio. Read R for Data Science.

Continue reading R Statistical Programming Language