December 24, 2008
Updating RubyGems broke the gem command
I ran:
gem update --system
The result was that the next time I tried to execute the gem command I got the following:
C:\>gem
The filename, directory name, or volume label syntax is incorrect.
I found that the gem.bat file had been changed and there was an extra double-quote on two lines.
@"ruby.exe"" "c:/Program Files/ruby/bin/gem" %1 %2 %3 %4 %5 %6 %7 %8 %9
And
@"ruby.exe"" "%~dpn0" %*
In both these cases, where there were two juxtaposed double-quotes (two double-quotes in a row), I had to remove one of the double quotes. Yielding:
@"ruby.exe" "c:/Program Files/ruby/bin/gem" %1 %2 %3 %4 %5 %6 %7 %8 %9
And
@"ruby.exe" "%~dpn0" %*
Problem was solved. I found a comment on the RubyGems forum that agreed with my fix.
December 09, 2008
Using patches to manage bug change-sets
In the Package Explorer, select Team | Create Patch...
Follow wizard to export the patch file to the clipboard, the filesystem or the workspace.You can then Override and Update to return the workspace to a state corresponding to the CVS repository.
Later, you can Apply Patch.. from the Team submenu, select the patch file you previously exported. Voila, your changes are back.
October 14, 2008
Identifying the source of a java Class
Class.forName("com.foo.MyClass")
.getProtectionDomain().getCodeSource()
October 13, 2008
Setting up Websphere for a remote debugger
Jacoozi: Remote Debugging with Eclipse
IBM Documentation -- another method, i have not tried.
Basically:
In the websphere administration console, go to a server's configuration and set it up.
October 07, 2008
Getting DB2 Error Code information
Start the DB2 Command Line Processor (CLP).
For SQLCODE -551 you type: "? sql551"
For SQLSTATE 56098: "? 56098"
May 27, 2008
Bugzilla Comments are mostly plain text, so don't use HTML
I wanted to do something like
<pre>
... some code ...
</pre>
for the sake of readability.
Well, I found out that doing so will just result in those tags showing up in the comment.
But bugzilla will try to create some hyperlinks for things in comments. See the Hints and Tips page of the bugzilla manual for more information.
March 19, 2008
ILog JRules BOM Update is trying to remove classes that I need!
Yesterday, when I did my normal procedure for this, the Update BOM option on a BOM Entry tried to remove a bunch of classes that I needed in the BOM.
I didn't know why. So I experimented. I created a brand new BOM Entry and tried to add the classes that JRules wanted to remove from the real BOM Entry. It threw an error. I tried to add some classes that were direct dependencies of the first, and they had the same problem.
I tried to think what had changed that these classes suddenly couldn't be in the BOM. Then I remembered that we had recently changed the base class to use Log4J. Log4J isn't part of the XOM. So maybe the BOM can't use a class if it doesn't have a access to to the classes dependencies. So, I tried adding a Log4J jar to the XOM project. After doing that, the classes from the XOM that had become dependent upon Log4J stayed in the BOM. The next time I tried to update the BOM, those classes remained in the BOM.
March 03, 2008
Deferred Constraints
In the Oracle DB, you can define a constraint as deferable. You can then make the constraint check fire at commit. It turns out, according to the DB people at my employer, that DB2 by IBM cannot. We have a table where rows can reference each other.
For example:
CREATE TABLE SELF_REFERENCE_EXAMPLE(
pk unsigned long;
...
another_row_pk;
CONSTRAINT FOREIGN KEY examplefk REFERENCES SELF_REFERENCE_EXAMPLE (pk);
);
And suppose we had a table like this.
pk |... |another_row_pk
=============================================
101 ... 208
208 101
Now, if we needed to move these rows to a history table, we can't move either because the other referenced row will not be in the history table.
In oracle we could make the history table fk constraint deferred and insert both rows. The fk constraint will be checked at commit, so there is not fk violation.
DB2 won't let us do the constraint deferral trick. So we have to do something like
insert 101 into the history table without its reference to 208.
insert 208 without its reference to 101.
update both rows with their respective references.
commit.
February 12, 2008
I really don't like ILog JRules
There is an eclipse-based IDE called ILog Rule Studio. It works somewhat, but builds are slow and you can't use the most recent jvm.
It is restricted to Java 1.4 and Java 5. If you use anything more current, some features of the ILog plug-ins won't work. Ruleset or RuleApp exports did not work until I installed the latest 1.5 JDK.
To use JRules you go through a process of "verbalization". You associate, hopefully, understandable English phases with java code. But doing a verbalization is painfully slow. When you verbalize, the save operation takes an amazing amount of time. I would say 10-30 seconds.
February 06, 2008
OpenLDAP wouldn't start. Here's how I fixed it.
Yesterday, a power outage brought my computer at work crashing down. When I tried to get my development environment going again, I couldn't interact with my local OpenLDAP server.
The slapd.exe process would essentially hang. I killed the process, and started it from the command line:
$ slapd -d -1
This showed that the process was hanging after loading a file in the data directory.
So I zipped up (zip file) the data directory. and then deleted the contents. Now, it would start up.
But there are no entries in the directory now. So I import an ldif file and, Voila!, I'm back in business.
December 12, 2007
Prototype extends arrays so they should not be used as hash sets
Turns out that Prototype adds some methods to Array. They are good, but one should be careful using Array objects as hash(key-value) sets.
Here is the blog entry we found that cleared everything up.
The skinny, Use Object as a hash, nothing else.
Thanks for the insight, Andrew Dupont.
July 10, 2007
Java reflection: primitive arguments in methods
In the Class.getDeclaredMethod(String, Class[]) method, you pass in a string representing the method name and an array of Class objects representing the types of any arguments.
For the following class :
public class Reflector {
public void intMethod(String aString, int anInt) { /* Some Code */}
public void integerMethod(String aString, Integer anInteger) { /* Some Code */}
}
You would get the methods reflectively like so:
. . .
Reflector r = new Reflector();
Method m = r.getClass().getDeclaredMethod("intMethod", Class[] {String.class, Integer.TYPE});
Method m2 = r.getClass().getDeclaredMethod("integerMethod", Class[] {String.class, Integer.class});
. . .
And invoke them thusly:
. . .
m.invoke(r, Object[] {"MyString", Integer.valueOf(100)});
m2.invoke(r, Object[]{"MyString", Integer.valueOf(100)});
. . .
For m.invoke, you wrap the int in the wrapper class since we're passing in an array of Object. Java automatically tries to unwrap it for you.
For an argument that is of primitive types use the following when defining the signature:
byte => Byte.TYPE
short => Short.TYPE
int => Integer.TYPE
long => Long.TYPE
float => Float.TYPE
double => Double.TYPE
boolean => Boolean.TYPE
June 27, 2007
Velocity
Velocity Template Language (VTL)
Statements begin with '#'ex. #set( $a = "Velocity" )
References (varables, properties, and methods) begin with '$'
Formal notation ${
Quiet notation $!
Literal string delimited by single-quote
ex. 'I know strings'
Interpolated string delimited by double-quote
ex. "I love $a" => I love Velocity
## This is a single line comment
#* This is
a
multiline
comment *#
#**
This is a documentation comment
@author Me
@version 5
*#
escaping characters
$$ => $
This snipet
#set($foo='dude')
Hi $foo
Hi \$foo
Hi \\$foo
Hi \\\$foo
produces
Hi dude
Hi $foo
Hi \dude
Hi \$foo
If a reference is undefined,
Hi $foo
would produce
Hi $foo
because $foo is undefined
while
Hi $!foo
produces
"Hi "
without the ".
June 19, 2007
Internet Explorer on Linux
This site offers an option for easily installing several versions of IE for LINUX.
April 16, 2007
Use Windows CE devices with Linux (Kubuntu)
The above is for setting up a syncing relationship. I'm just going to set it up to browse the file system.
- Install these packages:
- synce-kde
- synce-multisync-plugin
- synce-dccm
- synce-serial
- Setup synce
- Connect the Pocket PC via USB
- run: 'dmesg'
- Look for a line like 'usb 4-2: PocketPC PDA converter now attached to ttyUSB0' and remember the ttyUSB0 part. That's the device file for the PocketPC.
- Run: 'sudo synce-serial-config ttyUSB0', replacing ttyUSB0 with the appropriate device, if necessary.
- Run:'dccm' to start the daemon that will keep the connection alive.
- Run:'sudo synce-serial-start' to start the connection
- The above mentioned tutorial suggests running 'synce-pstatus' to get info on the device
- In konquerer, go to the address 'rapip:/'
- You're looking, hopefully, at your device's filesystem!
I haven't set up a partnership yet. That's next.
April 11, 2007
Using RSYNC (or any other system command) from RUBY
> system "rsync -<option(s)> <from> <to>"
You can invoke any system command in this way.
April 05, 2007
Followup: Linux CVS clients
April 02, 2007
CVS: find different or unmanaged files
- cd into the directory
- run "cvs diff -l --brief"
March 27, 2007
CVS update misses new directories
You run cvs update and you only get the directories that you checked out originally. So, instead, execute cvs update -d. This will include directories not in your working copy.
Linux CVS clients
March 24, 2007
Help! I can't update my linux install
The command is:
dpkg --configure -aYou might need to prepend sudo
March 23, 2007
linux environment variables
variable_name=value
For example
CVSROOT=:ext:boso@dumbcvs.dumbdomain.com:/cvsroot
or
JAVA_HOME=/usr/local/jdk6.0.0
ssh without a password
Thanks to mbonati at CalTech!
I quote the steps, just in case the page disappears:
What must be done, then , is to generate a public/private key pair, and copy the public part into the appropiate place on the server side.
For doing this, on the user's home directory, on the client machine, type
local> ssh-keygen -t dsa -f .ssh/id_dsa
-t tells the type of encription
-f tells where to store the public/private key pairs. In this case, the .ssh directory on home is being used
A password will be asked; leave this part blank, just pressing
Now, go the .ssh directory, and you will find two new files: id_dsa and id_dsa.pub. The last one is the public part. Now, copy the public key to the server machine
local> cd .ssh
local> scp id_dsa.pub user@remote:~/.ssh/id_dsa.pub
Of course, this time you will need to enter the password.
Now, login into the server machine and go to the .ssh directory on the server side
local> ssh user@remote
remote> cd .ssh
Now, add the client's public key to the know public keys on the server
remote> cat id_dsa.pub >> authorized_keys2
remote> chmod 640 authorized_keys2
remote> rm id_dsa.pub
remote> exit
and that's all.
Next time you log into the remote server, no password will be asked.
Note that this sytem will work while none of the machines change its IP address and for the specific user, so it is still safe.
March 15, 2007
Running Tomcat from Eclipse (using the server view from WST)
- right-click in the view and selecting new > server
- Select the server you will be using (it was tomcat 5.5 in my case). You will want to have the server installed already.
- Choose a host name
- Choose a runtime. If there isn't one available, create one (press the available button)
- Press next
- Select any web projects you want to run on the new server. If there aren't any, you'll be creating one soon, I wager.
- Press finish and you are done.
Don't let eclipse overwrite the tomcat config (unless you want to)
From inside the server's editor (right-click the server in the view and select open) select the option to "Run modules directly from the workspace". Now any configuration that you have in the server's conf/ directory is safe from changes you make to the config of the server defined in eclipse.
In the same editor you can set up ports, MIME mappings and other important stuff.
Note: If you're going to have the server listen on port 80 rather than 8080, linux' root user is the only one that can bind that port. So, in linux you'll need to run eclipse as root. Or maybe you can come up with a better solution. Let me know if you do. This article describes other ways of running tomcat on port 80 with a user other than root. I have not tried these solutions, let me know how the work for you.
Making the jump to linux
I downloaded the linux versions of Eclipse, Sun Java 6 SDK, and Oracle SQL Developer. I added the Web Tools Platform to eclipse for JSP, Tomcat, etc.
With those tools I was ready to go.
Here's where I had some problems. I tried to start sqldeveloper and it just threw exceptions. The problem? I had not set the JAVA_HOME environment. So I ran this command:
> export JAVA_HOME=/path/to/jdk
Now sqldeveloper starts just fine.
But I don't want to have to do that every time. So I put the command above in the /usr/environment file. Now every time I start a session, the environment variable is set.
