Librarians Learning to Code Presented by Bohyun Kim

One of the great things about librarians is the collaborative and energetic community spirit towards learning new things and Boyhun Kim’s Charleston Conference presentation on November 9, 2012 is an excellent example of this.  In her presentation and her blog, Library Hat, she has pulled together the many learning resources that are available and the communities involved in learning code for library purposes and services.

Posted in Presentations, Programming | Leave a comment

From Coursera to Udacity Computer Science 101 courses

Feeling confident after Nick Parlante’s more general introduction to Computer Science, I began a new class from another Stanford faculty member and a faculty member from the University of Virginia. This Computer Science 101 course from Udacity uses Python, a web scripting programming language as a tool to build a search engine.

Sample of Udacity video instruction page

Sample of Udacity video instruction page

After beginning in the Spring of 2012, I have yet to complete it. It is less introductory than a 101 classification would imply and demands a lot more involvement in solving problems and building upon the information learned earlier in the course.  Even though it is unfinished its focus on a practical application, like building a search engine, has helped me better understand how web crawlers, like the ones that Google uses, search and gather information about websites.

It also helped me better understand Python and gives me hope that I may be able to someday understand how it works enough to use the python library, pycdm, that Shawn Averkamp created at the University of Iowa to use with CONTENTdm.

Posted in Open Education, Programming, Search | Leave a comment

Internet Pioneers in Open Source Software from Dr. Chuck Severance

Integrated into the Coursera course on Internet History by Charles Severance at the University of Michigan are many videos of Internet Pioneers.  This set of three videos is about 3 people who created three of the major open source tools or organizations that drive the Web we use now.

One of the features that they all share is that they are committed to sharing and collaborating, a quality all librarians can appreciate.

  1. Rasmus Lerdorf invented PHP, a web programming language, to help him do his work more effectively and it led to the development of an open source tool and community.
  2. Brian Behlendorf invented with a group of collaborators the Apache Web Server so that they could continue to have a free software tool to create the Web.
  3. Richard Stallman founded the Free Software Foundation and his vision for software and use of the Web certainly predicted the existence of Wikipedia and sharing knowledge and information.
Posted in History of Science and Technology, Open Education, Open Source, Software | Leave a comment

Boolean Search: Library and Computer Science Style

One common set of tools of the librarian trade are the databases that are purchased and taught to researchers in the community they serve.  The most powerful searches are performed based on the boolean logic of AND, OR, and NOT. The figure below is an example of one of those search interfaces:

Academic Search Premier Search box

Each row can be set to focus on a particular field and mixed together with the Boolean operators in the drop-down menus on the left. This week’s course showed what the code looks like underneath the graphic display.

Computer code uses the same basic operators but represents them in the following ways:

    • AND = &&
    • OR = ||
    • NOT = !

It also uses commands that direct the computer to look for certain things in fields within a table of data. For instance, if we were looking at a table with fields full of data about the authors, titles, publication dates and we were looking for that children’s book author whose name starts with “C”.

One line might look like this:

if (row.getField(“author”).startsWith(“C”)) { print(row) }

Before this line there would be a code that would repeat this step, called a for loop and it would retrieve any names that begin with C in the table and print that row. We could then add another line with a boolean operator to get more sophisticated results. The results bring up a list of too many to choose from.

Let’s say that we remember that she wrote a book about a mouse.

if (row.getField(“author”).startsWith(“C”) &&

row.getField(“title”).startsWith(“Mouse”)) { print(row)}

It is really the search, C* in the author field AND Mouse in the title but shows us how it is translated into computer speak through the nice interfaces we use. We might now get the result of Beverly Cleary’s Mouse and the Motorcycle.

Posted in Information Retrieval, Programming | Tagged , , | Leave a comment

Movie Magic Spoiler Alert – Bluescreen

bluescreenIf you are someone who enjoys the wonder of movie-making without the desire to know how it works then read no further. Nick Parlante’s week 3 lecture revealed how the bluescreen/greenscreen trick uses computer code to insert portions of one image onto another. I have always wondered why that works and now I know.

The concept of pixels having a Red, Green, and Blue value is the foundation of this trick. The reason movie studios have those Green or Blue screens on studio is because it allows the computer to easily detect the color of the pixels from the screen and then replace them with pixels from another image.

In code language you need a way to identify which pixels to replace by identifying the Blue or Green ones. This is done by writing code that finds out the number of the Red, Green, and Blue portions of each pixel (remember that they range from 0-255) and finding the average. Comparing the average value of a pixel’s three numbers against a high Green value allows the computer to identify which pixels to replace with pixels from the other image.

Here are some of the key code components:

Commands like pixel.getX() to find the x (or y) coordinates within an image;

if statement to identify which of the green pixels are to be replaced by finding pixels where the Green value is higher than “avg” which is the average of the three color values.

if (pixel.getGreen() >  avg)

Link the pixel from one image to the other using names to represent each image (“image” and “back”)

pixel2 = back.getPixel(pixel.getX(), pixel.getY())

and copying the color values of the other image, pixel2, to the corresponding original “pixel” on the green screen.

pixel.setRed(pixel2.getRed())

This process done on every individual image in a video which is really just a large amount of static images flicking by rapidly.

[Image courtesy of mvjantzen]

Posted in Digital Images, Programming | Tagged , | Leave a comment

Grayscale Revealed

Color photo changed to grayscale

Photo editing software seems magic sometimes in the way that it can switch a photo from color to black and white with a button click. Learning the code for this has pulled back the curtain on this magical process.

When the Red, Green, and Blue values for a given pixel (between 0-255) are the same, you get a gray tone.  This also might explain why scanners or other imaging equipment list color settings as 24 bit and grayscale is only one third the value at 8 bit. If only one number value is needed to determine the pixel color instead of three separate ones for each color channel in Red, Green, and Blue then you have one third of the data.

With the handy for-loop command, Nick Parlante taught us how to calculate an average value for each pixel in a color image and modify each channel to be the same value to change it to gray. Here is the average snippet of code that generated the value to set for each pixel in the loop:

avg = (pixel.getRed() + pixel.getGreen() + pixel.getBlue())/3;

Very fun!

Posted in Digital Images | Tagged | Leave a comment

Loops, Curly Brackets and the Power of Repeating Code

In week 2, Nick explained “for loops” and how they allow simple commands of code to do much larger things. Part of the learning process included recognizing two major grammatical clues or code syntax, the curly brace, { , and the double forward slash, //.

If you have ever looked at a page of code and wondered what all these dangling wiggly lines are for then you are not alone. This curly bracket, or brace, begins a code function called a loop. In particular we were introduced to a “for loop” which repeats a given piece of code over and over for a defined set of items until it sees a right brace, }. In our case, it was for all the pixels in a digital image. Last week, we learned how to manipulate the color of one pixel at a time and the “for loop” enabled us to do this for all the pixels modifying the whole image.

The full example would look something like this:

image = new SimpleImage(“51020-banana.png”);
for (pixel: image) {
// your code here
pixel.setRed(pixel.getRed() * 20);
pixel.setGreen(pixel.getGreen() * 5);
pixel.setBlue(pixel.getBlue() * 10);
}

print(image);

I now understand that the brackets contain code that is meant to modify the Red, Green, and Blue values for one pixel and repeat it until all the pixels are changed in the image.

Also important to know is that the two forward slashes  //  signify a comment that is purely for human eyes and will be ignored by computers until the next line.

Understanding these two “grammar” points of computer code have helped me to make more sense of what I see when I look at code.

Posted in Programming, Syntax | Tagged | Leave a comment

Software Tip of the Code Iceberg

The week 1 introduction was already very helpful because it opened up the basic rules and syntax to how computer code works and made some of the functions of software I use, like Photoshop and CONTENTdm, more clear. The examples were demonstrations of how Javascript works (because it only needs a browser to work) with simple commands like “print”.

One example code snippet looked like this: print (1,2).

The computer will then spit out this: 1 2

R G B GraphicPhotoshop and Digital Images

Some concepts I already had a good grasp of like the RGB model of how color is produced on a computer where each of the three color channels; Red, Green, and Blue, have a value from 0 to 255. I hadn’t seen the RGB Color Explorer tool that he used that is similar to RGB Explorer from the Wolfram Demonstrations Project by Jon Perry

The programming piece that Nick Parlante explained so clearly was how a program can target individual pixels in an image and change their color or size and it gave me better insight into how Photoshop works on a much larger scale.

Green XSyntax and Error Messages and Algebra, Oh My

The explanation that was given about the ways that computers understand lines of code and how the error messages don’t always seem to make sense really clicked for me. When working with lots of metadata and trying to load it into CONTENTdm with a tab-delimited text file one can get very frustrated with the error messages and their lack of helpful information. I have more understanding of why it is difficult to give clear feedback on what went wrong and how diligent you have to be with details like punctuation that can make or break a line of code. I also see how the concept of variables and the way that learning algebra allows you to do more advanced functions in computer code, so I do have to dredge it up from its deep junior high grave in my brain. X = [whatever you want it to be] allows you to do lots of functions and change many things efficiently if you’ve coded correctly.

Computer Coding is People!

I appreciated the perspective that the professor gave on how computers are powerful in a certain way, such as their ability to quickly complete a massive amount of commands, but they are dumb in that they simply carry out mechanical commands and need specific syntax in their code to be able to function correctly. It takes human creativity to see a specific problem or function and figure out how to tell a computer to do it in computer language. As a librarian, I have many problems that I want to solve or cool features that I would like to provide to people but I need to learn to speak better computer to do it.

Posted in Programming, Software | Tagged | Leave a comment

Free Professional Development from Stanford University

Those of us in higher education and librarianship are hyper-aware that things are changing rapidly. The practice of librarianship is increasingly dependent upon computers and higher education is increasingly feeling the pressure of economic and technological cultural shifts demonstrated in the emergence of digital humanities, mobile technologies, and efforts towards more effective and engaged assessment. David Lankes’ Atlas of New Librarianship is one of several model discussions engaging the changing environment for librarians and, among other issues, calls for more competency in Computer Science.

One way to engage is to dive right in. New models of free access to higher education are emerging in the form of Khan Academy, Academic Earth, or Coursera, of which the latter  was introduced in an NPR article on April 18.   Coursera is a partnership between Stanford University, University of Michigan, University of Pennsylvania, and Princeton University to provide some of their courses to anyone who is interested for free.

CompuComputer Science 101 Stanford Universityter Science skills, like programming and database administration, are increasingly necessary as a core skill for librarians and what better way to learn new skills and engage some of the new models of education than taking a free class? This is what motivated me to enroll in Stanford University’s Computer Science 101 taught by Nick Parlante. I hope to be able to better engage my colleagues in IT and to be a better Digital Librarian after this experience. Week 1 is not over until May 1st, will you join me?

Posted in Higher Education, Open Education | Tagged | Leave a comment