I have left Harvard as of July 1, 2008 to take a position at NYU. This website has been cached and left static. Feel free to browse my new website, aka "What the heck is a Clinical Associate Professor?"

04.08.08

Google Summer Of Code LaTeX Project

Posted in LaTeX, Web at 8:48 am by leingang

The TeX Users Group will be participating as a mentoring organization in the Google Summer of Code program, and my project of a Dublin Core metadata interface was accepted.  I’m hoping some enterprising youth with lots of experience in programming TeX will be interested in the project.

Here is an overview of the project: Dublin Core is a scheme for expressing metadata (data about data) in a reliable, machine-readable way.  It can be expressed in various languages, including RDF, which can itself be serialized in XML.  Adobe’s eXtensible Metadata Platform allows RDF+XML statements to be embedded into PDF files.  This metadata can then be read by search engines in order to give context to the document besides its simple contents. 

TeX and LaTeX can be used to produce PDF documents, and have rich macro-programming environments.  One goal of the project is to add simple commands which can write the complex metadata statements into the PDF without the user needing to know anything about RDF, XML, or Dublin Core itself.  Another goal would be for more advanced users to augment this interface with new Dublin Core element sets and vocabularies.

I’ve always taken an interest in the semantic web, and apparently there aren’t too many people in this group also interested in TeX.  So if the project flies I think it could be very useful.

Blogged with the Flock Browser


Tags: , ,

03.20.08

Number pages within chapters in LaTeX

Posted in LaTeX at 9:17 am by leingang

In latex, the \numberwithin command allows one to bind one counter with another. A common example is the section counter and the chapter counter. When a new chapter is created, the chapter counter increments, and the section counter is reset. In this scheme, if the last section of chapter 1 is labeled “1.5″, the first section of chapter 2 is labeled “2.1″.

In the process of preparing a large handout, put together in stages and repeatedly distributed, a student asked if I could number the pages of a document within the chapters. So each page would be labeled chapter-page, and the first page of each chapter would be page 1.

Sounded simple enough: just use

\renewcommand{\thepage}{\arabic{chapter}-\arabic{page}}

(this changes the way pages are labeled) and

\numberwithin{page}{chapter}

to change the numbering. But this doesn’t quite do it, because \numberwithin resets the counter to zero, and so the first page of chapter 4 gets labeled as “4-0″. I need to start a new chapter, then reset the page counter to one, not zero.

There is probably a package which does this, but five minutes of googling didn’t produce it. So I started to roll my own. One can write a \Chapter command that calls \chapter then resets the page counter. The disadvantage here is that (1) you have to search-and-replace existing code, and (2) \chapter is a pretty complicated command with a starred version and an optional argument. The \chapter macro calls lower-level macros and actually returns a seven-argument macro with four arguments filled in. So rather than call the \chapter macro, I want to make adjustments, then return \chapter so that it can parse as normal. That’s when I tried:

\let\oldchapter=\chapter
\def\chapter{\resetcounter{page}{0}\oldchapter}

This adds the page reset to the beginning of the chapter, without changing the way it’s used. The trouble is that \chapter clears the page before starting the new chapter, and that page needs a label. So this made sure the first page of Chapter 4 was labeled 4-1, but now the last page of Chapter 3 got labeled 3-0!

What I needed was to return \chapter, but make sure LaTeX executed the \resetcounter command right afterwards. The solution is \expandafter, which defers token expansion by one position. From The TeXBook:

TeX first reads the token that comes immediately after \expandafter, without expanding it; let’s call this token t. Then TeX reads the token that comes after t (and possibly more tokens, if that token has an argument), replacing it by its expansion. Finally TeX puts t back in front of that expansion.

And here’s the implementation:


\let\oldchapter=\chapter
\def\resetpage{\setcounter{page}{1}}
\def\chapter{\expandafter\resetpage\oldchapter}

The parsing works like this: upon reading the new \chapter macro, TeX encounters \expandafter, reads \resetpage but holds onto it. It then expands \chapter, which under the hood returns that seven-argument monster macro. At that point \resetpage is called.

Update 2008-04-08: Peter tells me the package I’m looking for is chappg.  Should have googled more!

Blogged with the Flock Browser

Tags: , ,

12.21.07

To Friend or Not to Friend?

Posted in Web at 4:23 pm by leingang

My old colleague and friend Derek is planning a workshop session on Facebook for graduate student teachers.  He may admit that I told him to get on the Facebook bandwagon.  It turned out he asked for my thoughts at the very moment I was planning to write this post.

Facebook is the social networking application for people currently now in college, recent graduates of college, college-bound high school students, and those who work in a higher ed environment.  It’s also extremely popular in Canada: 10% of Canadians have a Facebook page!  I think that having a Facebook page is an important part of being findable and accessible online, much like having an e-mail address used  to be 15 years ago and having a personal website 10 years ago.  Still, there are issues and mores about expected barriers that need to be respected.

People of different generations use Facebook in different ways.  Those who were in college or close to it at the time Facebook was born use it to communicate with each other, upload and share photos, and express themselves in the young and exuberant manner they’re accustomed to.  Professionals often use their facebook pages to promote their work selves, either subtly or overtly.  Academics are caught somewhere in between, having Facebook contacts (or “friends”) in both arenas.

One popular feature of a person’s Facebook profile is the “Wall,” an area on which a user’s Facebook friends can write whatever they want.  It reminds me of the message board I attached to my dorm room door when I was in college.  Fellow students who dropped by and didn’t find me could leave a note, or say something interesting, or say something stupid…you probably have similar memories. 

The Wall scares me now.  I don’t want anyone to write anything they want on my page.  That’s my page and I want control over it.  Luckily, those who use my wall are either my student friends, who are respectful out the fact that they usually want something from me :-) , and my in-real-life friends who are obeying the golden rule.

The message board analogy extends to the entire Facebook experience.  Students treat their Facebook pages as their online dorm rooms.  They feel free to let down their hair, join groups for various serious and silly causes, post wide-eyed party pictures of each other with oh-so-convenient camera phones, and essentially bring their entire student life online. 

I feel more like my Facebook profile is my online office.  I only put up stuff that I would be comfortable with all my Facebook friends seeing, and that includes my students (I might as well include my Mom in that group, except we’re not Facebook friends.  We are LinkedIn contacts, strangely enough).  This means I don’t get an online dorm room, but I’m of a generation that doesn’t feel the need for that.

Derek pointed out a nice extension of the analogy.  I encourage my students to drop by my office.  But students probably wouldn’t want me dropping by their dorm rooms.  The difference in social protocol is inherent and can’t be leveled by a website. 

I respect that difference.  I’ll accept friend requests from all students, but I don’t friend my students.  I put my work on my Facebook page but only secondarily to the official course websites;  I don’t force students to use Facebook to find it. 

Facebook seems to be very hip to the needs of students and tries to provide one-stop shopping.  They didn’t invent photo sharing, but they adopted it and now host more photos than Flickr.  They added marketplaces to co-opt student use of craigslist. They opened up their application programming interface so that anyone can create an application as part of Facebook.  So I see the day when university websites–including course sites–will be totally integrated in Facebook.  But then again, that might make Facebook suddenly unhip and students will run to the next thing.  Until then, I’ll be in my (online) office; drop on by.

Blogged with Flock


Tags:

11.29.07

Texify

Posted in Math, LaTeX, Web at 9:42 am by leingang

I installed the LatexRender plugin to my WordPress blog to express myself in mathematical notation that HTML alone can’t handle.  It runs latex on the server side and serves up an image embedded in the text.

For mathematical bloggers who don’t have access to their webservers (or choose not to get their hands dirty with server-side code), there’s Texify, a nice web service that lets you input LaTeX and get a permalink to a graphic that you can include in your web pages.  For instance, I copied-and-pasted some code from a slideshow I’m working on and got this:

\begin{align*} \frac{\partial f}{\partial x_i}(x_1, x_2, \dots, x_n) &= \lambda \frac{\partial g}{\partial x_i}(x_1, x_2, \dots, x_n) & \text{for each $i=1,\dots,n$}\\ g(x_1, x_2, \dots, x_n) &= 0.\end{align*}

I’m impressed that they seem to have enabled the amsmath packages in their backend, so some of the more sophisticated mathematical constructs can be used (I’m using an align* environment and the \\text command up there).

The site also provides code to copy-and-paste into BBCode posts such as you’d find on forums, and even Google Docs!

(HT: Michael Tsai)

Blogged with Flock


Tags: , ,

11.16.07

Social bookmarking for courses

Posted in Education, Web at 3:02 pm by leingang

I was at the monthly web pegagogies free lunch sponsored by the Bok Center today and we talked a little about using social bookmarking sites like del.icio.us to collect bookmarks as a group. (There was also a nice demonstration of Facebook by two students, but I’ve already blogged about a similar presentation they made last Spring). I like the idea, but I’m wondering about the methodology.

In the examples of this that I’ve seen, a delicious account is created and the password is given to all the students in the group. The account is given a course-specific username like “history1667″ Then students use that account to save tagged bookmarks relevant to the course. Then to view all the bookmarks tagged by the group you go to the group’s user page.

I think this unnecessarily confuses the distinction between a user and a tag. It seems to me that people in the group should use their own delicious accounts to add a “history1667″ tag to their bookmarks. Then you can view the collection of pages tagged for the course by looking at that tag’s page.

That would certainly result in more links as students who already use delicious regularly wouldn’t have to log out/log in to do their research (delicious integrates well with browsers and can be hard to extricate). And it means that people could add links to that collection even after they left the course, and new students would have at their fingertips all the old links, without having to worry about passwords. And the entity “History 1667″ seems more to me like an attribute of the link than an agent in and of itself.

I’ve started doing this for my courses. If I’m looking at a page that might be useful for my Math 20 or Math 21b course, I can just tag it. I don’t have to re-login. I can tag the same page for as many of my courses as I want. And if my students want to do the same, the bank becomes richer.

There are, I suppose, reasons for having a controlled account. There might be another course numbered History 1667 at another university. Well, make the tag less common (I almost said “more unique” there) by calling it “HUHist1667″ or “HUHist1667Fall2007″ (then, if you want a fresh batch every semester you just change the tag). Most delicious interfaces feature tag-completion so you don’t even have to worry about it being easy to remember. Or, you can just apply the philsophy of folksonomy: don’t worry about it. Tag clouds make sure that the most important (as defined by user activity) links bubble up. It’s only going to become a problem if the tag is used by two groups equally frequently, which is unlikely and can by choice of tag name be made even less likely.

Another worry might be that outsiders might start using the tag to randomly bookmark irrelevant things like, as someone suggested, a picture of a cat. Again, I think the response is don’t worry about it. A basic tenet of semantic web philosophy is that anybody should be able to declare anything about anything, and it’s up to another layer to endow the trust. In this case, the user him/herself is the trust layer by visually weeding out the irrelevant links, and the tag cloud by making pages more users have marked with the same tag more connected to that tag.
A third objection might be that we don’t want to force students to create accounts on third-party services if they don’t want to, or to open up their use of a third-party service to a class. I can kind of see that, although delicious is for sharing bookmarks, so if you don’t want to share them with the world, why are you using it? But I can see wanting to share different things with different groups (and under different identities). So then maybe you have a group account for those who don’t want one, or encourage users have don’t want to use their “private” delicious accounts to create another one specifically for coursework.

So there’s a tradeoff between openness and quality, but I say, the more the merrier.

Blogged with Flock

Tags: , , , , , ,

09.27.07

Hacking your signature file (baseball bragging rights division)

Posted in Computing at 10:06 am by leingang

I wanted to blog about this for a while, and suddenly it’s almost too late. I hacked together some stuff to put the Red Sox’ magic number for clinching the American League East division in my e-mail signature automatically. The process is replicable for any kind of updating content.

About the magic number

In case you’re still confused, the magic number for a team in first place is a countdown to the “clinching” or mathematical assurance of the championship. Every time the team in first place wins, the number goes down. Every time the team in second places loses, the number goes down. When the number reaches zero, the race is over.

The race is clinched when the first place team is more games ahead of the second-place team (and all the other teams) than the number of games remaining. So one way to define the magic number is the lead in the standings, minus the number of games remanining, plus one or rounded up in the case of half-game differences in the standings. What amounts to the same thing, however, is the total number of games in the season, minus the number of wins by the first-place team, minus the number of losses by the second place team, plus one. It’s clear by that last definition that it does what you want (goes down with each win by first-place team or loss by second-place team), and the number of games plus one makes it reach zero at the point of clinching.

The Red Sox have been in first place in the AL East since April, and although they have been in first place a lot, they have not finished the division in first place since 1995. I’ve had the magic number in my signature since it was in the 60s (shortly after the all-star break), and today it stands at two. Which means the division could be clinched today.

Generating the content

The idea is simple: write a script which visits an internet location of baseball standings and munge that data to get the magic number. There are tons out there, such as every newspaper’s website or the megasites like EPSN. Scrolling through source code of Dashboard widgets I found out that MLB publishes this data in a lightweight, machine-readable format on a secret page. Today’s AL East standings can be found at

http://mlb.com/components/game/year_2007/month_09/day_27/standings_rs_ale.js

This file has lots of standings data in the form of a JavaScript object. This is really useful if you’re writing a JavaScript program to display the standings. XML would have been another choice, but this is just as easy to parse, maybe even easier. Also, this resource includes the magic number, not that your script couldn’t calculate it for you. Here’s an excerpt from the file:

var standings_rs_ale = [{
w: '94',
elim: '-',
rs: '850',
div: 'ale',
gameid: '2007_09_27_minmlb_bosmlb_1',
status: 'P',
pre: null,
last10: '5-5',
onerun: '22-26',
xtr: '2-5',
nextg: '9/27 v MIN, 7:05P',
vsW: '20-17',
ra: '643',
gb: '-',
wrap: '/news/wrap.jsp?ymd=20070926&content_id=2231984&vkey=wrapup2005&fext=.jsp&c_id=mlb',
home: '49-28',
code: 'bos',
pct: '.595',
league_sensitive_team_name: 'Boston',
vsC: '20-11',
vsE: '42-30',
vsR: '69-41',
vsL: '25-23',
xwl: '99-59',
strk: 'W2',
l: '64',
lastg: '9/26 v OAK, W 11-6',
interleague: '12-6',
team: 'Boston',
road: '45-36'
}, ...

There’s one of these records for each team in the division. The “elim” key is the magic number to be eliminated, so the Red Sox’ magic number can be found as the “elim” value for the second-place team.

I wanted to write this part of the program in python. I like perl, too, but I’ve been flummoxed trying to re-read my own perl scripts after setting them aside for a while. Python is hyper-strict on syntax but that makes it pretty easy to read.

Seeing the page in JavaScript made me think of JSON, a data-interchange format similar to JavaScript syntax. I thought parsing the JavaScript data in python would be as easy as reading it and hitting it with a python JSON library. Not quite. The standings page is valid JavaScript but not valid JSON. But rather than write my own parser I decided to massage the included JavaScript string so that it did parse as JSON. A little quoting of key values, switching double and single quotes, and getting rid of html links did that trick.

So here’s my script, which I saved as ~/Library/Scripts/getmn.py:

#!/sw/bin/python

# Get the Red Sox magic number

import cjson, re, urllib, datetime

today=datetime.date.today()
mlburl=”http://mlb.com/components/game/year_%04d/month_%02d/day_%02d/standings_rs_ale.js” % (today.year,today.month,today.day)
rawdata=urllib.urlopen(mlburl).read(-1)
(varname,data) = rawdata.split(’=',1)
# although this data is legal javascript, it’s not JSON. So we have
# to munge it a bit:
# quote property names with double quotes
data=re.compile(”\t([a-zA-Z0-9_]+):”,re.M).sub(’\t”\\1″:’,data)
# get rid of links
data=re.compile(”<a[^>]*>|</a>”).sub(”",data)
# replace single quotes by double quotes
data=data.replace(”‘”,’”‘)

dd=cjson.decode(data)

if (dd[0][’team’]==’Boston’):
print “Red Sox magic number: %d” % (int(dd[1][’elim’]))
What I like about this script is that it does very little lifting of its own, farming out most of the retrieval, data-crunching, and parsing. Even the massaging is done with ultra-powerful (as a class, not to say that mine are) regular expressions. This script works on the command-line if that’s all you want.

Adding the content to the sig

I use Microsoft Entourage for reading my mail and keeping calendar and contact info. I’m not in love with it but it is AppleScriptable, so you can do a lot with it. I wrote an AppleScript to run my magic-number-getter and append it to my standard “work” signature (that has my title, address, and a link to my vCard file in it):

set theScript to quoted form of POSIX path of (path to home folder as string) & “Library/Scripts/getmn.py”

set crlf to (ASCII character 13)

tell application “Microsoft Entourage”

set txt to do shell script theScript

set defaultSig to the content of the first signature where name is “Harvard”

set theSig to the first signature where name is “Harvard + Red Sox”

set the content of theSig to defaultSig & crlf & crlf & txt

end tell

AppleScript is a pain in the rear to write—it takes a lot of trial and error. But once it’s done, it reads pretty well. The crlf’s just insert blank lines.

If you have a different mail reader, this is going to change. But I’m confident the idea will work in Apple’s Mail.app as well.

Automatically updating

I saved this script in the folder ~/MIcrosoft User Data/Entourage Script Menu Items/ as “Get Red Sox Magic Number for Signature” So it’s accessible within the Script menu of Entourage.

But the final feature I wanted was to have that information update automatically. Entourage also has a scheduler, so I configured a job to run this script once a day:

That’s it! The workflow is easily copied for whatever oft-changing data you would want in your signture (for instance, the output of /usr/bin/fortune).

PS: While researching this post I found a site (with various different URLS) that computes the magic number for you and gives you HTML widgets. Plus a lot of Google ads, but useful all the same.

technorati tags:, , , , ,

Blogged with Flock

Resizing PDFs

Posted in Computing, LaTeX at 8:57 am by leingang

Yesterday I used my Facebook status line to say I was wondering how to resize PDFs. This seems to be a nontrivial issue. I have at least one workaround now, though.

Background: In my classes I often make slideshows with beamer (yay beamer)! It’s a great package for those who need the full flexibility of TeX or LaTeX to present math-rich course material. Some of my colleagues use Keynote with pretty good results, too. You can cut-and-paste PDF from TeXShop (an open-source TeX development environment for Mac OS X) to Keynote, with antialiasing and everything “just working”, and apply all of Keynote’s bells and whistles. (Among devotees of this technique is my colleague Tom, who likes the blackboard theme and the page-turning transition. Kind of mixing metaphors, if you ask me, but he didn’t. :-) )

I also use the InterWrite pad for classes, which allows me to draw on the screen and/or annotate the slides I’ve made. Anything that’s annotated gets attached to a file, which can be exported to PDF. It taxes my laptop’s speed, but I have a 4 year old laptop.

After classes I had been posting the slides and the screen notes as separate PDFs. This wasn’t ideal, because the notes file only has the slides I annotated. What I wanted was something that was as close to what happened in class as possible. Then I realized that Acrobat (among other tools, but I have access to Acrobat Pro so why not use that) can rearrange pages of PDFs, so it’s possible to merge the two into one file and post that.

Until yesterday this has worked fine. But suddenly my screen notes PDF came out at a different size. The slides are 128mm x 96mm and you use the reader or view to blow them up to screen size. After cropping the notes, however, the page of writing was for some reason closer to 210mm wide. I wanted to shrink that down to 128 so the merged document would have all its pages the same size.

So I never figured out how to do that in Acrobat Pro. The philosophy is that PDF is “electronic paper,” meant to be a published version of a document, so a lot of editing methods aren’t provided. You can annotate a PDF (in Acrobat Pro or also in Preview), decorate it with a rubber stamp, or move pages around, but you can’t for instance erase parts of a document (although you can white them out).

But LaTeX users are familiar with including graphics into their documents with the graphicx package. PDF is a popular format for included graphics, especially on the Mac. Graphicx does allow scaling of images, which on vector-based PDFs doesn’t lose any detail. Finally, the pdfpages package provides a frontend to including whole pages of a multi-page PDF rather than embedding a graphic on a page, with graphicx-style options.

So here’s what I did: created a wrapper in LaTeX that looked like this:

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-,width=128mm,fitpaper]{interwrite_notes.pdf}
\end{document}

Then I pdflatex-ed that file and the resulting PDF was exactly what I wanted.

I’m still kind of surprised that there’s not a Acrobat Pro-based solution to this.  But this works; it’s simple enough to be automated into a script, and it’s free, although it requires a TeX installation. 


technorati tags:, ,


Blogged with Flock

09.03.07

Running arbitrary text munging commands in TeXShop

Posted in Computing, LaTeX at 12:15 pm by leingang


File this under “If I blog about it, it might actually be worth the time it took to figure it out”…

I use TeXShop to handle my LaTeX documents. It works, it’s mac-like, and it’s pretty flexible. One thing I like about it is the Macro Editor, where you can define some boilerplate strings to insert in the document (and tie keyboard shortcuts to them). The Macro Editor has some simple replacement features: for instance #SEL# will get replaced by the current selection. In this way, you can define a macro which wraps an enviroment around whatever’s currently highlighted. The Macro Editor also allows you to write AppleScript code and execute it.

Another thing I like is the regular-expression enabled find and replace dialog. Anything you can write with a sed one-liner, you can use to transform text.

But what I needed was to be able to do this:

  • highlight text in TeXShop
  • run a macro that transforms that text (something more complicated than a single regex search-and-replace), probably running AppleScript which in turn would run a shell script.
  • replace the selected text with the transformed text.

The actual job I wanted to do was to take the text exported by OmniOutliner, which is plain text with items indented and marked by “-”, and convert it to the LaTeX itemiz environment.

The Google wasn’t helping me with examples on how this is done, so I had to figure it out myself. First, I forgot about writing the macro inside of TeXShop; I used Apple’s built-in (at least I think it’s built-in, if not, you have to install the giant XCode package) Script Editor.

Writing AppleScripts is a pretty trying process of wading through Script Dictionaries and reading the Result Log and multiple, multiple trials and errors. In fact, Chapter 3 of AppleScript: The Definitive Guide shows that this is actually the Best (available) Practice (for some reason that got left out of the latest edition. Pity.) But I got it, eventually:

convert Omni Outliner exported text to LaTex itemize environment

Matthew Leingang

2007-09-03

set crlf to

tell application “TeXShop”

set theSelection to the selection of the first document

set input to the content of the selection of the first document as string

write selection to a file to avoid quoting issues

putting “as string” in the definition of input makes this file an ascii file rather than a unicode file

set fileSpec to (path to temporary items folder as string) & (do shell script “echo $$”)

try

set f to open for access fileSpec with write permission

set eof f to 0

write input to f

close access f

on error

try

close access f

end try

beep

return

end try

do the actual text munging

set theScript to “perl -pe ” & quoted form of “s/^( *)- /\\\\item\\n\\1 /” & ” < ” & quoted form of POSIX path of fileSpec

set output to “\\begin{itemize}” & crlf & (do shell script theScript) & crlf & “\\end{itemize}”

remove the temporary file

do shell script “rm ” & quoted form of POSIX path of fileSpec

replace

set the selection of (first document) to output

end tell

The code block below “–write selection as a file…” takes the current selection and writes it to a temporary file.  There are ways of escaping troublesome characters on the command-line, but AppleScript is not a very good text editor.  So I went the way of the temporary file, which, as you can see, involves generating a path name, opening the file, erasing the file, writing the selection to the file, then closing the file.

It was here I ran into one of my favorite AppleScript gotchas: the selection has type “unicode text”, while shell scripts have type string.  Because of the extra bytes in unicode strings, my regexes would match only when they were one character long!  This is the kind of thing you can only catch when you examine that temporary file in the Terminal: you get all the extra non-printable bytes and you think “what the hell?  Aw, man, unicode <curse />.”

Casting the selection to a string fixes this.  I suppose it breaks unicode compatibility, but regular LaTeX isn’t unicode compatible anyway (you need XeTeX for that).  I briefly tried casting the shell script string to unicode, but since I wasn’t going to need unicode for the input, I didn’t pursue it beyond one trial, error, undo.

the “echo $$” script in the generation of the temporary file name is a big of unix magic: $$ evaluates to the number of the operating system’s current process.  Basically, the OS starts a new process each time it runs a program, so each execution of the script is going to result in a new process number.  I actually don’t know what process this evaluates to, that of the AppleScript instance or a brand-new one spawned by this line, only to provide its number and die.  The point is it’s unique to the running of the script, so I know that running it twice at the same time (or starting another run of it while one hasn’t finished) won’t result in the script clobbering its temporary files. 

The code block below “–do the actual text munging” is the meat of this script. I don’t want to blog about perl or regexps here (maybe some other time), so let me just leave that with one piece of advice: when nothing else seems to work, add more slashes.

The rest of the script does the actual replacement of the selection with the desired transformed text, then cleans up. 

I haven’t yet tried this with multiple documents open (I can’t figure out how to access “the current document” in TeXShop), but this is a good start.  If you enable the Script Menu and save this script in “~/Library/Scripts/TeXShop/munge.scpt,” you can now invoke it whenever you want.  But to invoke it within the Macro Editor, you can create a macro and put “–Applescript direct” on the first line and delete the “tell” … “end tell” lines.  That changes the behavior of the Macro Editor to run the contents of the macro in AppleScript (rather than insert the text itself into the current document). 

So there’s plenty more error checking to do, but this works and I’m done with it.  Hopefully putting this up will help me remember, and anyone else who needs to do the same thing.


technorati tags:, , ,


Blogged with Flock

08.07.07

Want to go to B-School? Better brush up on PowerPoint!

Posted in Computing, LaTeX, Funny, News at 2:43 pm by leingang

That may be good advice for up-and-coming businesspeople, but it’s actually becoming literally a requirement. Apparently the University of Chicago is requiring Business School applicants to submit PowerPoint-Like Slides as part of their application.

“In four slides or less,” the online instructions say, “please provide readers with content that captures who you are.”

Is this a Good Thing or a Bad Thing? Neither, I guess. PowerPoint is a tool, and it can be used for evil as well as good. I hope these applicants read The Cognitive Style of PowerPoint by Edward Tufte. He’s a master of visual expression and has many good points of advice and examples of bad slideshow usage.

The article goes on to say that things may not be as bad as they seem. Applicants are still retaining creativity by submitting poetry, photos, even a play. And the admissions committee says it’s more fun than reading essays.

Bad slideshows aren’t limited to business or government, though. I’ve been to many talks where sitting in the back of the room I couldn’t see the slides because the speaker had crammed so much text onto the page. When that happens, the slideshow becomes distracting.

Instead, I try to put no more than three bullet points on a page. Bullet points shouldn’t be too long; they should only give the next few topics I’m going to talk about. The actual text I want to say goes in a separate document–my notes–which I keep with me (PowerPoint does this for you in the notes pane). If I need to show my audience something more complicated, I put it in a third document–a handout–which I copy and hand out.

I use the excellent beamer class for LaTeX to produce slideshows for my classes. My students love them–it’s a nice resource to have to supplement class notes. I can’t use PowerPoint because of all the equations and mathematical notation I need to put into my slides (don’t you dare say “Equation Editor”), but with beamer I get a nice PDF that I can page through. Hyperlinks in the PDF allow me to jump back and forth, and I can even embed media (not that I have a lot of other media).

Just for laughs: here’s the Gettysburg Address in PowerPoint:



technorati tags:, ,


Blogged with Flock

07.07.07

Lessons in software installation: iTunes 7.3 version

Posted in Computing, Mac at 10:12 am by leingang

Mac OS X cheerfully lets you know when new versions of its software are released. Usually this is a good thing. Even when you don’t need the update, sometimes it’s easier to go ahead and take it rather than be nagged by the reminder all the time.

Consider the latest (7.3) release of iTunes. it has new support for AppleTV and the iPhone. I have neither, but I figured I’d go ahead and update.

Suddenly, iTunes stopped working. Upon starting, it would read the library, present the browser window, but before I could click anything, it would crash. Here’s my (definitely not complete, and probably not optimized) flowchart for recovering from errors like this:

Step 1: Try again. This isn’t supposed to work. I mean, computers ought to be deterministic, so the same thing should happen every time you perform the same sequence of events. But some bugs really are ephemeral, and so sometimes just trying again does work.

Actually, I read a magazine article by a guy who tried to document exactly what he did every time he encountered a software error he didn’t expect. Almost every time, despite his better judgment and his self-observation, his first step was to try the same thing again Maybe it’s like reflexively saying “What”? when you didn’t quite hear what someone said.

Step 2: Standard Resetting and Maintenance. Some of these tasks are kind of like spells that you cast in hopes that they work. Someone I know worked in tech support for a year with absolutely no computer skills. The advice he most frequently gave (I guess the users had passed the “try again” step) was “reboot.” A clean reboot can get rid of stuff that’s happened since the last startup that’s getting in the way without you knowing it.

Regarding macs, I often see the advice to “repair disk permissions.” Not a bad idea. Another one people suggest is to force the periodic tasks:

$ sudo periodic daily
$ sudo periodic weekly
$ sudo periodic monthly

These are tasks your computer should be doing every day, week, and month anyway, and unless you’ve done something seriously wrong, they’ll succeed. They may not affect the problem, though.

A third option here is to get rid (or hide) preference files that might be corrupted. In ~/Library/Preferences there are lots of .plist, files which can get corrupted and prevent appliction launch. They have funny, java-style names like “com.apple.iTunes.plist” but you can usually recognize the problem application’s file. Trash it or move it to the Desktop and relaunch to let the application recreate it. If that works, you’ll have to restore the preferences you liked manually, but that’s usually better than not having the application at all.

None of this worked for iTunes 7.3 which is when I moved on to…

Step 3: Google. There are so many software support sites out there, whether for applications or operating systems, and so many users that you can be reasonablly assured that you’re not the first to have had this problem and hopefully somebody who’s gone before you figured it out. I googled “iTunes crashes” but I found a lot of stuff relating to old versions (and references to some of the spells above.” So be more specific: googling “iTunes 7.3 crashes” brings up pages on VersionTracker and MacUpdate about the problem. Apparently 7.3 is not ready for prime time. Good to know, but what now? That brings me to…

Step 0: Backup. (meaning, to duplicate)

Step 4: Back up. (meaning, to retreat) Luckily, I had backed up my hard drive this week. So I went and copied last week’s iTunes over the new one. Hey presto! back in time to a working iTunes version. And I’ll ignore the nag to update to 7.3 until I see 7.3.1.

What about Step 0? After advice from my sysadmin at work, I installed SuperDuper! a while ago. It makes a bootable copy of your hard drive. This means not only do you have a browsable backup to restore files and applications, you can restart using the backup (upon reboot, hold the option key, then select the backup drive). The pro version of SuperDuper! does incremental backups (a backup of all 80GB or whatever on your internal HD does take a long time), as well as a scheduler so you be reminded to do it periodically.

I have the tendency to not want to buy software, especially for something as easy as backup, which after all can be done pretty easily with a little unix. But think about it: if you lost your entire documents folder, with all your work, pictures, music, and everything, how much would you pay to get it back? It’s called insurance.

And if you need iTunes 7.2 yourself and don’t have a backup, I learned through MacUpdate that you can get it on Oldapps. God bless the web. :-)

technorati tags:, , ,

Blogged with Flock

« Previous entries ·