Sat, 30 May 2009

10:14 PM - JSON in Java

I've been using JSON with Dojo Data Grids lately in PHP.  Now, I want to use something similar on this site.  I decided on the json-simple library.  It's actually quite easy to use.

Encoding examples:

http://code.google.com/p/json-simple/wiki/EncodingExamples 

<%@ page contentType="text/json;charset=UTF-8" language="java"%>

<%@ page import="com.justjournal.model.User" %>

<%@ page import="org.apache.cayenne.DataObjectUtils" %>

<%@ page import="org.apache.cayenne.access.DataContext" %>

<%@ page import="org.apache.cayenne.query.SelectQuery" %>

<%@ page import="org.json.simple.JSONObject" %>

<%@ page import="java.util.*" %>

<%@ page import="org.json.simple.JSONArray" %>

<%

    out.clearBuffer();

    SelectQuery query = new SelectQuery(User.class);

    query.addOrdering(User.USERNAME_PROPERTY, true);


    DataContext context = DataContext.getThreadDataContext();

    List users = context.performQuery(query);

    JSONObject obj = new JSONObject();

    JSONArray list1 = new JSONArray();


    Iterator it = users.iterator();

    while (it.hasNext()) {

        Map map = new HashMap();

        User u = (User) it.next();

        if (u.getUsername().length() > 2 && !new com.justjournal.User(u.getUsername()).isPrivateJournal())

        {

            map.put("id", DataObjectUtils.intPKForObject(u));

            map.put("username", u.getUsername());

            map.put("name", u.getName());

            map.put("since", u.getSince());

            list1.add(map);

        }

    }

    obj.put("items", list1);

    obj.put("label","id");

    obj.put("identifier", "id");

    obj.writeJSONString(out);

 

tags: dojo java json cayenne

()

10:02 PM - Apache Cayenne

 I've been working on converting just journal over to Apache Cayenne today.  I figured it would give me an opportunity to get better with it.  Cayenne has a nice modeling program, but their documentation is often lacking.

For example, suppose you're getting an error from your servlet container (Tomcat in my case) about a filter not loading.  With Cayenne, the "correct" way to use it is to load a filter mapped to /* that catches all the sessions and maps a DataContext to them.  You might find after pulling your hair out that there is a syntax error in your DomainNode.driver.xml file.  Even with logging cranked up in log4j, it will not tell you what's wrong with the filter.  However, if you initialize like a traditional app in a jsp page, you can see the error.  Invalid passwords are an example of what can cause this.

 

tags: java apache cayenne

()

Fri, 29 May 2009

8:13 PM - Hmm

Wondering why visual stuidio keeps crashing on me. Every time i drag a control in vs2008 after a few saves, it seems to crash. Wonder if it's a vista sp2 bug.

location: Home

tags: studio visual microsoft bugs

()

12:12 AM - Windows VIsta SP2

I installed Windows Vista SP2 Today. It's not too bad so far. It went much smoother than the service pack 1 installation. I have issues with vista, but part of me likes it. It's a love hate thing I guess. I often find myself more relaxed using MidnightBSD or Mac OS. Since I got git and some of the cygwin tools installed, vista is much more tolerable. I just love having a unix like shell with unix style commands. Sometimes I wonder if I could just deal with windows if they'd add them as part of the OS.... nah.

I also installed the direct x sdk today. THe C# support is not as nice as I expected. I'm starting to understand why some people write C++ code still for games. If you want to do any clever transformations, it sucks. (directx 9 at least)

You might wonder why i installed the directx sdk. I want to write a very simple game. Caryn's going to work on the logic/backend and I'm going to write the graphical "engine" to render it.

location: Home
mood: Okay

()

Wed, 27 May 2009

7:54 PM - git tip: configure name

git config --global user.name "John Doe" 
git config --global user.email "john.doe@company.com" 

tags: git

()

2:31 AM - (no subject)

No Doubt will begin touring again.  I find that surprising.  The real question is will they sound like stefani's solo work.  

There's a new vaccine for the swine flu headed toward the CDC for review.  That's good news.  

I've been having trouble sleeping again.  Tonight, I got the I4B stack removed from MidnightBSD.  GCC 4.2.1 is working now in CURRENT.

()

Tue, 19 May 2009

6:07 PM - AMD Phenom: A review

I purchased an AMD Phenom last week. It's a quad core first generation chip with 2.3Ghz cores (9600). The chip works great with Vista and I think it will rock in MidnightBSD once I get some of the stuff on the AMD 7700 chipset fixed. The best part though is the power consumption. The only thing different is the cpu and motherbard, yet i'm seeing much better power use over a core 2 duo 6000 series (2.13ghz). THe new box uses 125-150watts most of the time.

()

Mon, 18 May 2009

11:27 PM - (no subject)

I finally beat Half-life 2 tonight.

()

Sun, 17 May 2009

12:48 AM - (no subject)

I'm still setting up my computer after all the crap. I finally got it running stable. I suspect it was gettnig too hot. I finally got the motherboard drivers installed and it's running much faster. At this point, i need to load SP1, IE8 and a few more programs.

()

Sat, 16 May 2009

9:38 AM - Why Vista Sucks

I seem to be on a role.  

I gave up on Windows Vista ten months after launch.  It "died" because I added more ram.  The file system was corrupted and it just freaked out.  I suspect it was a memory mapping bug with the video card.  It was x64 vista and 4GB of RAM.

Yesterday, I got a new motherboard and processor.  It's an AMD Phenom 9600 and Asus M4A78 Plus. Everything else stayed the same.  I decided that with a major CPU and motherboard shift, I should reinstall Windows.  Why not try 32 bit vista this time?  

After spending 2 hours deactivating amazon unbox, iTunes, adobe acrobat, various games, and other stuff I finally got to put the motherboard and cpu in.  This process took me about an hour.  My case was dirty and I hadn't used an AMD chip in years.  The heatsink setup is much better than the Intel design for core2 and pentium d chips.  

I tested BSD first as I didn't have to reinstall the OS like WIndows.  However, the USB controller and Ethernet are not supported correctly.  I'm already bummed.  Now to install Vista.  

Windows Vista's installer is quite nice and easy to use.  I had to use it twice because I know vista won't let you go from legacy sata to AHCI mode later.  Once the bios was fixed, I got Vista loaded.  

I found that I had to install over 100 updates to vista and that didn't include SP1!!!!!  In fact, it didn't suggest I use SP1 first to save time.  Only 70 installed correctly.  Upon reboot it "tried" again and the update mechanism just froze.  I decided to stop updating and it claimed it stopped.  Next, I attempted to install the chipset driver from ATI.  It seemed to hang near the end, but otherwise looked complete.  I proceeded to install some other software like steam and amazon unbox.  It went fine.   Then after I had setup a good part of the system, I decided to reboot.  BSOD

Try again : BSOD

Try in safe mode: BSOD

Use the repair feature of vista disk which claims not to whack your personal files.  It then told me that it had to use a restore point, but my files would be ok except for a few "programs" i recently installed.  It deleted everything!  It was almost a factory install at that point.  It seems the restore point was at the beginning of the install!  

What have we learned?

1. The dialogs are wrong in the installer.  You can and apparently do lose data with Vista.  Tell the user.

2. The backup software isn't like time machine and i can't get my amazon unboxed videos back.  Mr. Monk and the man who shot santa is gone!  

3. Vista can't shut down.  it takes like an hour and never does anything.  I think this is motherboard related but since i can't install the drivers....

4. Everything is hidden.  I hate that.  

5. The only thing that works worse is KDE 4.  Since it was designed to look like vista, i think they did an exceptional job getting the suck down.

Now, I'm sure you might find the above to be misleading.  Perhaps I did something out of order or "wrong".  If so, Windows let me do it.  That in itself is a bug.  If I can't use it, how on earth could a typical non computer literate person make this thing "go". 

 

()

9:32 AM - Why Amazon Unbox sucks

Amazon unbox service runs on Windows.  Some users of Windows experience problems that require an OS reinstall or even a revert to a previous checkpoint.  The product activation can be lost in these cases.  This means you lose videos that you purchased.  Amazon makes you rebuy videos because Windows has bugs.

At least with iTunes, you can reset it every year (computer count).  Worst case you have to wait a year to get your content back.  It's not gone forever.  

Ways they could improve the service:

1. allow you to deactivate a computer from the web, see a list and make sure it's dead jim.

2. Don't do it in the uninstaller!  What if it goes wrong?  

3. Allow people to reset their activations once in a while.  Just require a net connection periodically to "verify" even.  I don't care as long as I don't lose my damn videos.

4. Ideally provide support for other operating systems.  I know this is a long shot.

5. Give me ANY reason to like it over iTunes.

 

tags: sucks unbox amazon

()

Thu, 14 May 2009

7:56 PM - NBC Sucks (again)

This time, they decided to kill two of the shows I like!  Knight Rider and Life have been cancelled now for the Fall.   I don't get what's going through their minds.  The new shows look stupid.  I won't even try watching them as they'll just get cancelled.  The network doesn't keep shows running or give them time to get a base.  With Monk leaving the air after this season, there won't be a lot left to replace it for me.

tags: sucks nbc

()

Tue, 12 May 2009

10:50 PM - It's that time again

Computer upgrade time! I just ordered an Asus motherboard and an AMD Phenom quad core CPU. This will replace my very festive Intel DP965LT motherboard and Intel Core 2 6420 cpu.

()

Sun, 10 May 2009

9:21 PM - (no subject)

I bought a copy of warcrarft 3 today.  Caryn's had a copy for awhile, but since she's playing it more and I haven't played in some time, it seemed like the right thing to do. :)

I don't have the frozen thrown expansion, just the original game.  It's been fun playing that tonight.  I also installed starcraft (again).  It kind of hit me that I should play some of these games I've got around. 

()

Sat, 9 May 2009

6:52 PM - (no subject)

Well this has been a rough week.  My mother had to go in for appendicitious to the hospital.  She's recovering at home now.

I've been working today in hopes I can catch up for all the work I missed this week.  I managed to create a test database and setup Cayenne's data model and generate classes for it.  We've been using GIT for the project.  Glad it's in Java now.

 

()

Tue, 21 Apr 2009

11:54 PM - Government taking computer security seriously

Finally, the government has started to think seriously about the security of computer systems. It's about time.  I just wish they'd get the power plant stuff off the Internet.  I'm sick of hearing about stories where key infrastructure was in danger because someone was too cheap or lazy to setup a private network with leased lines. 

()

Sun, 19 Apr 2009

1:54 PM - Cost of ownership of your computer

Microsoft has always made a big deal about TCO (total cost of ownership) of various software products.  Lately, they've even claimed macs are more expensive.  

I recently had a discussion with my boss about the value of his laptop that he recently replaced.  I made a comment he got his money's worth because it was beat to hell and he used it constantly.  He took the time to figure out how much it cost him per day to own it.  I never thought about that before with hardware when I buy a new system.

First, I decided to compare apples to oranges... well a mac to a dell.  I bought a dell workstation in 2004 which is now running  as server.  Caryn bought a powermac g4 in 2002.  Both are workstation class and cost about the same amount of money.  Instead of comparing the original suggested retail prices or what we paid for them, I included all hardware upgrades like drives, ram, etc that we did in my calculation.  I did not estimate when the upgrades happened and do an addition technique so this is off a bit. It's probably a bit higher.  The daily cost of the powermac g4 for caryn was $1.095 a day whereas the Dell Precision 650 was $1.150 a day.  Both are over a 5 year period.  However, we still have the powermac and I used it a year after she did (not figured in) and it's sitting unused currently.  The original cost of both machines was nearly identical.  I replaced the video card in the dell within 3 days of owning it (had a firegl card that was a POS).   

Upgrades on both systems include:

Video card (both got ATI cards.. ATI AIW9600XT vs ATI 9800 (mac))  I had to replace the AIW with an nvidia which gave out on me, and the ATI radeon mac card also died taking out the power supply, logic board, and itself in the mac.  These repairs were included.

Hard drives were added to both systems.  Typically they were around $100 or less.  DVD burners were added to both systems.

Of course this is hardware cost.  It has nothing to do with software.  

Another example:

IBM Thinkpad T30 (refurb) bought from IBM about two years ago.  Cost was just under $500.  $0.685 a day before hardware upgrades.  I added ram (had it so free), plus a new hard drive with a cost of $130.  That brings it up to $0.86 a day.  Finally, the wifi card brings it to $0.952 a day!  I did not buy any software for this system as it came with windows and I've been running MidnightBSD on it primarily.

This is a whole new way to look at computer purchases for me.  

Another example: an iMac purchased ~14 months ago would cost the owner 2.79 a day.

A PC bought in 2006, with many upgrades to keep it current would cost $1.65 a day. 

()

Sun, 12 Apr 2009

5:27 PM - (no subject)

 Just eating dinner right now and trying to setup a cvs mirror for midnightbsd.  Odd day so far.

()

Sun, 5 Apr 2009

2:31 PM - FabBSD?

I was just reading the FabBSD website.  They seem to be forking OpenBSD for use with controllers and other machinery related projects.  That means there are at least two forks of OpenBSD now, one fork of NetBSD, two of FreeBSD (plus some commerical variants and distros), and zero for DragonFly, MirBSD and MidnightBSD.  it's getting crowded. :)

At least BSD is getting popular.

tags: openbsd mirbsd netbsd freebsd dragonfly bsd fabbsd midnightbsd

()

Thu, 2 Apr 2009

9:01 PM - GitX update

I opened a trouble ticket with GitX as it does not work with 1.6.2.1 git. How annoying!

()