the Little Projects of Shawn M. Jones /blog the life and times of a man in 21st Century America Sat, 06 Dec 2014 18:06:07 +0000 en-US hourly 1 http://wordpress.org/?v=4.3.1 Living on the Unix Command Line: The Importance of a Prompt /blog/2014/12/06/living-on-the-unix-command-line-the-importance-of-a-prompt/ /blog/2014/12/06/living-on-the-unix-command-line-the-importance-of-a-prompt/#comments Sat, 06 Dec 2014 18:05:19 +0000 /blog/?p=382

Over the last decade, I’ve continued to gravitate more and more toward Unix and the command line while many of my colleagues have gravitated toward GUI applications. This post is not about the pros and cons of GUI vs. CLI or how one is better than the other. Suffice it to say, I live with both, but spend a lot of time working in terminals.

Today we focus on the prompt. Many people leave the prompt set to the default for their distribution, which may be fine, but in my 20 years of Unix use, I’ve found some nice tweaks that make my life easier. I share them here because you may find them useful as well.

The default prompt for a Red Hat Enterprise Linux system looks like the following:

[smj@athena bin]$

This gives me an idea of which user I’m logged in as (smj), which server I’m logged in to (athena) and the current working directory (bin). Unfortunately, in the example above, my current working directory is actually /usr/local/bin. Based on the default prompt, I cannot tell if I’m in /usr/local/bin, /opt/bin, /usr/bin, /bin, or even /home/smj/bin. This presents a problem considering how often much of the Unix directory structure repeats itself.

Another issue I have is that I’m pretty sure I’m logged in to the bash shell, but can’t really be sure. I’ve had to endure many shells in my career, from sh to bash to csh to tcsh to ksh and some I can’t even remember because they appeared so infrequently.

So, to address these problems, I spent time trying to find a prompt that would provide enough information to be useful, while working across several platforms and shells.

My current bash prompt looks like so:

18:30:33 smj@athena:/usr/local/bin
bash $ -->

My current tcsh prompt looks like so:

18:40:01 sjone@procyon:/usr/local/bin
tcsh % -->

There is no color in either prompt. This avoids any issues between different terminal color schemes or terminal types. It works equally fine in the Linux console and hpterm.

You may be asking, why does he need all of this information in the prompt? Let’s review each part of my prompt.

Newline at start

Consider the following text from an open terminal with a prompt containing no information:

total 892
-r-sr-xr-x. 1 root bin 234404 Aug  3 18:35 cdcc
-r-xr-xr-x. 1 root bin  44568 Aug  3 18:35 dccif-test
-r-sr-xr-x. 1 root bin 627422 Aug  3 18:35 dccproc
#cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
#128.82.7.27 e-2104-13 e-2104-13.cs.odu.edu
#netstat --inet
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 athena.littleprojects.o:ssh 192.168.191.210:5011        TIME_WAIT
tcp        0    116 athena.littleprojects.o:ssh 192.168.191.210:5012        ESTABLISHED
tcp        0      0 athena.littleprojects.o:ssh 192.168.191.210:5013        TIME_WAIT
tcp        0      0 athena.littleprojects.o:ssh 192.168.191.210:5014        TIME_WAIT
tcp        0      0 localhost:10024             localhost:58377             TIME_WAIT
tcp        0      0 athena.littleprojects.o:ssh 192.168.191.210:di-ase      TIME_WAIT
tcp        0      0 localhost:10025             localhost:53230             TIME_WAIT
tcp        0      0 localhost:10025             localhost:56526             TIME_WAIT
tcp        0      0 localhost:10024             localhost:58375             TIME_WAIT
#gvim chicken.txt

Can you quickly glance out it and tell me which commands have been executed? I need some separator on the screen to indicate the individual command executions so I can tell what happened. Without a separator, it looks like one big garbled mess, so I opted for a newline between the prompt and the command executions.

Try it now?

total 892
-r-sr-xr-x. 1 root bin 234404 Aug  3 18:35 cdcc
-r-xr-xr-x. 1 root bin  44568 Aug  3 18:35 dccif-test
-r-sr-xr-x. 1 root bin 627422 Aug  3 18:35 dccproc

#cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
#128.82.7.27 e-2104-13 e-2104-13.cs.odu.edu

#netstat --inet
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 athena.littleprojects.o:ssh 192.168.191.210:5011        TIME_WAIT
tcp        0    116 athena.littleprojects.o:ssh 192.168.191.210:5012        ESTABLISHED
tcp        0      0 athena.littleprojects.o:ssh 192.168.191.210:5013        TIME_WAIT
tcp        0      0 athena.littleprojects.o:ssh 192.168.191.210:5014        TIME_WAIT
tcp        0      0 localhost:10024             localhost:58377             TIME_WAIT
tcp        0      0 athena.littleprojects.o:ssh 192.168.191.210:di-ase      TIME_WAIT
tcp        0      0 localhost:10025             localhost:53230             TIME_WAIT
tcp        0      0 localhost:10025             localhost:56526             TIME_WAIT
tcp        0      0 localhost:10024             localhost:58375             TIME_WAIT

#gvim chicken.txt

Now I can clearly see that the top is the output of some command that has scrolled off the screen, but the cat, netstat, and gvim commands came next. It’s not that I can’t figure out what commands were executed (or even look at the history), but that when I’m comparing commands and output to each other, I need to be able to quickly see which sections of output belong to which commands. For me it’s a legibility and time-saving measure.

Time last command exited

At the beginning of the prompt is a timestamp.


18:30:33 smj@athena:/usr/local/bin
bash $ -->

This timestamp serves as a “poor man’s time command” letting me know (roughly) just how long the previous command took to run. It also serves as a way to keep track of times if I have a meeting or other engagement coming up. I put it in front, so when I see the prompts in sequence I can compare them to one another.

Username

Next is the username.


18:30:33 smj@athena:/usr/local/bin
bash $ -->

I don’t have the same username for each account. I also want to know if I’m running as root or a regular user. Sometimes that forces me to notice that I’m root before I do something dangerous. With one terminal up, this is not a problem. When I’m switching between five, it becomes increasingly important to keep each straight.

Server hostname

And equally useful to the username is the hostname of the server to which I’m connecting.


18:30:33 smj@athena:/usr/local/bin
bash $ -->

With the hostname I can tell different terminal sessions apart and ensure that I don’t make a mistake of typing the wrong command on the wrong server.

Full Path

As noted above, I like seeing the full path in my prompt. This way I can tell where I am on the server.


18:30:33 smj@athena:/usr/local/bin
bash $ -->

I also have a newline inserted after the path because a long path can scroll pretty far across the screen and some terminals have an issue including both the command and a long prompt on the same line.

The whole username@hostname:path exists so I can easily copy and past this string into an SCP command for moving files between servers. This is easier than typing scp myfile username@hostname:path by hand, especially considering hitting <tab> doesn’t work to expand the path for the server you are copying to.

Shell Name

This was one of the last things I added. I use a lot of bash; a LOT OF bash, but occasionally I have accounts (thank you ODU) that are tcsh, or I need to use an ancient server running csh or sh. I wanted to ensure that I could readily identify the shell as I switch between systems, so I have the prompt state which shell is running.


18:30:33 smj@athena:/usr/local/bin
bash $ -->

This means that I actually have login scripts for each shell that attempt to create as close as possible an approximation of the bash prompt. For example, if I’m suffering through an actual Bourne Shell session, I only get this:
sjone@E-2104-13.cs.odu.edu
sh $ -->

For tcsh, I get this:

18:40:01 sjone@procyon:/usr/local/bin
tcsh % -->

The point is that the shell is identified on the line on which I’m typing commands. This way I will know about the shell so I can change my syntax for items, such as redirecting stderr to stdout, when using a shell other than bash.

I do not control all of the servers I log into. Even though I may prefer bash, administrators on other systems have everyone default to tcsh or other shells. I try to ensure that my login prompt reflects this difference, especially when I’m working across several machines.

"The Arrow"

I added the arrow (–>) with an additional space afterwards so I can separate the prompt from the command that has been run. I find this to be useful, much like the newline between prompts, when looking at the output from a series of commands. It allows me to separate the commands I run from their output.

No color

Finally, I work across multiple systems with different terminal emulators, some of which I cannot choose for myself. At work I use PuTTY or Attachmate Reflections. At home I prefer the Mac OS X terminal program, or < a href="https://help.gnome.org/users/gnome-terminal/stable/">gnome-terminal, but I don’t always get to use my home computer for all of my projects. Sometimes, I don’t even get to configure the terminal how I would like!

Imagine that I had selected a color scheme using blue. Now imagine that same blue with a black background. Was that even legible? If cannot change the background to white or gray then I have to strain to read that text. Also, consider yellow on a white background. If I cannot reliably control my background colors, I really can’t select any meaningful foreground colors either.

Hence, I put not color into my prompt.

Setting up the prompt

To generate my prompt, I set the PS1 variable to the following value in my .bashrc file:

PS1='\n\t \u@\h:\w\nbash \$ --> '

The \n provides the newline, the \t provides the time, the \u provides the username, the \h the hostname, the \w the full path, and the rest is just text.

See the bash man page.

TCSH is not that much different:

set prompt = "\n%P %n@%m:%~\ntcsh \% --> "

Here, the %P provides the time, the %n provides the username, the %m the hostname, the %~ the full path (substituting ~ for my home directory), and the rest is just text.

Other shells do not have these fancy variables for telling time or providing other information, so for those shells I just set them with a text string providing as much meaningful information as I can get. I even have a custom Windows Command Prompt I use when I’m able to set it myself.

Summary

I hope you have found this article a useful resource. Though I realize not everyone is in the same situation I am, having to adapt to many differing environments, I hope that you can take away something useful from this discussion about the importance of a prompt on the command line.

For more information on how to set up your prompt effectively, Carla Schroder has a nice article discussing the use of colors and other features. For more in depth information on the bash prompt, check out the Giles Orr’s Bash Prompt HOWTO from the Linux documentation project. Understudy has a similar article to this which discusses more shells.

Whatever you do, take some pride in your prompt! It doesn’t just have to be that place where you give information, you can also get information.

]]>
/blog/2014/12/06/living-on-the-unix-command-line-the-importance-of-a-prompt/feed/ 0
Memento MediaWiki Extension /blog/2014/06/17/memento-mediawiki-extension/ /blog/2014/06/17/memento-mediawiki-extension/#comments Wed, 18 Jun 2014 04:11:58 +0000 /blog/?p=374

After more than a year of work, I’ve released the Memento MediaWiki Extension version 2.0.0 on MediaWiki’s extension site and on the project’s Github site.

It has been very fun.  Because this was a small academic project, I’ve had unprecedented freedom in my processes and technologies for getting the job done.  It has worked well for me, leading me to find the best solutions possible.

I have published the results of my further analysis as a Tech Report.  Publishing to arXiv is a process I will need to document at a future date, but it has been rewarding to see months of work documented for posterity.

In my excitement, I have tweeted the news to the masses.

As punctuation to this achievement, the source received its first pull request, meaning that version 2.0.1 will be coming soon.

]]>
/blog/2014/06/17/memento-mediawiki-extension/feed/ 0
Research, Research, Research /blog/2014/03/24/research-research-research/ /blog/2014/03/24/research-research-research/#comments Tue, 25 Mar 2014 02:09:18 +0000 /blog/?p=358

Lately, over the past few years, I’ve been pursuing my Master’s Degree in Computer Science from Old Dominion University. It’s been a crazy ride. Some of the courses have merely been a review of information I already knew. Others were some of the most difficult in my life.

Now, I face a new challenge: the thesis.

I’ve done some preliminary work with Memento, RFC 7089, as developed by my colleagues at Old Dominion University and Los Alamos National Laboratory. Memento is a way of browsing the web as if it were a date in the past. I’ve identified a new use case: avoiding spoilers in TV shows, movies, and books.

I’m working on bringing my work on the Memento MediaWiki Extension into my thesis, which I hope to publish by the end of the year.

Wish me luck!

]]>
/blog/2014/03/24/research-research-research/feed/ 0
Operation Not Permitted /blog/2012/06/02/operation-not-permitted/ /blog/2012/06/02/operation-not-permitted/#comments Sat, 02 Jun 2012 16:31:01 +0000 /blog/?p=305

I’m renting a new server from my dedicated server company, and got a really good deal.

I’ve wanted SELinux with my Red Hat/CentOS/Scientific Linux/Fedora servers since Red Hat ironed out the details around Fedora 6. The benefits are that someone breaking into one of the services is “sandboxed” and it limits the damage they can do to the system.

The drawbacks are that often items don’t function as one would expect because you have not found the correct set of draconian rules to enable the functionality you are looking for, but Red Hat has worked to iron out a lot of that to great success in the last few years.

I changed my SELinux setting in /etc/selinux/config from “disabled” to “permissive” so I can start up services and monitor /var/log/audit/audit.log to determine which SELinux rules should be altered.

After rebooting my server and analyzing the logs, I used the fixfiles command to change the SELinux contexts to get rid of some errors and saw the following message on several files:


failed to change context of `/etc/resolv.conf' to `system_u:object_r:net_conf_t:s0': Operation not permitted

I assumed (wrongly) that this must be some issue with SELinux. I tried the chcon command and got the same message. I could run chcon fine on other files, so what was the problem?

I decided maybe something was up with the file inode, so I tried moving the file aside with the intent of filling it in with the proper data/permissions/etc. after. The cp and mv commands also returned with Operation not permitted.

The permissions on the file showed that the files were owned by root and root had write permission to the file:

-rw-r--r--. 1 root root 97 May 31 17:39 resolv.conf

Now this was less an SELinux problem and more an issue specific to these files. Some more goggling led me to the obscure lsattr command, which showed:

----i---------- /etc/resolv.conf

The i is the “immutable bit”. It is the Linux equivalent to Microsoft Windows’s “Read Only” checkbox. I had known about it, but could not remember the command to check for it.

Removing the immutable bit was easy using chattr:

chattr -i /etc/resolv.conf

And then I was able to run fixfiles, chcon, mv, cp, and whatever else I wanted on the given files.

I’m guessing the admins at the server hosting company had set the bit inadvertently during installation of the system.

]]>
/blog/2012/06/02/operation-not-permitted/feed/ 1
Music Question: Apple or Amazon? /blog/2011/11/26/music-question-apple-or-amazon/ /blog/2011/11/26/music-question-apple-or-amazon/#comments Sat, 26 Nov 2011 17:58:44 +0000 /blog/?p=288

I’m in. By in, I mean I have the MacBook Pro (it’s got Unix!), the iPad, the iPod, the iPhone, and the MacMini Server. For documents I still use Microsoft Office like the majority of the rest of the world, but for personal documents increasingly I’m using iWork because of some of nifty features, like autosaving and iCloud.

So, now I want to buy P!nk’s Greatest Hits…So Far!!!. Usually, I purchase my music at Amazon’s MP3 store, or, if I’m really feeling nostalgic, Second Spin; but iCloud presents me with a new opportunity: the idea that if I just buy my music with iTunes I will have access to it wherever I am.

My first concern is space. You see, I’ve ripped about half of my CDs so far and I’m taking up 22GB of space on my iPod with music. As time goes on, I’ll probably reach 45GB in CD music alone. I’m in no danger of hitting my upper limit today, or next year even. My iOS devices (iPod, iPhone, iPad) all have 64 GB of space. I don’t put music on the iPad, preferring to use that device for movies and books, so the space taken up by the different forms of media shouldn’t interfere with one another.

I don’t have a lot of music with iTunes. I bought one album because it was only available there. If I continue to buy MP3s via Amazon, then I will continue to take up more and more space on my iOS devices.

I’m not sure where Moore’s Law will taper off in terms of more and more storage being available in these consumer devices. I doubt this trend will continue for consumer devices because more and more people are moving their storage to the cloud. My theory is that this will lead to fewer folks buying hard drives (whether they be magnetic or flash, it doesn’t matter), thus driving the demand down and the price back up again. With the price up, Apple (or Amazon, or Samsung, or whoever makes your portable music device) will not put as much storage into your portable device. This means that I will hit an upper limit on how many MP3s I can put onto my iOS device in the future. Apple wants me to use iCloud instead, because they see this future coming. More importantly, they are helping that future come.

So, the question is, do I continue to use Amazon’s MP3 store and manually move songs onto and off of my iOS device in the future, or do I just bite the bullet now and move to iTunes altogether? iTunes has the largest collection of music out there and I can always store a few MP3s for those artists and labels that I have to buy on Amazon.

Then there is an issue with preservation. The music on iTunes is (as most of you know) not stored in the MP3 format, but AAC (with various file extensions). As of 2009, it is supposedly DRM free. I opened one of my iTunes songs in VLC player, and it played fine, without asking me for a password like the DRM-full songs do. If this is the case, and AAC players are available in the future, then my concerns about preservation may be unfounded, as I will always be able to play the songs I’ve purchased.

iTunes is big, and with that many customers, I wouldn’t be surprised if AAC stayed around for a long time, so there should be no issue with finding an AAC player if iTunes goes away.

To recap:

Amazon MP3 Store Apple’s iTunes
storage space issues will require more and more storage on my iOS devices handled by iCloud
preservation capability MP3s are playable on many, many devices AACs are no longer encumbered by DRM and are playable by a lot of open source software, meaning conversions are possible

So, there really is no reason I can’t just jump on the iTunes bandwagon and enjoy the benefits of iCloud.

]]>
/blog/2011/11/26/music-question-apple-or-amazon/feed/ 0
Using launchd to run scheduled jobs /blog/2011/08/29/using-launchd-to-run-scheduled-jobs/ /blog/2011/08/29/using-launchd-to-run-scheduled-jobs/#comments Mon, 29 Aug 2011 19:25:22 +0000 /blog/?p=264

My new server’s predecessor ran Linux. I had a few scheduled jobs, like the ones that back up this blog, its database, and so on. On Linux the tool used for scheduling jobs is cron. Lo and behold, Apple has deprecated cron on their systems in lieu of an Apple-grown tool named launched. Launchd’s job is to replace cron, init, the rc scripts, the file alteration monitor, and a whole host of other normal Unix utilities in favor of one huge behemoth process that starts at boot. I’ve got mixed feelings about this concept, as it goes against the Unix philosophy of “doing one thing and doing it well”, but I chose OSX and have tried to learn their way of doing things.

I found several articles describing how one creates the plist files used by launchd. These XML files contain the information on the process you wish to run, including when to run it, how to run it, and who is allowed to run it. Here I will detail how I used it to merely run a scheduled job every night at midnight.

To start with, I have a simple script that backs up the database on the server:

#!/bin/sh
 
BACKUPDIR=$HOME/Backups/lawrence.littleprojects.org/db
REMHOST=lawrence.littleprojects.org
OUTPUTFILE=$REMHOST.sql
 
# if we don't have a backup directory, make it
if [ ! -e $BACKUPDIR ]; then
  mkdir -p $BACKUPDIR
fi
 
cd $BACKUPDIR
 
# run the remote database dump command
ssh $REMHOST "mysqldump --verbose --user=root --password='XXXXXXXXXXXX' --all-databases" &gt; $OUTPUTFILE
 
# if the zipped output file already exists, move it before zipping the new one
if [ -f $OUTPUTFILE.bz2 ]; then
  mv $OUTPUTFILE.bz2 old-$OUTPUTFILE.bz2
fi
bzip2 $OUTPUTFILE
 
chown smj:staff $OUTPUTFILE.bz2

This script is creatively entitled backup-database. I want it to run every night so I have an exact copy of this website’s database in case the web server goes down and I have to reinstall everything.

Under cron, I would run crontab -e and then put the following line into the editor that is brought up:

0 * * * *    $HOME/bin/backup-database

Apple made this simple step a lot more complicated than, in my opinion, it needed to be; but they gave me a tool that is a lot more powerful that mere cron.

To use launchd, I needed to make a file in the directory /Library/LaunchDaemons named org.littleprojects.backup.lawrence.db.plist that contains the following XML code:

<!--?xml version="1.0" encoding="UTF-8"?-->
 
 
 
    Label
    org.littleprojects.backup.lawrence.db
    ProgramArguments
 
        /Users/smj/bin/backup-database
 
    StartCalendarInterval
 
        Hour
        0
        Minute
        0

I’m a little annoyed at how Apple handled the whole key-value syntax, but I’ll let that be. The file reads as follows: create a job named org.littleprojects.backup.lawrence.db that will run the program /Users/smj/bin/backup-database at the 0th hour and 0th minute of ever day (midnight). I’m not sure if this is any less difficult to read than the cron syntax, but it is more difficult to write to be sure.

Once I created the file, I then needed to load it into launchd, which could be done by running the following commands:

sudo launchctl load org.littleprojects.backup.lawrence.db.plist

If you do this you, do not need to reboot as others claim. This is Unix and reboots should only be necessary for major operating system changes. Rebooting in order to create a scheduled job is not only ridiculous, but time-wasting and leads to error-prone behavior like making many untested scheduled jobs at once in order to save on reboots. I always try to find a way around reboots to avoid error-prone behaviors!

So, I did the same thing for other scripts I wanted to run at certain times. I understand why apple decided to use launchd, I just wish they would have made it easier to configure. Lingon exists in the app store for the express purpose of helping you create these plist XML files, but it will not load them for you and instead recommends you reboot after each edit, which I noted my distaste for above.

In the future I will be exploring how to best use launchd for other purposes, like restarting services, and scheduling scripts to run when other system events occur.

References:

]]>
/blog/2011/08/29/using-launchd-to-run-scheduled-jobs/feed/ 1
Randomly crashing Mac Mini Server running Lion [Solution] /blog/2011/08/18/randomly-crashing-mac-mini-server-running-lion-solution/ /blog/2011/08/18/randomly-crashing-mac-mini-server-running-lion-solution/#comments Fri, 19 Aug 2011 00:08:24 +0000 /blog/?p=253

I’d been looking for a home server solution that offered me more disk space, but that ran cool and quieter than my server-closet behemoth. I wanted the server to also be able to execute scripts and scheduled jobs. I researched several options, including the Dell Zino, but none seemed to capture my attention like the Mac Mini Server.

The day it arrived, I set it up and spent hours pouring over Apple’s documentation. I got file sharing, SSH, WebDAV, and other services set up easily, but realized that I had to download Server Admin Tools separately in order to get access to DHCP and DNS. Some admins speculate that this is a separate download to prevent would be admins from accidentally turning on DHCP in a network that already had it. Screen sharing worked flawlessly. I had it using my 46″ television as a monitor, so watching online video and iTunes was awesome!

The next day I went back to my new toy, and… it had locked up. I was not pleased. Murmuring curses and threats of sending the server back didn’t bring the server back from its limbo. This was UNIX! UNIX was not supposed to do this! I felt betrayed by a company I’ve been growing in support for. Why did they do this to me?

I think I’ve solved the problem. Nothing useful was in the logs, but I came across a forum post where someone had suggested that there were bugs [1][2] in Lion’s display drivers that caused some Macs to lock up when returning from sleep.

I went into System Preferences, then chose Energy Saver. I slid the slider next to Display Sleep all the way to the right, choosing Never. I have not had a lockup since.

I can’t recommend this for everyone, because they don’t have a display that is either off, or using another input, like my TV, but it might work in a pinch if you don’t mind manually turning your display off. Also, I’m a little surprised that it’s affecting my brand new Mac Mini Server, because the articles I’ve found refer to older Macs.

Update: This may have been fixed by the 10.7.1 patch. I haven’t tested it yet.

]]>
/blog/2011/08/18/randomly-crashing-mac-mini-server-running-lion-solution/feed/ 0
Review: Safari 2 Go (for iPad) /blog/2011/05/15/review-safari-2-go-for-ipad/ /blog/2011/05/15/review-safari-2-go-for-ipad/#comments Sun, 15 May 2011 12:24:06 +0000 /blog/?p=248

A friend excitedly told me about Safari 2 Go (S2G) for iPad. Having an interest in the technical books Safari offers, I chose to try and download a book right then and there, on 3G. S2G refuses to let you log in at all, unless you have wifi.

Later, on my wifi network, I started the download of a book. It took 10 minutes. I’ve noticed that books in the Amazon Kindle app and iBooks generally take about 5 minutes to download, over 3G. I was quite disappointed with the Safari download speed.

Also, the first attempt was unsuccessful, for the iPad’s desire to sleep during inactivity had forced me to “babysit” the iPad, occasionally touching it to ensure that S2G didn’t terminate the download. Other iPad apps are able to override this inactivity setting so they can finish their downloads without issue, even finishing the download while the user is running other apps (you know, that whole multitasking thing that’s sweeping the nation).

Once I did get the book to download, the resulting product wasn’t fully available.

Some of the pages in the resulting book vanish when you try to read them. They’re quite the tease. It might be related to a watermark that vanishes after a picture is loaded. If you do a quick print screen you might be able to capture the missing page. :)

All in all, it’s not a pleasant experience.

The Safari web site works fine, but I was looking forward to the offline storage for when I didn’t have or want to use an internet connection.

At the moment S2G sucks. What the hell were they thinking releasing it like this?

Update (2011/06/08): The updates haven’t helped, crashing often and appearing to fix none of these issues. In fact, the latest version doesn’t even load, presenting the user with a black screen and no functionality.

]]>
/blog/2011/05/15/review-safari-2-go-for-ipad/feed/ 0
Rebirth of a web site /blog/2011/02/21/rebirth-of-a-web-site/ /blog/2011/02/21/rebirth-of-a-web-site/#comments Tue, 22 Feb 2011 04:21:48 +0000 /blog/?p=233

I just spent time giving birth to an Old Dominion University Computer Science web site at http://www.cs.odu.edu/~sjone.  It’s just one page now, with some course information, and some links back to this site.  I know, not very interesting.  Under the covers, though, is a testbed for the Semantic Web.  So far, I’ve got Dublin Core and Friend of a Friend (FOAF) implemented for that one page.  In the future, I intend to bring the lessons learned there over to this site.  Eventually, the two will begin to look more alike in both style and function.

Perhaps Web Science and Digital Libraries is really my thing. I spend an awful lot of time blogging about my own web sites.

Validation of the Creative Commons Markup

I also discovered that the Creative Commons license markup wouldn’t validate with the W3C validator. This was because my page was initially specified as XHTML, but the Creative Commons license link contains additional RDF metadata used by search engines and other software. A blog post suggested just removing the metadata, but I didn’t want to do that because I knew that metadata had been placed there by Creative Commons for a reason. That metadata is part of the RDFa standard, which is a way of embedding metadata into normal HTML and XHMTL.

It turns out that once you put that Creative Commons markup into your XHTML, it becomes XHTML + RDFa, which is a completely different document type. I felt good that I’d figured this out, and changed the page to use this instead.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">

Now it validates fine as XHTML + RDFa.

Nifty floating image trick

You may wonder how I got the image to stay on the left and in the same spot, even though the visitor can scroll the page.  It is based on the following CSS, shamelessly stolen from the W3C themselves.

body {
    background-image: url(http://www.cs.odu.edu/~sjone/images/oducs-lpx.png);
    background-repeat: no-repeat;
    background-position: top left;
    background-attachment: fixed;
   /* more CSS here */
}

That’s it. It’s quite elegant, and I spent more time making the image with Inkscape than I did actually writing the CSS to tell it to stay put.

Useful Links

I discovered the following useful sources for bringing that site to life:

]]>
/blog/2011/02/21/rebirth-of-a-web-site/feed/ 0
Testing RAM on a Macbook Pro /blog/2011/02/03/testing-ram-on-a-macbook-pro/ /blog/2011/02/03/testing-ram-on-a-macbook-pro/#comments Fri, 04 Feb 2011 04:46:02 +0000 /blog/?p=217

My Macbook Pro came with 4GB of RAM in 2 2GB modules.  In December, I ordered 8 GB (2 4GB modules) of RAM from Crucial so I could max out the RAM in the machine, as I intend to keep it for a while.

Early in January I started to see applications crash.  VMWare Fusion became almost unusable.  I had never seen this behavior from my Mac before, so figured the new RAM had something to do with it, but wanted to verify my assumption before blindly blaming Crucial for bad RAM.  At that point I had to learn how to best test RAM on a Mac.

On a PC, I would have booted a CD running memtest86, but none of my Internet research indicated that was possible for the Mac.

Instead, I had to install memtest and boot the machine into single user mode in order to run memtest with the least amount of interference from running programs. I wanted to document what I had done in a blog post so I could remember next time.

Note: This article involves configuring your Mac in a way that could make it difficult for you to boot it normally if you don’t know what you’re doing. If you don’t feel comfortable following these instructions, take your Mac to a technician who not only feels comfortable fixing your computer, but is also competent to do so.

To tell the Mac to boot into verbose 64-bit single user mode, go to Applications/Utilities/Terminal, and type:

sudo nvram boot-args="-s arch=x86_64 -v"

You may be asked for the password you type to make changes to the system, type the password and hit enter.

Reboot your Mac.

Your Mac will boot to a prompt.  You may be surprised at all of the text that goes by.   These are kernel messages that are normally hidden by the nifty Apple logo.

At the prompt type:

memtest all

This will attempt to test as much RAM as it can.  Remember that some of your RAM is being taken up by minimal amount of software that booted your machine into single user mode (the kernel and bash), so you won’t be able to test everything, but if the flaw was in the RAM being used by the software running at this point, the machine would have failed to boot.

If your RAM is good, the test will take hours and you will see something like:

Memtest version 4.22 (64-bit)
Copyright (C) 2004 Charles Cazabon
Copyright (C) 2004-2008 Tony Scaminaci (Macintosh port)
Licensed under the GNU General Public License version 2 only
 
Mac OS X 10.6.6 (10J567) running in single user mode
Memory Page Size:  4096
System has 2 Intel core(s) with SSE
Requested memory: 7555MB (7922552832 bytes)
Available memory: 7555MB (7922552832 bytes)
NOTE:  Memory request is too large, reducing to acceptable value...
Allocated memory:  7343MB (7700721344 bytes) at local address 0x00000000101000000
Attempting memory lock... locked successfully
Partitioning memory into 2 comparison buffers...
Buffer A: 3671MB (3850360672 bytes) starts at local address 0x0000000101000000
Buffer B: 3671 MB (3850360672 bytes) starts at local address 0x00000001e67fd760
 
Running 1 test sequence... (CTRL-C to quit)
 
Test sequence 1 of 1:
 
Running tests on full 7343MB region...
  Stuck Address       : ok
  Linear PRN            : ok
Running comparison tests using 3671MB buffer...
  Random Value        : ok
  Compare XOR         : ok
  Compare SUB         : ok
  Compare MUL         : ok
  Compare DIV          : ok
  Compare OR           : ok
  Compare AND         : ok
  Sequential Increment:ok
  Solid Bits               :ok
  Block Sequential      :ok
  Checkerboard         :ok
  Bit Spread             :ok
  Bit Flip                  :ok
  Walking Ones         :ok
  Walking Zeroes       :ok
 
All tests passed!  Execution time:  7068 seconds.

If your RAM is bad, you will likely get a response really fast, and you will see something like:

*** Address Test Failed *** One or more DIMM address lines are non-functional.

or

FAILURE: possible bad address line at offset 0x06b3a4c8.

or

FAILURE: 0xbea1ce76 != 0xbea1ce7e at offset 0x06b3a4c8.

or

*** Memory Test Failed *** Please check transcript for details.

If you get a message like:

Attempting memory lock... ERROR: Memory lock failed - reason unknown.

WARNING: Testing with unlocked memory may be slower and less reliable

hit CTRL-C and make sure you booted into 64-bit mode by typing the following:

uname -m

If the command doesn’t return x86_64 then you are not running in 64-bit mode and your Mac can’t reach the RAM above 4GB. Please reference the above command for booting your Mac into single user mode, as it includes the flags to set it to 64-bit mode, then reboot.

If the command above does return x86_64, then you are running in 64-bit mode and this message is probably a preview of test failures to come.

If you have more than one module of RAM, then take all of them out, and place one in the machine, boot, and run the test. After that one finishes test, note the results, turn the Mac off, take the RAM module out, and put the next one in. This way you can figure out which module is bad.

When done, make sure you have good RAM in the machine, boot it again, and type:

sudo nvram boot-args=""

This will give you your “normal” Apple logo screen on boot.

I hope you will find this article as useful as I will the next time we need to test RAM on a Mac.

Today, Crucial was nice enough to send me some new RAM after I sent them the bad module.  So far, it appears to be passing memtest.  Cross your fingers for me!  :)

]]>
/blog/2011/02/03/testing-ram-on-a-macbook-pro/feed/ 35