Java kills people
July 8, 2010
Batch printing
February 1, 2010
I often upload some pdf files on a server to print them at my faculty. On the server I follow these steps:
1. Convert the uploaded pdf files to postscript
for file in `ls -1`; do pdftops $file; done
ls -11 lists all the files of the current directory, one file per line. pdftops actually converts the pdf files to postscript.
2. Delete the pdf files
rm *.pdf
We need to delete the pdf files to only list postscript files in the next command.
3. Put two pages on one page and print them
for file in `ls -1`; do psnup -2 -d0 $file | lpr -Pscit32411d; done
Again we walk through the file list but this time psnup prints two pages on one page and we pipe its result to the print command lpr. The argument P is the printer name of our destination.
I’m sure this can be done in only one line but I’m not a big shell scripter so I make the batch printing in three lines.
- The parameter is a one and not a l ↩
source url not under source root
January 26, 2010
I’ve tried to mirror a svn repository and svk (yes svk and not svn!) told me that the source url is not under source root whatever this means.
An escaped space character caused svk fail the check:
if substr( $source_path, 0, length( $source_root ), '') ne $source_root;
in line 162 in SVNRa.pm.
I fixed this problem while adding a line which replaces %20 by a space character because an URL with the file protocol must not be escaped. These resources are accessed directly from the disk and not from a webserver.
$source_path =~ s/ /%20/g if $source_path =~ m,^file://,;
# XXX: this shouldn't happen. kill this substr
die "source url not under source root"
if substr( $source_path, 0, length( $source_root ), '') ne $source_root;
Let SVN accept revision propchanges
January 20, 2010
The following message appears if you try to modify properties (e.g. the log message) while the propchanges hook is not enabled.
Repository has not been enabled to accept revision propchanges;
ask the administrator to create a pre-revprop-change hook
This hook is nothing else than an executable script located in repos/hooks/ that exits with 0 or 1 if defined conditions are not fulfilled. You can remove the file suffix tmpl from pre-revprop-change.tmpl1 if the template already exists or you create it from the scratch.
For Unix systems the script looks like
#!/bin/sh
exit 0;
and for Windows it’s
@echo off
exit /B 0
- On Windows the suffix shouldn’t be removed but changed from tmpl to bat instead. ↩
Removing line numbers from a source code
July 24, 2009
At the moment I’m learning developping eclipse plugins for my work. Therefore I had to copy some code 1 from this tutorial. Unfortunately I had to remove the stupid line numbers. It’s best to let remove them by a script. Because I spent a lot of time in WordPress plugin development few weeks ago I chose PHP to do the work.
<?php
$code = '
1. package com.myplugin.rmp.views;
2. import java.util.ArrayList;
3. import org.eclipse.core.resources.IFile;
4. import org.eclipse.core.resources.IFolder;
5. import org.eclipse.core.resources.IProject;
6. import org.eclipse.core.resources.IResource;
7. import org.eclipse.core.resources.IWorkspace;
8. import org.eclipse.core.resources.ResourcesPlugin;
9. import org.eclipse.core.runtime.IAdaptable;
10. import org.eclipse.jface.action.Action;
11. import org.eclipse.jface.action.MenuManager;
12. import org.eclipse.jface.dialogs.MessageDialog;
...
199. public void setFocus() {
200. viewer.getControl().setFocus();
201. }
202. }
';
echo "<pre>". preg_replace("/\d+\./", "", $code) ."</pre>";
?>
The script is self descriptive but be sure that you adopt the regular expression to your needs. The regex I used destroys code containing constructs like anyObject12.doAnything();
- Copy & paste is bad but 200 lines are too many to rewrite
↩