More code for your convenience

I had this log file from my server that's just been sitting there collecting errors for about 2 years. It got pretty big, upwards of 60 MB. So, I wrote this program to break it into chunks. I looked over the FreeBSD documentation to see if there's a program that just reads the last few KB or so. I was getting no output on my new "Browse By Month" code, and when I wrote this program, I was able to split the file into chunks of about 976 KB each (1,000,000 bytes).

package filebreaker;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class FileBreaker {
public static void main(String []args){
String dir = "/usr/home/jason/Downloads/";
String filename = dir + "catalina.out";
int chunk = 1000000;

try {
BufferedInputStream fs = new BufferedInputStream( new FileInputStream(filename) );
BufferedOutputStream os = null;
int itr = 0;
byte []buf = new byte[chunk];
int status = 0;
while (status != -1){
status = fs.read(buf, 0, chunk);
String chunkFilename = dir + "/out/catalina-" + itr + ".txt";
os = new BufferedOutputStream(new FileOutputStream(chunkFilename));
os.write(buf);
os.flush();
os.close();
itr++;
}
fs.close();
}
catch (Exception e){
e.printStackTrace();
}
}
}


I found out the error. I'm using Java 1.6.0 on my local machine, and have yet to install it on my server. I used a method (Calendar.getDisplayName(int, int, Locale)) that wasn't part of Java 1.5.0, which is running on my server. DOH!

I also now like putting code on my website since I have new css for handling <code /> tags. It looks like this:

code {
display: block;
overflow: auto;
width: 600px;
white-space: pre;
}

code br {
display: none;
}


:D My text formatter takes line breaks and replaces them with "<br />", and I wanted code to be preformatted so I don't have to replace tabs with spaces, and also I didn't have to check if I was inside a "code" tag and not insert <br /> for line breaks. It's just a very convenient way to handle it that might look like crap in another browser that's not FireFox. I'll add lots more code now :)

Laptop Configured

Sound works, development environment set up (including eclipse, java, tomcat, mysql, mysql dbs and users [tables and data are automagic]), can't disable the "tapping" on the touchpad yet.

I got the development environment set up after some troubles where I forgot that I depend on some JARs being in the tomcat/common/lib folder, and don't copy them over. Doh. This stuff is all manual.

I had to configure my /boot/loader.conf to load the driver for my sound card (snd_hda), I've been messing around in the same file to see if I can load a 'synaptics' touchpad driver, or enable support, but I don't think I have a synaptics touchpad driver. FreeBSD reports it as a Generic PS/2 mouse otherwise.

I need to disable tapping! When you go to edit a Java file and accidentally move your cursor to the spot where you didn't want to edit at, it's so annoying. However, I did notice that this touch pad IS freakin tiny, and I hardly touch it by accident. That's good.

Scrolling would be nice to have. That's a hardware issue though, no scroll "wheel". I looked around, and with moused options, you can emulate 3 buttons (I have two I think) and enable scroll with a combination of the middle mouse button (in my case both pressed) and moving on the mouse pad. This would be tough. Kinda like pressing CTRL +N+U+<+O+/ Good luck. I'm gonna write a program that says "To uninstall this software, press CTRL +N+U+<+O+/ within the next 2 seconds." Oh, you messed up. Try it for 1 minute and your hand will hurt :)

The ThinkPad T61 that I got comes with a fingerprint reader, and apparently someone made it work on Gentoo, of course, the OS I had on here for a while and couldn't do anything with. I betcha now I could though. I'm not retarded when it comes to setting up a Linux / Unix laptop anymore.

You'll notice I now have a cool "RSS" link in the address bar if you're using a modern browser, like FireFox 2.0.0.11 or 3 beta 3 like I am.

I'm heading up the mountains tomorrow. Might go skiing, might just hang out and drink :) We'll see. I was asked to bring my guitar, but I only have my huge amp now! It's awesome though.

Laptop Shopping...

Blows monkey snot (or insert your own, more vulgar version of "sucks" here). When you're going to look at a store instead of online, of course you have to deal with salespeople who know less about laptops than you do. You can't tell them exactly what you're going to be using it for, because it won't help them decide what model you need, and you already have in mind that you want a "business" laptop. Not something for games, or something with eighteen card readers on it. Definitely not something that comes preinstalled with Windows Vista.

I'm trying to tell the guy, "I don't need HDMI, card readers, Bluetooth, photo album software, MS Office, built in web cam... I have a Mac" :D I just need a good CPU, a fast hard drive, and decent amount of RAM. Wireless is optional. Before I let him in on the little secret that I know a slow mother f@#%@$ing hard drive when I see it, he was trying to push 4800 RPM drives on me.

When he was trying to sell me anti-virus software and MS Office, I sorta just smiled at him and said "I won't be running Windows", in a smart ass type of way that only a true geek can do.

What I ended up with was a Lenovo ThinkPad T61 (as "business" as it gets, and what I have been eyeing online for weeks), with a 14.1" screen (which is running at 1280x800 on Gnome on my FreeBSD, so I'm fine with it), 2.1 GHz Core 2 Duo, 1 GB RAM (but I put in another GB when I got it home), a 100GB 7200 RPM hard drive, and an NVidia basic video card, and tons of ThinkPad goodness (which means nothing!). Minimal but is absolutely awesome. It's 5.3 lbs. It kicks the f%#@ out of my previous laptop's ass. So fast.

Compare to my other laptop (which I'm fuzzy on now):
1.5 GHz single core Centrino, I upped it to 1GB ram, 4800 RPM 60GB hard drive, ATI video card.

A hard drive's speed will make or break productivity in programming. I also just needed an upgrade in CPU speed, and RAM never hurts :)

There's just one thing though that I wish I had noticed about this laptop before I bought it, but I think I can deal with it. Most laptops today have a touch version of a mouse's "scroll wheel" on their pads. My previous laptop has it. This one doesn't :( I can use page up / down, or go old school and use the scroll bar. I'm used to it though, since I had Gentoo Linux on my other laptop for so long, nothing f%@#$ing worked anyway :)

So, I'm installing FreeBSD, getting my development environment set up, and will be creating features for this website, and new websites and software in the near future.

Open Source is so inexpensive

Keeping with my 'money' theme from the last few posts, here we have something on the complete opposite side of the spectrum. Not including donations, I've paid $0 for all of the software on my other laptop, and it does everything.

Now, I've been thinking about doing something drastic. Since I installed Ubuntu Linux, my development time on that laptop has actually diminished about 100%. I haven't done any development on it. This is because it's so f@#$@#ing slow. I do a lot of ANT builds and they just take forever. The drastic thing I've been thinking of is upgrading my laptop to a new one. Preferably a Lenovo ThinkPad or something. Customizing one of those for a Linux installation (everything except picking Linux, since they only offer Vista Home Basic) is a lot cheaper than configuring it for even Vista Home Basic. All I need is 2GHz Core 2 Duo (the minimum CPU option), 1GB RAM (although I've been bumping it up to 2GB in the "Customize" section), 1Gbps LAN, and integrated graphics. I could opt to have Wireless, but that's extra. It's not that expensive, although I can't afford it now.

So, instead of getting a beefier laptop to run a slow operating system (Gentoo ran super fast on the same exact old crappy laptop), I was looking into some other operating system that's just as powerful and fast as Gentoo, but not the hardest thing to set up. In my search, I decided to go with something that I've been eyeing ever since I got into free software. FreeBSD.

Having this Mac, and having nothing to work on when I got a side job doing .NET with SQL Server for one of the local schools (Episcopal Academy, which isn't exactly 'one of the local schools'), and the Mac being Intel, I found out about that program called "Parallels", which can run virtual machines of multiple operating systems. I have a Windows one installed for all of that development I did for EA, and I have an Ubuntu Linux one for when I tried it out (much like now) before I installed it on my laptop. So, I did the same thing with FreeBSD. I think I'm going to give it a shot on the laptop.

It's a lot easier than Gentoo, that's a plus. It's as well documented as Gentoo (just visit freebsd.org and see for yourself), it's *almost* as fast as Gentoo, and it runs Gnome. The only thing that I was wondering was "Will it run everything?" Yes it will.

FreeBSD is Unix, not Linux. While they are similar in some areas, there's others where they are just very very different. Like, FreeBSD and Linux use different threading models, which Sun depends on in its Linux implementation of Java and Sun does not provide a native implementation of Java for FreeBSD, yet. However, you can get "Linux compatibility mode" running on FreeBSD which will make the Linux implementation work on FreeBSD. The down side of that is that FreeBSD has to build the source for Java to install it, and the source is released under an incompatible license. So, when you install it, it fails, and asks you to download certain files before it can continue. And still, after you do that, you're contractually obligated (through the license) to NOT distribute the resulting built Java binaries. It's weird. There is hope, though, as most believe that Java 7 (it's at 6 right now) will be released under the GPL, since Sun completely open sourced Java recently.

So, I'll give FreeBSD a shot, and if it doesn't work out, then I'll download and try out another one!

Interesting side story. FreeBSD offers its ISOs in "torrent" format. I've known what BitTorrent was since about 7 years ago, but never got into it. It's a giant legal mess since it's also used to distribute "pirated" material. But there are very legal, morally good ways of using BitTorrent. Anyway, I downloaded it through that (a BitTorrent client called "Transmission" for Mac, also free open source software), and it's just neat seeing all the people you're downloading the same file from simultaneously. It's really brilliant software, BitTorrent is.