All posts tagged coding

End of the Week Link Roundup for January 13

Here’s a list of the stuff that’s filling up the tabs of my browser. I wanted to write about a number of them, but I just don’t have the time.

  • “That’s what she said”.js (JavaScript): Very cool, very funny. The glories of GitHub.
  • Who killed lard?: NPR’s Planet Money has a podcast and they recently asked: who killed lard? Was it Upton Sinclair? Or should we blame William Procter and James Gamble? It was their company which created a new alternative to lard — the “pure and wholesome” Crisco?
  • Sell Your By-Products: is the advice of the good folks at 37Signals, who have a pretty good track record given that they developed Ruby on Rails and have written two books, which in turn spawned a consulting business. They are that good. (Definitely on my “would work for them” list.)
  • AppStorm’s Ultimate Dropbox Toolkit and Guide is a roundup of Dropbox apps or apps that get better with Dropbox.

2012 is the year I teach myself how to program in Python.

Getting up and running with NLTK

A while ago I tweeted a note to Digitial Humanities Questions and Answers about putting together a Python or R script for getting a word frequency distribution for a text. The short explanation for why I want to do this is because it is one way to develop a drop, aka stop, lists in order to tweak network analysis of texts of visualization of those texts using techniques like a word cloud. I am interested in a Python or R script in particular because I want my solution to be platform independent, so that students in my digital humanities seminar can use the scripts no matter what platform they use. (I had come across some useful bash scripts, but that limits their use to *nix platforms like Mac OS X or Linux.)

Handily enough, a word frequency distribution function is available as part of the Python Natural Language Toolkit (NLTK) — the same functionality is also baked into R, as John Anderson demonstrated — but I am focusing any scripting acumen development for now on Python.

Getting up and running with NLTK

To get up and running with NLTK in Python, you first need a fairly recent version of Python: 2.4 or better. (My MacBook is running 2.6.1, which is acceptable, and I’m not good enough, yet, to update.)

In addition to a recent version of Python, and in addition to the NLTK (more on that in a moment), you also need PyYAML. All the downloads for PyYAML are available here: http://pyyaml.org/download/pyyaml/. (Please note that from here on out I am describing the installation process for Mac OS X: the Windows routine uses different flavors of these resources — there is a PyYAML executable installer, for example.)

Download the tarballed and gzipped package and unpack it some place convenient. (YOu are going to delete when you are done, and so the place doesn’t matter.) I put my copy on the desktop, and so, having unpacked it, I navigated to its location in a terminal window:

% cd /Users/me/Desktop/PyYAML-3.09

(Please note that the presence of the % sign is simply to indicate that we are using the command line.) Once there, you run the setup module:

% sudo python setup.py install

From there, a whole lot of making and installing takes place as your terminal window scrolls quickly. It’s done within seconds. Now you need to download the appropriate NLTK file, mine was here:

[http://nltk.googlecode.com/files/nltk-2.0b9.dmg][]

This time it’s a GUI-based installer package. Follow the instructions, click on things, and you are done.

To check to make sure everything got done that needed to get done, return to your terminal window and invoke the Python interpreter:

% python

At the Python interpreter prompt (>>>), type:

>>> import nltk

If everything went well, all you will get is a momentary pause, if any, and another interpreter prompt. Congratulations!

Farming versus Mining

Wil Shipley of Delicious Monster, maker of Library, has a nice post up that compares two ways of approaching the software business: farming versus mining. Essentially, farming is the old-fashioned way of building a business to last, building with the long game in mind. Mining is the new way to do business: build a business with the current hot model in order to sell it. Investors, at least the generation of investors who came of age in the last two decades, prefer the latter model: they make money as a business rises, usually with unmaintainable growth, and a number of investors make money as the business crashes and burns. The founders, as well as the investors who find them, of such companies are the new rock stars, but they are even better than rock stars, like other media stars, might begin to lose his or her shine after one flop too many. These new business stars don’t seem to have to worry about that. As long as the flop occurs after everyone has made their money, no worries.

To be fair, the software industry is only one of many industries to be troubled by this dynamic, which dates back to the shift in investing for dividends and slow, but long, stable growth to investing for growth in stock price. Shipley’s analysis is especially interesting because he goes on to make an argument about how easy mining is: ideas are easy. Implementation is hard. Certainly the farmers I know would agree that their work is hard, without guarantee of success, and likely to yield only small successes over a series of years.

Learning Python

Oi. In a recent post to the Digital Humanities Seminar I am teaching I noted that finding decent word frequency applications that one can run locally is harder than I thought. The alternative is to build your own. One of my students has done just that using R, and I am trying to teach myself how to do it in Python. There are, of course, the tutorials at the Python website itself and there is this e-book over at Blogspot. And I have three Python books stacked on my desk beside me, but I can’t for the life of me figure out how to get text from a file into either the Python interpreter or into a Python script.

Inside Tron Legacy’s Coding

Josh Nitmoy’s account of his design work for Tron: Legacy not only details his own coding efforts, using a variety of software (including Processing), but also his efforts to represent coding correctly (at least that is his position). That is, having grown tired of seeing ridiculous UIs or one too may characters using nmap, he decided to have the characters in the movie actually use things like grep and kill.

Design, then Code

Design, Then Code is a nice place to begin thinking about making an app for iOS devices. The name is certainly good, in that it stresses thinking about the user experience in advance of building the code that creates the functionality, but the idea that one can do all the design work ahead of the construction is something that I thought we were long past. I understand that they are responding in some fashion to the sort of user experience nightmares that folks often point out as being the great weakness of Google’s application offerings, where there is a lot of functionality, you just can’t figure out how to get to it.

Why does it have to be one or the other? I thought we were beginning to figure out that it has to be both?

Zen and the Art of Programming

This post on Zen and the Art of Programming is from last year (2010), but it has a nice collection of books “that will make you a better developer.” Interestingly, a few of the books are less about programming and more about programmers: about how to create an organizational culture that supports good programming. There is also a Python book focused on machine learning entitled Programming Collective Intelligence.

Critical Code Studies

Critical code studies is here, and I think it’s asking all the right questions:

Do Digital Humanities scholars need to know how to code? … While that question raises anxieties in many humanities scholars, it is not an overstatement to argue that computer source code presents a sign system, a discourse environment, that holds tremendous influence over our daily lives — and that for the humanities not to be able to address it, not to be able to use their methodologies to critique this cultural milieu, is the equivalent to unplugging from the Internet permanently or, as has been tweeted, to live in the Roman Empire without knowing how to speak Latin. While perhaps not every DH practitioner need code or know how to code, if we cannot collaborate with our colleagues in computer science to apply our methodologies to the study of source code (and hardware and software), we will be confined to cultural critique of the surface effects of a digital culture which functions within in a black box. (From the front page for HASTAC‘s new Critical Code Studies forum.)

As I continue to develop the analytical and narrative framework of the book I am writing on creativity in fabrication shops in south Louisiana — testing it against what I can actually write — I am also thinking about the next project. For a time now, I have been thinking that writing an ethnography of a coding project would be interesting. Unlike, Scott Rosenberg’s fine Dreaming in Code, however, I knew I wanted my book to include within its purview an actual discussion of the code involved. That is, I think coders have two kinds of conversations: those about code and those in code. So far, I think most documentation has focused only on the former without really revealing how the two discursive streams interact. While I dabbled in Ruby, particularly in Ruby on Rails, I was part of the Radiant CMS mailing list, and I thought I would work with them, but now I am not sure what my subject might be. I am, however, looking forward to this work.

Speaking of alternate domains of critical study, however, I would like to note that critical code studies joins critical legal studies, but there is still not, so far as I am aware, anything like critical business studies. I presented a paper or two on the subject at a few meetings of the American Folklore Society, and I remember having some interesting discussions with Michael Owen Jones about it. I have not pursued it, but I do wonder if others have or are interested in doing so. Certainly the business literature community produces plenty of material which begs for a closer examination. (I’m afraid the sheer glut of it was what overwhelmed my own thinking about it.)

Zen Coding for HTML

Zen Coding for HTML allows you to type this:

div#page>div.logo+ul#navigation>li*5>a

and have your text editor convert it to this:

<div id="page">  
    <div class="logo"></div>  
    <ul id="navigation">  
            <li><a href=""></a></li>  
            <li><a href=""></a></li>
            <li><a href=""></a></li>  
            <li><a href=""></a></li>  
            <li><a href=""></a></li>  
    </ul>  
</div>  

Vygotsky and Coding

At the recent Microsoft Professional Developers Conference, an all-star cast of coding greats were convened on “Microsoft Perspectives on the Future of Programming. ” Among other things, Butler Lampson, Erik Meijer, Don Box, Jeffrey Snover, Herb Sutter, and Burton Smith discussed the improvement in IDEs (integrated development environments) and in various languages and how making coding easier, or at least less likely to fail, also means people not knowing everything they should in order to become great. One contributor likened it to anti-lock break systems: “Now you don’t have to be a great driver to perform well in snow. You just mash the brakes and the anti-lock system does all the heavy lifting for you and it pumps much faster than you ever could. It’s just, in my view, a case where computers actually help you think less. It’s like what Vygotsky in activity theory distinguishes between your performance and your competence.” The video is here, and the statement is right at 40:00 in. Check it out.

Coding’s Place in the Digital Humanities

An observer of the 2008 meeting of Museums and the Web noted that:

More museums should be building these programming skills in internal teams that grow expertise from project to project. Far too many museums small and large rely on outside companies for almost all of their technical development on the web. By and large the most innovation at Museums and the Web came from teams of people who have built expertise into the core operations of their institution.

I fundamentally believe that at least in the museum world there isn’t much danger of the technology folks unseating the curators of the world from their positions of power. I’m more interested in building skilled teams within museums so that the intelligent content people aren’t beholden to external media companies but rather their internal programmers who feel like they are part of the team and understand the overall mission of the museum as well as how to pull UTF-8 data out of a MySQL database.

About all I can say is that universities in general and humanities in particular could be inserted wherever museums appears above and the statement would be perfect. Ideally, programming would not only be folded into teams but also into individual players. There really is no reason why humanists shouldn’t have at least some exposure to the basics of coding.

To see the quotation above in its original context, you only need to look here.

Run MultiMarkdown in Terminal

I found this script. I think I could substitute the PHP version of MultiMarkdown here.



#!/bin/bash

#******************************************#
# This script runs the multimarkdown       #
# script on specified file, redirects      #
# output to html file, and opens resulting #
# file in web browser.                     #
#******************************************#

# gets complete filename of file 
srcfile="`eval echo $1`"    

# gets the filename without .txt
FILENOEXTENSION="`echo $srcfile | sed -e 's/\..*$//'`"  

# Runs perl script and creates .html file
~/MultiMarkdown/bin/multimarkdown2XHTML.pl $srcfile > $FILENOEXTENSION.html 

# opens it up
firefox $FILENOEXTENSION.html


Teach Yourself to Program in/with Scheme

The good folks at MIT and MIT Press have made the influential computer-science text Structure and Interpretation of Computer Programs available on-line with sample code and the instructor’s manual. It’s all here.

Hanging Indent in Plain Text

Hanging Indent

I’ve got a list that looks like this:

  1. The job of a writer is to discover what series of events best illustrates an idea or an emotion.
  2. Just like the actor, your job is one of translation, the most difficult part which is that it all comes down to this: you have to write something that a person can do in front of a camera.

and I want it to look like this:

1.    The job of a writer is to discover what series of events best illustrates
      an idea or an emotion.

That required the insertion of a hard return at the end of the line and then an insertion of three spaces in addition to the existing single space in order to make it four spaces and to line up with the tab.

  1. Just like the actor, your job is one of translation, the most difficult part which is that it all comes down to this: you have to write something that a person can do in front of a camera.

Okay, that’s consistent:

Go to end of line.

Insert hard return

Go to beginning of next line (or advance one character)

Insert three spaces.

Continue until you get to a pre-existing hard return.