What Is Code?

Paul Ford’s [“What Is Code?”][bb] at/on _Bloomberg Business_ is a magnum opus of a treatment. My little word count app that I created as a service on my Mac logs the things at 30,000 words.

[bb]: http://www.bloomberg.com/graphics/2015-paul-ford-what-is-code/

Learn to Write (Code)

This year is the year I teach myself to write code, and there have never been more resources available to humanists interested in doing so. At this moment, I would like to point out two interactive approaches as well as two more thoughtful approaches designed especially for historians (who, as always, seem better at producing these kinds of texts than other humanists):

If you are interested in a very simple, one step at a time approach to learning how to code — and those first few steps really do feel, to me, like what the first few steps must feel like to the soon-to-be toddler, transformative — then there is both [Hackety Hack][hh], which was first brought to my attention by [ProfHacker][ph] and [CodeAcademy][ca]. Hackety-Hack will teach you the basics of [Ruby][], a very powerful programming language that has also been refined for web work — e.g., Rails, which is the power behind Twitter — and CodeAcademy will teach you [JavaScript], another scripting language which powers some significant features of the modern web.

In the same ProfHacker article linked above, Ryan Cordell points to another resources for learning Ruby (for humanists): [The Rubyist Historian][rh] by Jason Heppler. (Unfortunately, at this moment, that portion of his site appears to be down.) There is also the terrific book [The Programming Historian][ph], which offers instruction in various ways to work in [Python][].

[hh]: http://hackety-hack.com/
[ph]: http://chronicle.com/blogs/profhacker/more-hackety-hack-less-yackety-yack-ruby-for-humanists/30175
[Ruby]: http://en.wikipedia.org/wiki/Ruby_(programming_language)
[ca]: http://www.codecademy.com/
: http://en.wikipedia.org/wiki/JavaScript
[rh]: http://www.jasonheppler.org/2010/12/10/the-rubyist-historian-the-series/
[ph]: http://niche-canada.org/programming-historian
[Python]: http://en.wikipedia.org/wiki/Python_(programming_language)

Visualization Toolkits

As I begin to assemble materials for my spring seminar surveying the digital humanities, I find myself trying to come up with categories, especially for describing arenas of activity. The digital humanities can be quite overwhelming when you are first introduced to them, and because everyone comes to them from so many backgrounds and with so many agendas, it’s hard to separate personal visions from something more synthetic.

Towards the latter, I am trying to think about how to describe some of the things that people regularly do, and I’ll be posting some of my initial thoughts in a series of posts that I will myself later synthesize into something like a syllabus and/or guide. Readers who want to follow along are welcome to do so. I am going to tag the posts with the number for the course, 531, and I will try to update earlier posts so that they turn up under that tag as well.

One of the first things to break out for me is the area of visualization, which is so important that it’s built into most network analysis applications. Visualization, especially dynamic visualization which allows you to adjust your view of the data in various ways, is an essential part of analysis and understanding.

Many of us are used to working with built-in visualizations toolkits like those found in Network Workbench or ORA or even Excel/Powerpoint — Numbers/Pages for those Mac users who eschew Microsoft’s productivity apps and OpenOffice users forgive me for not knowing the equivalents, but R also possesses some remarkable graphical abilities.

None of them can compare to the graphical and/or visualization abilities of two languages build for doing this kind of work: Processing and Protoviz.

Up next: a comparison of the two.

Website Infrastructure

For those who have asked, this site runs on a total of 7 PHP pages. `Index`, `search`, and `single` serve the blog portion. `Page`, `archives`, and `notes` are special purpose pages. (Yes, that’s six pages and I said seven at the outset. One page is purely for my own in-house use, and I don’t want to give it away.)

archives.php
index.php
notes.php
page.php
search.php
single.php

To reduce server load and to increase load times into browsers, I have opted not to use separate `footer` and `header` php files. The design of the site doesn’t change enough to warrant keeping them as separate files.

My goal in this site is always to keep the infrastructure, and the data structures, as simple as possible.

{less} extends CSS

While CSS3 continues to evolve in interesting and powerful ways, it still clings to some conventions that make it more like a set of markup conventions and less like a programming language. That is, while you can describe a lot of things in CSS, you typically have to do so verbosely and somewhat redundantly. You cannot, like most modern programming languages, compress your efforts, pass variables, create something like objects.

For those who either run Ruby or, like me, are confined to admiring it and continue to try to learn it, [`less`](http://lesscss.org/) is available for installation and use and what it does to, or for, CSS is nothing short of amazing.

For one thing, you can set up variables for things used site-wide that allow you to establish, as in the example below, all your colors in one place:

@brand_color: #4D926F;

#header {
color: @brand_color;
}

h2 {
color: @brand_color;
}

Or you can use something they call *mixins* which operate like some sort of powerful hybrid of variables and functions — note how you can pass an argument to what looks like a variable:

.rounded_corners (@radius: 5px) {
-moz-border-radius: @radius;
-webkit-border-radius: @radius;
border-radius: @radius;
}

#header {
.rounded_corners;
}

#footer {
.rounded_corners(10px);
}

Finally, for me at least, there is the opportunity to nest selector names in a way to make inheritance more obvious:

#header {
color: red;
a {
font-weight: bold;
text-decoration: none;
}
}

(Nothing kills me more than trying to figure out inheritance of an item that just won’t style for me because I’ve missed some piece of the CSS flow in my analysis.)

Check out [`less`](http://lesscss.org/) for more.

Share Delicious Library

(with simple HTML)

For anyone interested in sharing the library with friends, here are some tips. For the purpose of this explanation I am going to assume that you have a web server on your machine and that you server root directory is at `/Library/WebServer/Documents`.

1 – Copy your library file, `Library Media Data.xml`, from `~/Library/Application Support/Delicious Library/` to the root directory of you web server. I recommend renaming it to something without spaces, such as `mylibrary.xml`.
2 – Copy the directory `~/Library/Application Support/Delicious Library/Images/Small Covers` to the root of your web server.
3 – Edit the file `mylibrary.xml` (if that is the name you gave it) and add the line:

after then line that reads:

4 – Create a new file called `delicious-library.xsl` in the root folder of your web server and add the following text:


 ]>














Books

oddRow evenRow
Small Covers/   
Author:
Publisher:
Series:
Volume:

Books

oddRow evenRow

Movies

Small Covers/   
Author:
Publisher:
Series:
Volume:
oddRow evenRow
Small Covers/   
Author:
Publisher:
Series:
Volume:

5 – Now from you web server, if it is running on the same machine:

http://localhost/mylibrary.xml

If your web server is not your local computer, then you will simply have to modify the steps with uploading instead of copying. Always be sure to modify a *copy* of your files, and not the originals. You don’t want to get burnt if you make a mistake

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


Convert HTML to text

I forgot from where I copied this script:

#!/bin/bash
# Usage: convert-html-to-md […]
# Convert the specified HTML files into Markdown text-format equivalents
# in the current working directory. The file extension will be .md.txt.
# Requires the html2text.py Python script by Aaron Swartz to convert
# from HTML to Markdown text [www.aaronsw.com/2002/html2text/].
# html2text=”${1}”shift

[while [ -n “${1}” ] ; do
# Use the contents of the title element for the filename. In case
# the title element spans multiple lines, the entire file is first
# converted to a single line before the sed pattern is applied. Any
# “unsafe” characters are then replaced with hyphens to produce a
# valid filename.
title=$(cat “${1}” | \
tr -d ‘\n\r’ | \
sed -nre ‘s/^.*(.*?)<\/title>.*$/\1\n/ip’ | \<br /> tr “\`~\!@#$%^&*()+={}|[]\\:;\”\’<>?,/ \t” ‘[-*]’)</p> <p> # If there’s no title, then just use the original filename.<br /> if [ -z “${title}” ] ; then<br /> title=$(basename “${1}” .html)<br /> fi</p> <p> # Convert the HTML to Markdown.<br /> cat “${1}” | python “${html2text}” > “${title}.md.txt”<br /> shift<br /> done]</p> </div><!-- .entry-content --> <footer class="entry-meta"> Posted on <a href="http://johnlaudun.org/20080508-convert-html-to-text/" title="12:16" rel="bookmark"><time class="entry-date" datetime="2008-05-08T12:16:18-06:00" pubdate>2008 May 8</time></a><span class="byline"> by <span class="author vcard"><a class="url fn n" href="http://johnlaudun.org/author/johnlaudun/" title="View all posts by johnlaudun" rel="author">johnlaudun</a></span></span>. <span class="sep"> | </span> <span class="tags-links"> Tagged: <a href="http://johnlaudun.org/tag/code/" rel="tag">code</a>, <a href="http://johnlaudun.org/tag/html/" rel="tag">html</a>, <a href="http://johnlaudun.org/tag/python/" rel="tag">python</a>.</span> </footer><!-- .entry-meta --> </article><!-- #post-1997 --> <article id="post-2014" class="post-2014 post type-post status-publish format-standard hentry category-work tag-code tag-svn"> <header class="entry-header"> <h1 class="entry-title"><a href="http://johnlaudun.org/20080428-subversion-notes/" title="Permalink to Subversion Notes" rel="bookmark">Subversion Notes</a></h1> </header><!-- .entry-header --> <div class="entry-content"> <p>Here’s what a checkout request on the command line looks like:</p> <p> $ svn checkout http://svn.example.com/repos/calc<br /> A calc/Makefile<br /> A calc/integer.c<br /> A calc/button.c<br /> Checked out revision 56.</p> <p>### SSH Problems</p> <p>> ## Planet Argon, ssh, authorized_keys, and TextMate happiness</p> <p>> Been trying to get ssh-based password-free login going at Planet Argon (more on the transfer from DreamNightmareHost to Planet Argon in a future post). A couple of back-and-forths with the admins over there. Both they and this thread insist that ~/.ssh/authorized_keys needs to be chmoded to 600. This isn’t right. It only needs 644.</p> <p>But what the above thread pointed me to is that ~/ needs to be chmoded to 750. Voila! Now I can use Subversion, directly inside the best text editor on the Mac.</p> <p>Let’s just hope there aren’t any groups that need to write to my home directory.</p> <p>## Problems</p> <p> Toulouse:~ jjl$ ssh -v<br /> OpenSSH_4.5p1, OpenSSL 0.9.7l 28 Sep 2006<br /> usage: ssh [-1246AaCfgkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]<br /> [-D [bind_address:]port] [-e escape_char] [-F configfile]<br /> [-i identity_file] [-L [bind_address:]port:host:hostport]<br /> [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]<br /> [-R [bind_address:]port:host:hostport] [-S ctl_path]<br /> [-w local_tun[:remote_tun]] [user@]hostname [command]</p> <p>## Following Allan’s Advice</p> <p>Your identification has been saved in /Users/jjl/.ssh/id_dsa.<br /> Your public key has been saved in /Users/jjl/.ssh/id_dsa.pub.<br /> The key fingerprint is:</p> <p>Shakespeare was the pass-phrase used.</p> <p>## MacFusion</p> <p>Set up on 2007-04-28. Used SSH (which has the wild woman password by the way). Mounted like a charm. Now, let’s see what’s in there and how well this works.</p> <p>## SVN Checkout</p> <p>If you are using bash you should put this in your ~/.bash_profile (or a similar file which gets sourced when you open a terminal):</p> <p> export LC_CTYPE=en_US.UTF-8</p> </div><!-- .entry-content --> <footer class="entry-meta"> Posted on <a href="http://johnlaudun.org/20080428-subversion-notes/" title="20:39" rel="bookmark"><time class="entry-date" datetime="2008-04-28T20:39:28-06:00" pubdate>2008 April 28</time></a><span class="byline"> by <span class="author vcard"><a class="url fn n" href="http://johnlaudun.org/author/johnlaudun/" title="View all posts by johnlaudun" rel="author">johnlaudun</a></span></span>. <span class="sep"> | </span> <span class="tags-links"> Tagged: <a href="http://johnlaudun.org/tag/code/" rel="tag">code</a>, <a href="http://johnlaudun.org/tag/svn/" rel="tag">svn</a>.</span> </footer><!-- .entry-meta --> </article><!-- #post-2014 --> </div><!-- #content .site-content --> </section><!-- #primary .content-area --> <div id="secondary" class="widget-area" role="complementary"> <aside id="text-3" class="widget widget_text"> <div class="textwidget"><a href="http://johnlaudun.org/boat/" rel="attachment wp-att-7877"><img src="https://i0.wp.com/media.johnlaudun.org.s3.amazonaws.com/wordpress/media/2016/01/ACB-cover-small-103x150.jpeg?resize=103%2C150" alt="The Amazing Crawfish Boat" width="103" height="150" data-recalc-dims="1" /></a> <p style="line-height:1.1 "><small><em>The Amazing Crawfish Boat</em> is available at your favorite bookseller (both <a href="http://amzn.to/1rf9wAT">Amazon</a> and <a href="http://www.barnesandnoble.com/w/the-amazing-crawfish-boat-john-laudun/1121843205?ean=9781496804204">B&N</a>). I have also released some additional <em>free</em> materials: audio versions of some of the chapters and photos — all available for download. Details are available on the <a href="http://johnlaudun.org/boat/">book’s page</a>.</small></p></div> </aside><aside id="search-5" class="widget widget_search"> <form method="get" id="searchform" action="http://johnlaudun.org/" role="search"> <label for="s" class="assistive-text">Search</label> <input type="text" class="field" name="s" value="" id="s" placeholder="Search …" /> <input type="submit" class="submit" name="submit" id="searchsubmit" value="Search" /> </form> </aside><aside id="top-posts-2" class="widget widget_top-posts"><h1 class="widget-title">Top Posts & Pages</h1><ul> <li> <a href="http://johnlaudun.org/20131228-ipython-notebook-keyboard-shortcuts/" class="bump-view" data-bump-view="tp"> iPython Notebook Keyboard Shortcuts </a> </li> <li> <a href="http://johnlaudun.org/20150512-installing-and-setting-pip-with-macports/" class="bump-view" data-bump-view="tp"> Installing, and Setting, PIP with MacPorts </a> </li> <li> <a href="http://johnlaudun.org/20170928-append-python-list-using-list-comprehension/" class="bump-view" data-bump-view="tp"> Append a Python List Using a List Comprehension </a> </li> <li> <a href="http://johnlaudun.org/20130126-nltk-stopwords/" class="bump-view" data-bump-view="tp"> NLTK and Stopwords </a> </li> <li> <a href="http://johnlaudun.org/20181111-24-liter-daypack-comparison/" class="bump-view" data-bump-view="tp"> 24-liter Daypack Comparison </a> </li> <li> <a href="http://johnlaudun.org/20151219-jupyter-notebook-runtime-error/" class="bump-view" data-bump-view="tp"> Jupyter Notebook Runtime Error </a> </li> <li> <a href="http://johnlaudun.org/20080321-word-wrap-filling-in-emacs/" class="bump-view" data-bump-view="tp"> Word-wrap (filling) in Emacs </a> </li> <li> <a href="http://johnlaudun.org/20101212-an-existential-epiphany/" class="bump-view" data-bump-view="tp"> An Existential Epiphany </a> </li> <li> <a href="http://johnlaudun.org/20121230-macports-the-key-to-python-happiness/" class="bump-view" data-bump-view="tp"> MacPorts: The Key to Python Happiness </a> </li> <li> <a href="http://johnlaudun.org/20180603-understanding-how-beautiful-soup-works/" class="bump-view" data-bump-view="tp"> Understanding How Beautiful Soup Works </a> </li> </ul></aside> </div><!-- #secondary .widget-area --> </div><!-- #main .site-main --> <footer id="colophon" class="site-footer" role="contentinfo"> <div class="site-info"> <a href="http://wordpress.org/" rel="generator">Proudly powered by WordPress</a> Theme: Publish by <a href="http://kovshenin.com/" rel="designer">Konstantin Kovshenin</a>. </div><!-- .site-info --> </footer><!-- #colophon .site-footer --> </div><!-- #page .hfeed .site --> <div style="display:none"> </div> <script> jQuery(document).ready(function () { jQuery.post('http://johnlaudun.org?ga_action=googleanalytics_get_script', {action: 'googleanalytics_get_script'}, function(response) { var s = document.createElement("script"); s.type = "text/javascript"; s.innerHTML = response; jQuery("head").append(s); }); }); </script><script type='text/javascript' src='http://johnlaudun.org/wordpress/wp-content/plugins/jetpack/_inc/build/photon/photon.min.js?ver=20190201'></script> <script type='text/javascript' src='https://s0.wp.com/wp-content/js/devicepx-jetpack.js?ver=201926'></script> <script type='text/javascript'> /* <![CDATA[ */ var jetpackCarouselStrings = {"widths":[370,700,1000,1200,1400,2000],"is_logged_in":"","lang":"en","ajaxurl":"http:\/\/johnlaudun.org\/wordpress\/wp-admin\/admin-ajax.php","nonce":"469dbd2094","display_exif":"1","display_geo":"1","single_image_gallery":"1","single_image_gallery_media_file":"","background_color":"black","comment":"Comment","post_comment":"Post Comment","write_comment":"Write a Comment...","loading_comments":"Loading Comments...","download_original":"View full size <span class=\"photo-size\">{0}<span class=\"photo-size-times\">\u00d7<\/span>{1}<\/span>","no_comment_text":"Please be sure to submit some text with your comment.","no_comment_email":"Please provide an email address to comment.","no_comment_author":"Please provide your name to comment.","comment_post_error":"Sorry, but there was an error posting your comment. Please try again later.","comment_approved":"Your comment was approved.","comment_unapproved":"Your comment is in moderation.","camera":"Camera","aperture":"Aperture","shutter_speed":"Shutter Speed","focal_length":"Focal Length","copyright":"Copyright","comment_registration":"1","require_name_email":"1","login_url":"http:\/\/johnlaudun.org\/wordpress\/wp-login.php?redirect_to=http%3A%2F%2Fjohnlaudun.org%2F20150901-what-is-code%2F","blog_id":"1","meta_data":["camera","aperture","shutter_speed","focal_length","copyright"],"local_comments_commenting_as":"<p id=\"jp-carousel-commenting-as\">You must be <a href=\"#\" class=\"jp-carousel-comment-login\">logged in<\/a> to post a comment.<\/p>"}; /* ]]> */ </script> <script type='text/javascript' src='http://johnlaudun.org/wordpress/wp-content/plugins/jetpack/_inc/build/carousel/jetpack-carousel.min.js?ver=20190102'></script> <script type='text/javascript' src='http://johnlaudun.org/wordpress/wp-includes/js/mediaelement/wp-mediaelement.min.js?ver=5.2.2'></script> <script type='text/javascript' src='https://secure.gravatar.com/js/gprofiles.js?ver=2019Junaa'></script> <script type='text/javascript'> /* <![CDATA[ */ var WPGroHo = {"my_hash":""}; /* ]]> */ </script> <script type='text/javascript' src='http://johnlaudun.org/wordpress/wp-content/plugins/jetpack/modules/wpgroho.js?ver=5.2.2'></script> <script type='text/javascript' src='http://johnlaudun.org/wordpress/wp-content/themes/publish/js/small-menu.js?ver=20120206'></script> <script type='text/javascript' src='http://johnlaudun.org/wordpress/wp-includes/js/wp-embed.min.js?ver=5.2.2'></script> <script type='text/javascript' src='https://stats.wp.com/e-201926.js' async='async' defer='defer'></script> <script type='text/javascript'> _stq = window._stq || []; _stq.push([ 'view', {v:'ext',j:'1:7.3.1',blog:'33779968',post:'0',tz:'-6',srv:'johnlaudun.org'} ]); _stq.push([ 'clickTrackerInit', '33779968', '0' ]); </script> </body> </html>