Packaging and distributing taglibs in a JAR
This is more of a “note to self” than a “how to”.
If you’re trying to distribute tag files in a JAR, you need to put them under /META-INF/tags. You then need to create a TLD file that you also put under /META-INF/tags. If you have tags or functions that you created in Java, and want to distribute them alongside the tag files, you need to reference them in the TLD and package them in the same JAR (goes without saying).
If you want to do the same thing in maven, the location for the tag files and the tld file is different; you need to put them in src/main/resources/META-INF/tags. Then you can run mvn package and maven will create a JAR with your tags.
Read more »
Popularity: 5% [?]
Mono on Ubuntu: Package dotnet35 was not found in the pkg-config search path
I’m taking a C# and .NET class at ASU East. Our professor has example code that runs on Windows and the Mac (using Mono). I installed mono 2.8 from this link and I was able to get C# code to compile. However, when I tried to run my professor’s build script (he uses ant with some .NET extensions), I got the following error:
[dn:csc] Package dotnet35 was not found in the pkg-config search path.
[dn:csc] Perhaps you should add the directory containing `dotnet35.pc’
[dn:csc] to the PKG_CONFIG_PATH environment variable
[dn:csc] No package ‘dotnet35′ found
[dn:csc] error CS8027: Error running pkg-config. Check the above output.
To fix this, I set the value of PKG_CONFIG_PATH to /usr/local/mono/2.8/lib/pkgconfig (you’ll need to add this to your .bashrc). If you used the mono install-script without modification, then the value of PKG_CONFIG_PATH should be /opt/mono-2.8/lib.
Popularity: 3% [?]
Bytecode optimization in Java
I learnt something new about bytecode optimization today. In languages like C and C++, if you’re really concerned about efficiency, you can drop into assembly mode and write specific assembly code instead of relying on the compiler to convert your C/C++ code into assembly (compilers can optimize, but not as well as humans in all cases).
I saw a question on Stackoverflow today that talked about the getfield opcode in the context of the trim() method in the String class. In the trim() method, you have the following comments:
int off = offset; /* avoid getfield opcode */ char[] val = value; /* avoid getfield opcode */
The author of the question wanted to know what these comments mean. This question seemed pretty interesting to me and so I went and did some research. I found out that getfield is an operation that lets you get access to the member variable/field of a class. This operation is fairly expensive as it involves indexing into the runtime constant pool. Performing this operation a few times does not really incur a performance hit. It is when you perform the operation multiple times, that performance becomes an issue. You can see this from the next few lines of code:
while ((st < len) && (val[off + st] <= ' ')) {
st++;
}
while ((st < len) && (val[off + len - 1] <= ' ')) {
len--;
}
Now if the author of the trim() method hadn’t assigned offset and value to local variables, a getfield operation would be performed every time the loop-condition is tested. This is obviously inefficient. Therefore, the author assigned the the values of offset and val into the local variables off and val. So now, instead of getfield you have iload (for off anyway), which performs much faster.
Popularity: 4% [?]
A Minecraft Stargate
I’ve been playing Minecraft for a while now. It doesn’t look like much at all, but it’s a really fun game. I love the fact that you can build whatever you want. It’s like legos, really. Anyway, I built a Stargate in Minecraft. I originally wanted to use the portal blocks, but if you stack two or more together, they just vanish. So I decided to make inner part of the Stargate out of glass and water. This means that you can’t walk through it, but it still looks kinda neat. I figure that I could make a wall of water if I had a trough that ran through the middle. But this would mean that you would fall into the trough every time you stepped through the Stargate. There might be other ways… I’ll see if I can figure it out. I used lightstone for the chevrons. The gate is bigger than it would be normally, but that was the only way I could make a circle that looked decent.
This is with the default texture-pack in Minecraft. It would probably look better with a better texture-pack.
I’ll try to build a DHD next. Probably won’t be able to make it look as nice as the original, though.
UPDATE
Here are some better pictures. I’m using the Minecraft Enhanced Texture Pack 256×256. I also noticed that I had placed one of the lightstones in the wrong place. I fixed that.
Here is the world file (it’s a zip) if you want to check it out. It’s from my multiplayer server and so there are a bunch of other creations on there, that my friends made.
Popularity: 22% [?]
Broadband speed-test results for T-Mobile’s HSPA+ network
I’m at Phoenix Sky Harbor airport waiting for my (delayed) file to Orange County. I was having trouble connecting to Sky Harbor’s free Wi-Fi and so I decided to tether to my G2. The phone was showing all four bars on the HSPA+ network and so I decided to run a speed test. This is what I got:
The average speed for T-Mobile as reported by speedtest.net is around 2Mbps, so I’m surprised that mine is so high. I ran a few more tests and I got results between 2.5Mbps and 3.5Mbps. What bothers me the most is that T-Mobile’s mobile network provides a better upload speed than the measly 896Kbps that Qwest gives me.
Popularity: 3% [?]
Anonymous self-invoked recursive-function in Javascript
I needed to do an n-ary tree traversal recently with some Javascript code that I’m working on and I initially wrote an iterative n-ary tree-traversal algorithm (using a node stack with a while loop). I wanted to keep track of some extra (depth-dependent) data during the traversal and I didn’t like the way I was forced to do it with the iterative algorithm. I also didn’t feel like adding a new function to the namespace. Then I realized that you can create function-literals in Javascript and self-invoke them. So I ended up with the an anonymous self-invoked recursive function. Here’s the basic skeleton for an n-ary tree traversal (this one is pre-order):
(function(node){
for(var i = 0; i < node.children.length; i++) {
console.log(node.data);
arguments.callee(node.children[i]);
}
}(root));
You can also do a binary tree traversal (this one is also pre-order):
(function(node){
if(node != null) {
console.log(node.data);
arguments.callee(node.left);
arguments.callee(node.right);
}
}(root));
Seems very elegant and also very Lisp-like to me (must be the parentheses!)
Popularity: unranked [?]







