Archive for the ‘Programming’ Category

Installing LaTeX on GNU/Linux

Saturday, February 20th, 2010

Ok, I’m going to rewrite this page a little bit so that I can remember all the junk I install to get my LaTeX setup correctly on Ubuntu.

Getting Started

I usually start off by installing the plugin for gedit. That installs 95% of the stuff you would need to use LaTeX. In fact, it may be all you need.

Extra Stuff

To get the fullpage package, you need to install texlive-latex-extra. This package contains hundreds of styles, etc. It includes the exam package, but not the up to date version.

If you need to use the LaTeX exam class on Ubuntu, you will need to manually grab the latest version of exam.cls from  Phil Hirschhorn’s website. It goes into the /usr/share/texmf-texlive/tex/latex/exam/ directory on Ubuntu. If you don’t have this, you can’t use some of the new features like \ifprintanswers, for example. I guess someone needs to update the package on Ubuntu.

Ways to give this holiday season

Friday, December 19th, 2008

Today I sat down and pondered what gifts to get my wife. I realize that one of two things is going on.

  1. We already have plenty of stuff, and I shouldn’t give her anything.
  2. I’m lazy, and a bad husband for not being creative enough to give her something she will truly enjoy.

It’s probably a combination of both. I look around at the way we live, and I see no reason to panic over the recession we’re in. We’ve got it so good, and by most people’s standards we are struggling to get by!

So, one of the things I plan to do this season is just give to a couple of organizations I’ve been meaning to support, but haven’t yet supported. Here are a few that could use some help if you’ve got a few extra dollars. I may add more as I think of them.


Wikipedia Affiliate Button


Coding is not a crime



LaTeX in Gnome

Tuesday, June 10th, 2008

If you use LaTeX to create professional documents, and if you use GNU/Linux with Gnome, you are in the minority. I can’t possibly overrate this setup, and I encourage you to invest some time in it – it will be worth the gains to you, especially if you are a researcher and write papers a lot. I used LaTeX for my English papers in my college composition class. LaTeX is useful for writing books as well, in fact it is the de facto standard for publishing anything you want to look really awesome, especially math books and papers.

So, how do you set it up and begin using LaTeX? First things first. You have to learn about LaTeX. There are a bunch of tutorials, but a very nice one is by Andy Roberts -  Getting to Grips with LaTeX.

Next, you’ll want to get some sort of editor for LaTeX. For KDE (which is not Gnome, obviously) you would simply use Texmaker. The problem with installing this on Gnome is that you get a ton of new libraries for QT and it’s a lot of stuff to install for one program. There is an easier way – use Vim. Well, most people aren’t going to do that! How about using Gedit? It’s got a nice extension for LaTeX (and a lot of other nice extensions too). There is a nice website set up for this plugin to Gedit, and installing is a breeze. You’ll also need the rubber package which includes the TeX libraries and all.

The Gedit plugin is in beta, so not everything works just perfectly. Hey, if you like it, donate to the people who are writing it – Free Software doesn’t have to be gratis. You might encourage them to finish your favorite missing feature sooner.

Using Headings Effectively

Monday, May 12th, 2008

What are headings?

Headings are important elements of documents, emails, books, websites and a plethora of other types of written work. Why are they so important? When people read, they tend to search for the important words, or the things that jump out at them first. It is a matter of efficiency; you want to read the important stuff first and skip the unimportant things. With resumes and websites, for example, you want to make sure you help your audience focus on the important stuff quickly. If you don’t make a conscious effort to make your work easy to navigate, people will get frustrated and move on.

Headings are semantic separators; they separate sections of documents into visually distinct regions of text and they give meaning to the text they contain by the descriptive text in the heading. There is a lot more to this than meets they eye. Your brain makes distinctions that you might not be conscious of at first glance. For instance, you might not notice the logical order of headings, but you will notice if something doesn’t make sense the way it is ordered. For instance, consider the following example.

A paragraph about dogs

Here is a description of some dogs that are awesome for pets. You should pick a dog for a pet since they are great for pets! You can pick one from the following list:

Great Dogs For Pets

  • Doberman
  • Dalmatian
  • Mutt

Now, you probably notice the line “Great Dogs For Pets” first, but logically, you should first notice the heading that says “A paragraph about dogs” since this conveys more meaning about the content below it. We instinctively look at the boldest, biggest things first, and you should certainly cater to that instinct. We also generally scan from left to right and top to bottom, so that whole example just screams “contradiction”!

Using Headings in Documents

I’m going to assume you have a word processor of some sort. Hopefully it’s one that is Free Software such as Open Office. You should notice a menu of styles in your word processor. Open Office Writer has a drop down menu in the top left of the screen that usually says “default”. If you click on it, you will see all kinds of options for styling the the document.

By default, the default headings are styled so that they either decrease in size or stay the same as the order gets larger, and they sometimes alternate between italic and non-italic font style. That variety helps you pick out where you are in the document.

Of course, if you want to make it absolutely impossible to get confused, you can number your headings. For example, “1.0 Dogs, 1.1 What dogs are good pets?, 2.0 Cats, …” You get the point I hope.

Accessibility

From the point of view of meeting the accessibility needs of visually impaired people, headings are more important. People who use screen readers need to have headings to convey the meaning and structure of the website. You might want to check out this page at WebAIM which talks about the accessibility implications of misusing headings.

Conclusion

  • Do use and nest headings in a logical order to convey the structure of your document.
  • Don’t use markup with regular text to ‘visually’ create headings.

Richard Stallman to speak at VCU

Monday, January 28th, 2008

Richard Stallman, (founder of the GNU project, the Free Software Foundation) will be speaking at VCU on March 27th of this year.

Mr. Stallman will speak on the topic of “Free Software in Ethics and in Practice”, and about the goals and philosophy of the Free Software Movement, and the status and history of the GNU operating system, which in combination with the kernel Linux is now used by tens of millions of users world-wide.

This seminar will is the result of many hours of work on my part, and the donations and help of the VCU community, faculty, students and staff. It is primarily sponsored by the VCU School of Engineering’s Computer Science Department, the VCU Honors College, the Student Advisory Board to the Computer Science Department, as well as the ACM chapter at VCU. Additionally there is a private company who has offered a significant donation, but I am not sure if I should post their name here.

Event Details

When: March 27th, 2008 at 7:00 PM
Where: Room 1164, Temple Building, VCU Monroe Park Campus
Directions: Please follow the VCU directions to the Main Street Parking Deck.

Installing Java OpenGL on GNU/Linux

Sunday, September 9th, 2007

The jogl tutorial and installation instructions found on the Sun Java website are correct, but somewhat unhelpful for beginners. In particular, you need to set the CLASSPATH and LD_LIBRARY_PATH in order for the program to work correctly. Here is how I did it.

  1. Make sure you have already installed the Sun version of Java.
  2. Download the latest jogl files from Sun.
  3. Save the file in a convenient place – I’ll assume your home directory.
  4. Become superuser or root:
    $su OR $sudo su
  5. Now, you need to create the directory to install it. I put it in
    /usr/lib/jogl/
  6. To do that, type:
    #mkdir /usr/lib/jogl/
  7. Move the zip file to that directory:
    #mv ~/jogl-<your version>.zip /usr/lib/jogl/
  8. Unzip the file:
    #cd /usr/lib/jogl/jogl-<your version>/
    #unzip jogl-<your version>
  9. You probably will want to change the name of the jogl directory to something like jogl-1.1.1-rc3 instead of having the architecture type on the end. (remove the -linux-i586 or whatever from the end of the name). Renaming a file is as simple as moving it from one name to the other as in “mv filename_old filename_new”.

Now you can configure the system to look there for the files when you call javac. To do this, I added the following lines to my .bashrc file:

#Add some JOGL paths - added by gnat79 on 9/9/2007
export CLASSPATH=${CLASSPATH}:/usr/lib/jogl/jogl-1.1.1-rc6/lib/jogl.jar
export CLASSPATH=${CLASSPATH}:/usr/lib/jogl/jogl-1.1.1-rc6/lib/gluegen-rt.jar
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/jogl/jogl-1.1.1-rc6/lib

The best way to do this is to use a text editor such as gedit to copy and paste it in. You may have trouble opening the file since it is hidden by default in many systems. (All files that start with a ‘.’ are hidden). You can open it with a command like this: $gedit .bashrc (from your home directory). Alternatively you can use vim to edit it. Make sure you change the version of jogl from what I have in the example.

Now you’re done!

If you see any problems with this article, please comment on it. I’m no expert! You should also read the directions that Sun has provided.

Two reasons not to scale images in HTML

Wednesday, August 1st, 2007

There are probably more than two reasons, but here are a couple problems that you might want to avoid.

Many people are too lazy to change the size of an image in an HTML document, which is totally understandable. What if you have to use it two or more times, and you need different sizes for each image (thumbnails, for example)? Unfortunately, this causes problems for other people, due to your lack of non-laziness.

First, the original image could be really large, which is common now that digital cameras take 7 mega-pixel pictures. If you just plop the image on your website, you’re using up valuble space on your server, and you’re causing everyone else to download that whole image everytime they visit a page. This is a real problem for dialup users, and dialup users make up a considerable percentage of Internet users.

Second, many browsers can’t scale images well. If you try to scale an image, it may look pixelated, stretched or fuzzy, depending on which way you change the size. Even going from a large image to a smaller image causes noticable problems in quality.

So, before you drag and drop that next image into a WYSIWYG editor, scale it down or make a thumbnail that links to it.

Java newline characters

Monday, March 26th, 2007

Java doesn’t work the same way on all platforms (GNU/Linux, Windows, Mac), even though the Java Virtual Machine was designed for that purpose. In fact, there are some system inconsistencies that apparently can’t be avoided. For example, each operating system uses different end-of-line characters in text files.

  • Windows: [ \r\n ]
  • GNU/Linux or Unix: [ \n ]
  • Macintosh: [ \r ]
  • and sometimes [ \f ]

If you want to read information from a string, input stream or a file, you can use the Scanner class to accomplish this task. If the file is delimited with a comma and then a space “, ” you must set the delimiter by object.useDelimiter(", ");. You can also put a regular expression in the parentheses like this: object.useDelimiter(", |\n"); and then the Scanner will look for a comma-space or an end of the line.

Suppose you want to scan a line that contains several types of data (String, int, etc) that looks like this: George Jones, 44, 88, 99, 22, 90 and suppose you set up to scan it using this method: object.next();. You must first set the delimiter, of course. Then you will have no trouble scanning the name George Jones. But, then let’s suppose you want to scan the numbers as integers. You can use object.nextInt(); which works fine until the last number 90. At that point there is no next comma-space delimiter to find, so you get an exception.

The solution to this problem is to use the proper delimiters: object.useDelimiter(", |\n");. In the case that you created the file on Windows, that will NOT work. You must use \r\n in that case. Once you know the correct characters for the file, you can use the expression "\n|\r\n|\r" and it will work on files created on all major operating systems.

Another complication to using Java is if you compile a program on Linux it will set the default end-of-line characters to the GNU/Linux (\n); however if you compile it on Windows it will use (\r\n).

Somtimes it may be necessary to use the [ \f ] delimiter, though I am not sure at which times. This delimiter is called the “form feed” character. If you have problems with end of lines, just try it.

Also, be aware that GNU/Linux text documents usually have a trailing empty line at the end of the file.