Computer Scientist, Graduate Student, and Geek
Diagram in Powerpoint (PPTX) to Postscript (PS)

May 06, 2013

Converting a diagram made in PowerPoint to a postscript file (so it can be included in a LaTeX document) is a complex multistep process. Below are the steps I follow:

  • Print the slide with the diagram to a PDF using CutePDF (using PowerPoint's Save As PDF option will result in a huge postscript file in the end)
  • Run the following sequence of commands, setting the NAME variable to the name of the PDF file, sans extension:
    NAME=mydiagram; pdfcrop $NAME.pdf; pdf2ps -r300 $NAME-crop.pdf; \
    mv $NAME-crop.ps $NAME.ps; rm $NAME-crop.pdf

Categories: Linux

Tags: latex, pdf, postscript, powerpoint


Replacing Values in a Vector with NA in R

October 01, 2012

# Load data files
dataA <- read.table("dataA.csv", header=TRUE, sep=",")

# Replace zeros in column ColA with NA
dataA$ColA <- replace(dataA$ColA, data$ColA == 0, NA)

Categories: Uncategorized

Tags: R


Interstate 80 (Part 2)

September 28, 2012

I have continued to create Interstate 80 on my N-scale model railroad of Grinnell, IA. (Read the original post)

To finish the hill I created from foam on one side of the tracks, I covered the foam with two thin layers of spackling paste. To start the hill on the other side of the tracks, I glued together two layers of foam roughly cut to the shape of the hill. I verified the height of the bridge by placing a partially assembled piece between the two sides.

I shaped the hill on the inside of the track the same as I did with the first hill. However, I included space for an off-ramp going down the side of the hill.

To finish the new hill, I covered it with a thin layer of spackling paste and glued on both a main roadway and an off-ramp cut from thick styrene sheet. Since the off-ramp didn't have the right slope initially, I added some foam shims underneath.

The next step is to add some scenery and put the bridge in place.

Categories: Model-Railroad

Tags: scenery, structures


Merging PDFs

August 22, 2012

pdftk - The PDF Toolkit is a handy tool for merging PDFs (and many other manipulations, e.g., removing pages from a PDF). On major Linux distributions, it can be installed with yum or apt. To merge multiple PDFs into a single PDF, execute a command similar to:

pdftk inputA.pdf inputB.pdf inputC.pdf cat output output.pdf

The above command creates a new PDF called output.pdf which includes all pages from the PDFs inputA.pdf, inputB.pdf, and inputC.pdf.

Categories: Linux

Tags: pdf


Reading Arguments from the Command Line with Perl

August 21, 2012

The variable $#ARGV contains a count of the number of command line arguments. The count is zero-based (i.e., -1 means no arguments, 0 means one argument, 1 means two arguments, etc.), and it does not include the script name.

The actual argument values are stored in the array $ARGV, e.g., the first argument can be accessed using $ARGV[0].

Categories: Development

Tags: perl


Simple CDF Graph in R

August 10, 2012

Below is a sample script for R for creating a cumulative distribution frequency (CDF) graph with one or more curves.

# Load data files
dataA <- read.table("dataA.csv", header=TRUE, sep=",")

# Create CDF points
count <- length(dataA$ColA)-1
cdf.dataA <- data.frame(x=sort(dataA$ColA), y=c(0:count)/count)

# Setup graph parameters
xrange <- c(0, 10)
yrange <- c(0,1)
colors <- c('black') # 'gray39', 'gray69'
linelabels <- c('DataA')
linetype <-c (1)

# Setup output
postscript("cdf.ps", width=5, height=4)
#png("cdf.png", width=400, height=300)

# Setup basic plot
plot(xrange, yrange, type='n', main='', xlab='ColA', ylab='CDF')

# Add lines to plot
lines(cdf.dataA$x, cdf.dataA$y, type='l', col=colors[1], lwd=2,
    lty=linetype[1])

# Add legend
legend(xrange[1], yrange[2], col=colors, lwd=2, lty=linetype,
    legend=linelabels)

# End output
dev.off()

Categories: Uncategorized

Tags: R


Perl Code for Processing CSV Files

July 30, 2012

Below is a sample Perl script containing many constructs that I commonly use to process output in the form of a comma-separated value (CSV) file.

use strict;

# Read from standard in, one line at a time
while (my $line=<STDIN>)
{
    # Trim trailing newline
    chomp $line; 

    # Create an array from a line of comma-separated values
    my @cols = split(/,/,$line);
}

Categories: Development

Tags: perl


Installing Packages in R

March 07, 2012

You can install packages in R by running the following command within R:

install.packages(c("pkg1", "pkg2"))

(See http://cran.r-project.org/doc/manuals/R-admin.html#Installing-packages for more information.)

Categories: Uncategorized

Tags: R


Old Versions of Firefox

February 16, 2012

Fedora 13 does not have all the necessary dependencies for Firefox 10, so I needed to downgrade to Firefox 9. I finally managed to find the installers at: https://ftp.mozilla.org/pub/mozilla.org/firefox/releases

Categories: Linux

Tags: fedora, firefox


Interstate 80

January 08, 2012

My N-scale model railroad of Grinnell, IA now features the beginnings of Interstate 80. Adding Interstate 80 to the layout provides a way to hide part of the track so viewers cannot see the entire loop. Shortly after I decided to include Interstate 80, I read the Step By Step article "How to build a highway overpass" in the December 2011 issue of Model Railroader. I am basing my design off of the article.

I began in the front-left corner of the layout by adding a hill. Below is a picture of the foam that forms the base of the hill with some cardboard standing in for the road. You can also see two of the new vehicles I got for Christmas (thanks Llewellyn).

After I had roughly shaped the hill, I built two abutments out of some styrene sheet. You can see one of them, unpainted, in the photo below. I also cut the road surface from styrene and glued it to the hill, weighing it down with soup cans while the glue dried.

The hill, road, and one of the abutments are now complete.

Next, I need to build the hill for the other side of the tracks.

Categories: Model-Railroad

Tags: scenery, structures


Older Entries >>