February 2nd, 2007
Today I wanted to get rid of all directories named “.svn” in one of my projects. These directories store Subversion information and I wanted to get rid of it.
The best method to delete a bunch of files by name is to use the find command and pipe its output to xargs. xargs in this case runs rm on each file name that find lists.
First, use find by itself to double-check the files that you will be deleting. In this case, I’m telling find to list the directories it recursively finds named “.svn” in the current directory:
find . -name .svn -type d
Double-check that you actually want to delete the files you listed.
From that point, I sent those directories to the guillotine with:
find . -name .svn -type d -print0 | xargs -0 rm -rf
The -print0 option separates the file names with the null character and the -0 option tells xargs to delimit the file names by the null character. These options eliminate problems with file names with spaces and/or newlines in them (xargs delimits by spaces and newlines by default).
Posted in Uncategorized, Tech | No Comments »
November 14th, 2006
I recently discovered that this sequence of commands is a nice, clean way to kill a postmaster process:
sudo su postgres
pg_ctl kill QUIT 7741
You would have to change the 7741 to the pid of the postmaster process that you need to kill. This also assumes that the user ‘postgres’ initiates postmasters, which I believe is the default.
And, as the Postgres people are fond of saying, DON’T kill -9 the postmaster!
On a side note, never kill a real postmaster.
Posted in Postgres | No Comments »
September 23rd, 2006
The “New Folder” button is disabled for most Windows XP users when using Java’s JFileChooser and the current directory is “My Documents”. This problem is reported in detail on Sun’s bug tracking site. I posted a workaround, which I will also post here:
public static void main(String args[]) {
...
// A litte fix for WinXP
if (System.getProperty("os.name").equals("Windows XP"))
fixMyDocumentsRights();
...
}
/**
* Fixes the fact that you can't create a folder in
* My Documents with JFileChooser unless a bit has been
* unset. This bit doesn't seem to affect
* Windows applications.
*/
public static void fixMyDocumentsRights() {
try {
Runtime.getRuntime().exec(
"cmd /c attrib -r \"%USERPROFILE%/My Documents\"");
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
Posted in Tech, Java | 4 Comments »
September 21st, 2006
I created a special blog for those who are not interested in hearing what I have to say about geek technology X and Y. And by special, I don’t mean dumbed down; I mean less geeked up.
From now on this blog will be a journal of problems I run into while developing software and the solutions that I find. Believe it or not, I do a lot of software development since I study it full-time and work at it with my two part-time jobs!
If you do not know a lot about development, you still might want to tune in once in a while to see what I’m working on.
Posted in Uncategorized | No Comments »
August 30th, 2006
Despite my appreciation for log4j, Apache’s premier open-source logging system for Java, I wish that it had better online documentation. Sure, they include a “manual”, but it is only an introduction. The full manual, it appears, is only sold commercially.
That being said, it was with a lot of Googling and some fancy guess work that I figured out how to change the encoding of appenders from a log4j properties file. It’s easy enough to do in the code, you just have to read the javadoc. It would look something like:
myUnicodeAppender.setEncoding("UTF-16");
This will work for any subclass of WriterAppender (ConsoleAppender and FileAppender for instance).
Apache recommends in the log4j manual that you do most of your configuration in a separate properties file. To set the encoding try this:
log4j.appender.myUnicodeAppender.Encoding=UTF-16
If you use the default appender named “R” (from the manual), you can add this to your properties file:
log4j.appender.R.Encoding=UTF-16
Posted in Tech, Java | 7 Comments »
July 11th, 2006
In my Software Engineering class our TA showed us this example of a “pattern” (as in “design patterns”). If you are in an aspiring boy band, this pattern should be helpful.
Here is the chorus as an example:
Title of the song
Naïve expression of love
Reluctance to accept that you are gone
Request to turn back time
And rectify my wrongs
Repetition of the title of the song
Credit for the song goes to Da Vinci’s Notebook, whoever that is.
Posted in Tech, Humor | 3 Comments »
June 1st, 2006
My approval of San Francisco’s Deerhoof just went up a notch. The avante-garde rock group now allows any fan to remix Rrrrrrright (from Runners Four) and submit it. All submissions are posted.
Posted in Art | 1 Comment »
April 16th, 2006
I think it was about 1996 when I made my first web page. It was hard to believe that some punk kid could publish something so easily accessible by anyone who cared to read it. I posted some short stories, HyperCard stacks, and MIDI tunes. I sprinkled it some Photoshop-made images and, *ta-da*, I was online.
Now, ten years later, almost every one I know has a blog or myspace.com account. It’s amazing.
Posted in Life, Tech | 3 Comments »