Rough Book

random musings of just another computer nerd

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% [?]

February 21, 2011 Posted by | Computers, Java, Programming and Development, Web | , , , , , , , , | Leave a Comment

Scumbag Steve and Y U NO guy

Scumbag Steve broke the build

Scumbag Steve broke the build

IntelliJ Idea Y U NO STOP STEALING FOCUS?

IntelliJ Idea Y U NO STOP STEALING FOCUS?

Popularity: 6% [?]

February 11, 2011 Posted by | Computers, Humor, Musings, Ramblings, and Inanities, Programming and Development | , , , , , | Leave a Comment

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% [?]

January 24, 2011 Posted by | .NET, C#, Computers | , , | Leave a Comment

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% [?]

January 21, 2011 Posted by | Assembly, Computers, Java | , , , , , , | Leave a Comment

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.

A Stargate in Minecraft

A Stargate in Minecraft

A Stargate in Minecraft

A Stargate in Minecraft

A Stargate in Minecraft

A Stargate in Minecraft

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.

A stargate in Minecraft

A stargate in Minecraft

A stargate in Minecraft

A stargate in Minecraft

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% [?]

January 14, 2011 Posted by | Computers, Gaming, Musings, Ramblings, and Inanities, PC | , , , , | 2 Comments

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:

Broadband speed-test results

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% [?]

December 29, 2010 Posted by | Computers, Networking | , , , , , , , , | Leave a Comment

Rooting the G2

As some of you may already be aware, it appears that the G2 has some sort of “magic restore” (it’s not a rootkit) function that causes all changes to /system to be reverted. This means that you cannot remove any bundled bloatware. Even more troubling, it looks like the phone will perform the restore while it is running (i.e, you don’t need a reset). I haven’t turned on my G2, so this is what I’ve heard from people at XDA Developers. You can get temporary root on the devices, but after a little while (some people say minutes, others say hours; experiences seem to vary) root is lost. So it is possible that something is performing the restore while the phone is running.

Helpful folks on XDA Developers have posted the datasheet to the eMMC and another kind soul (damnoregonian) was able to get the value of the CSD register (the register that seems to control the behavior of the MMC): d00f00320f5903fffffffdff924040c8.

WP_GRP_SIZE[36:32] and WP_GRP_ENABLE[31:31] seem to be the bits that control the write-protect (per the datasheet). Currently these seem to be set to the default values per the data sheet (11111b and 1b). Clearing the bits should (theoretically) turn off the write protection. The value to do that would be d00f00320f5903fffffffde0124040c8. The CSD node is R/O and so you cannot echo to it directly. The only way to do it would be to write a kernel module/driver that writes to the register. Apparently the kernel exports a function called mmc_send_csd, and so one should be able to write to this register.

I’m tempted to write a kernel module that does just that. But since working at Intel I haven’t written any kernel drivers. Also while I did write drivers at Intel, I pretty much made modifications to what others before me had written, and so I never wrote one from scratch. I’m going to see if I can start on something this weekend… wish I was still in college… I had a lot more time then!

If this works (and that’s a big if), there’s still the issue of restores being done while the phone is in operation. That could cause a lot of inconsistency. So this might be a partial solution.

Either way, I’m sure someone will come up with a way to root the phone. But if there’s nothing by next Friday, I’m going to return the phone.

UPDATE

Someone posted updated specs. It looks like those bits are read-only. Bummer. Also, this from T-Mobile’s website:

Bellevue, Wash. — Oct. 7, 2010

As pioneers in Android-powered mobile devices, T-Mobile and HTC strive to support innovation. The T-Mobile G2 is a powerful and highly customizable Android-powered smartphone, which customers can personalize and make their own, from the look of their home screen to adding their favorite applications and more.

The HTC software implementation on the G2 stores some components in read-only memory as a security measure to prevent key operating system software from becoming corrupted and rendering the device inoperable. There is a small subset of highly technical users who may want to modify and re-engineer their devices at the code level, known as “rooting,” but a side effect of HTC’s security measure is that these modifications are temporary and cannot be saved to permanent memory. As a result the original code is restored.

Well, T-Mobile. How about you provide us technical users a way to root our devices? What you’re doing is stupid. You’re going against everything Android stands for. If I can’t root it, I think I will return my phone and get a Vibrant instead. I would have expected this from Apple or Verizon. But not from you. Very disappointing.

Popularity: unranked [?]

October 7, 2010 Posted by | Android, Assembly, C, Computers, Hardware, Nerdy Stuff, Programming and Development, Technology | , , , , , , , , , , | Leave a Comment

Unboxing my new T-Mobile G2 Android Phone

My wife called me at work today and told me that my new phone just came in the mail :) . It’s the new G2 by HTC, which is supposed to be the successor to the G1. The specs on this phone are:

  • 3.7 inch WVGA capacitive touch screen
  • 5 megapixel camera with auto-focus and flash
  • Qualcomm MSM7230 800MHz processor
  • 4GB ROM
  • 512MB RAM
  • GPS/aGPS
  • WiFi
  • Bluetooth
  • Android 2.2
  • Runs on T-Mobile’s 4G/HSPA+ network
  • Slide-out keyboard

Read more »

Popularity: 1% [?]

October 6, 2010 Posted by | Android, Hardware, Nerdy Stuff, Technology | , , , , , , , , , , , , | Leave a Comment

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 [?]

September 10, 2010 Posted by | Javascript, Programming and Development | , , , , , | Leave a Comment

Downtime and System Upgrade

Sorry for the downtime. My webserver had a failing hard-drive and I figured that while I was replacing the hard-drive, I would upgrade the entire machine as well. The box was a Pentium 4 1.4Ghz with 512MB of RAM that I hadn’t upgraded since I first built it in 2002. Now it’s been upgraded to a Pentium 4 2.4Ghz (hyper-threaded) with 1GB of RAM. Building from source will be a lot faster now! The whole upgrade process took a while because I was also in the process of upgrading another one of my machines and that took for EVER (some issues with shorting). Finally I had to install FreeBSD (version 8.0) on the new hard-drive as well as Apache, PHP, MySQL, WordPress etc. After I have everything set up, I’m going to make sure that I image the hard-drive so that I can restore it from backup easily.

Popularity: unranked [?]

July 24, 2010 Posted by | Computers, FreeBSD, Hardware | , , , , , , | Leave a Comment

All original content on these pages is fingerprinted and certified by Digiprove