Archive for August, 2008

Defragmentation

Posted: August 31, 2008 in Computer and Internet

 

This weekend I thought I would have a look at the built in Vista defragment tool and see how well it is working as I have felt a slight performance loss while browsing my files at certain times. Vista has been coping much better than XP though.

Built in to Vista there is a lite version of Diskeeper, at least that is what most sources say as I cannot fully verify this take it with a grain of salt. To evaluate how well the built in Vista defragging tool worked I used a nifty little free tool called HDView, you can use it to view the fragmentation on your drive quickly, it works like the sysinternals version DiskView. I would also recommend another tool called NTFSniffer that you can use to very quickly find a file on your harddrive, especially since it caches everything so the search is fully indexed, no fuss and fast, good complement to Vistas search as you can control it better.

Either way, my harddrive was not as defragmented as I had hoped and even the page file was bogged down with fragmentation, so I decided to set out to find a better solution than the built in version. I found the following 4 tools that stuck with me

People also mentioned O&O Defrag as well as asuslogic but I didn’t try those out.

Defraggler is a neat tool, a one exe kind of program and you can keep dragging with you on your USB or mesh shared folder. JkDefrag is similar and slightly more powerful. However both this programs (as well as the built in Vista) does not defragment the system files including the page file. They are good considering they are free tools. Defraggler seems to have potential because their ccleaner tool is excellent.

I have now tried both Diskeeper and PerfectDisk for a couple of days and my winner is PerfectDisk. It is less bloated and has in my opinion a sleeker interface. Diskeeper had a cool interface showing a log of graphs, however they showed graphs of things I don’t like to see anyway. Diskeeper uses a process of constant monitoring to defragment the drive, I dislike this approach as it is like a antivirus program that runs all the time as well, the only good thing is that it uses up computer resources when you aren’t doing anything, the downside is that they use them up also when you are actually doing things. Diskeeper also refused to defragment in offline mode duing reboot (to defragment certain systemfiles). Diskeeper is also way more expensive and you get 3 licenses of PerfectDisk for a price lower than DiskKeeper.

PerfectDisk is a schedule only tool but it can monitor IO and CPU activity to minimize the impact when you do a defragmentation. It worked perfectly with VSS (so did diskeeper, but not Jk nor Defraggler) not botching up my restore points and previous versions. It handled offline defragmentation nicely and reorders my files in a recently used to rarely used sorting. It defragmented the MFT and the directory nicely, it also tried to but the MFT where statistics show a performance gain according to Microsoft studies.

All in all, cheap, easy and efficient.

Defraggler and Jk are a good replacements if you don’t want to spend money and want a better tool. Jk is OSS and uses the Windows defragmentation API so it is very likely compatible and safe.

Diskeeper, well I don’t see any benefits.

All in all, my computer feels swift as when it was newly installed again, go upgrade the Vista defragmentation tool and get your performance back.

I have been having troubles with the folder view changing in the Explorer every now and then. I have tried to clear out the Bags and BagsMRU keys, and it made it better for awhile and then it started back again.

I just read another tweak Vista Annoyances Resolved. You simple remove the keys, and back Bags\AllFolders\Shell->FolderType=Documents

Seems to work so far. This has been the most annoying bug (part from the Network card problem described before) I have had with Vista. Part from that it has run smoothly and is really a step up from XP, just the search function in the start menu is a feature useful enough to validate an upgrade in my opinion. (Part from a sometimes 50% increase in windowed mode gaming, which is useful when you play MMORPG and don’t want to go full screen)

The article above also hints about other useful tweaks. Vista has received a lot of bad press, most of it is simple false facts and general FUD, normally coming from those a bit upset with Microsoft or simple with a strong conviction that Bill Gates is evil. He may or may not be, but don’t let that stop you from trying out Vista and decide for yourself instead of listening to the popular opinion. You might end up distrusting popular opinions and certain prominent bloggers integrity or at least be more skeptic about them in the future, or perhaps it will strengthen the trust. Go find out, go get the facts it will benefit everyone. There is absolutely nothing wrong with XP nor Ubuntu/Linux it is just in my opinion much lesser of an experience (Vista is still missing virtual desktops built in though, but I can recommend trying out CubeDesktop – 3D realtime virtual desktop manager and task switcher or Otaku Software or if you like it open source this one has promise XP Virtual Desktop Manager – Home).

IE8 beta 2 out

Posted: August 29, 2008 in Computer and Internet

 

The new beta of IE is out. So far it is much faster and has incorporated a few useful feature such as better inpage searching, faster tabs, slightly better recovery. If they could just add a good session manager as the IE7Pro has.

Either way try it out, it has a good compatibility that will fake IE7 if you have problems.

 

Every now I come across a machine which I do not have access to and need access to, not for any illegal purpose, just ordinary machines used to get the job done but I forgot the password used to access it. As having physical access to a machine means its game over it is not really a bother, just a slight annoyance. I am generally surprised as to how simple most passwords normally are and also at the fact that most people (read admins) don’t seem to care much as to how Windows and Linux work and what has to be done to secure them, or at least make it slightly harder. Therefor I thought I would give a few hints and pointers.

I guess in the average company security breaches are rare (at least those that do any damage), and perhaps even if a breach happens the secrets that can be stolen are of less value then the money needed to secure them. But I don’t think that excuses a 15min investment in a few web pages to actually just learn the few tweaks that should be done to your systems. For instance using pass phrases instead of password on your administrator accounts. Also basic stuff about how windows system used to work in Win95 and NT and how that legacy can severely compromise your users. The Windows system (and unix wasn’t any better) had a component called LAN Manager which handled the network stuff back then. Instead of sending passwords back and forth hashes were used, however the hash in the LAN manager is particularly weak and this does not seem to be common knowledge.

If it were I wouldn’t be able to so easily get into most computers. Even when working for Ericsson I found their systems to be lacking the proper security measures, this is a bit surprising as such large corporations put a lot of effort and money into security and still they miss the most basic things. The LN hashes were easily grabbed from your own domain computer by grabbing them from the LN manager’s memory dumps. This is particularly compromising when domain accounts are used for running services, and those accounts are not blocking local logon. The reason for this is that you just need to attack your local computer which leaves no traces and then you have a valid domain account that can reach any computer on the network more or less anonymously. Even worse this password might be a shared secret so it might actually go to more than one account. With some trickery you can quite easily compromise a colleagues password if you intentions are malicious. 

The reasons the LN hash is weak can be read about on the Wiki or any preferred best practices site for computer security but I give a few links below that gives a simple summary as well as describing the most common attack methods on hashes without salting where Rainbow attacks are very powerful (can cut down LN hash recovery to as low as 12s on average). It also gives links to a few useful tools that any admin or user of a computer should use to make sure your passwords are good.

http://technet.microsoft.com/en-us/magazine/cc745951.aspx?pr=blog

http://redmondmag.com/columns/article.asp?EditorialsID=736

And here is an article that you should consider as well

http://technet.microsoft.com/en-us/magazine/cc745951.aspx?pr=blog

Alright it is time to be a bit more provoking (maybe I get a comment =) so I am going to advocate a few MS tools (again), this time Visual Studio and its ecosystem. I can’t say for sure why I favor this suite so much, but once again I hope it is because I have found it to be the most efficient tool for what I am doing. The only downside is that they are not Open Source, but then again Eclipse is and I never have time to alter things anyway, Adobe isn’t and it doesn’t bother me (even though Flash CS3 really needs some love…). Sure it is nice to be able to see the code but it isn’t really a production/efficiency factor for me (and I really doubt it is for many people, they need to invest their time in their core domain not improving tools). Beside Visual Studio is based on the Visual Studio Shell (a free tool you can use to make your own IDE for your own language) so it is really very plugable and extendable without having the complete code.

In general I have not really understood the necessity of everything needing to be Open Source, it is surely nice, it surely benefits society as it is an endless source for education for developers, it allows me to tinker with things if I want (however very very few people have the ability to, even fewer people actually have time to actually do just that). I find it much more important that I the tool is working, is being actively developed and improved and not forked every fortnight.. Perhaps I am close minded..

So I have been playing around with the gold mine of free features in the express editions (http://www.microsoft.com/express/download/) (I am a long time use of the professional editions, all the way back when Turbo C and Delphi were the competition). It is really nice to see that effort is put into competing with eclipse and other free (as in no charge) tools out there. It would be a shame to lose a whole generation of potential developers just because they couldn’t get there hands on the tools. Visual Studio is one of the best IDEs I have ever used, and I have used and use many daily (among them eclipse). Teh debugger is probably the feature that stands out the most and also the fact that many features are already installed by default compared to eclipse where you have to go plugin hunting, which is a never ending story. Not to say that there aren’t plugins for VS that are really useful, such as FXCop, DevExpress or ReSharper, Workspace Wizard to name a few. One usage annoying downside to the Express versions though is that plugins are not allowed…

The Visual Studio tools are starting to blend together better and better and I wish they would release the Expression Blend in a express edition as well so some competition could happen on the Adobe Flash because that is really one of the most horrible IDEs I have to stand daily especially the utterly useless debugger (and the propriety binary only mergeable FLAs..).

In this suite of tools (that has been available for paying developers for a long time) you can find a fully fledged, fully functional SQL Server. Easy to configure, rock solid stability and best class performance. The ease of setting it up makes MySql or your choice of FOSS servers seem almost prehistoric (in my opinion). I have a hard time seeing why one would choose SQLite or MySql when the express editions of SQL Server are free (as in no charge) unless of course you believe you are a database developer and can really contribute to the server and needs the sources to do it, frankly I believe that will only slow you down, leave it to the database wizards instead. Or of course if your preferred development machine and deployment environment is unix based, then you are out of luck =) And of course we all have different preferences. Perhaps I have a different mindset because I could never get my head around MySql it still feels like I am always fighting it to get things done or perhaps I am indoctrinated due to using MS tools for too long so I can’t see the path of the righteous any longer..

Either way one problem you might stumble upon is that by default the only local connections are allowed (quite reasonable as it is mainly meant for development, use SQL Embedded for deployment for your small applications). However this can easily be changed to allow remote connections and also over TCP/IP. Check the Surface Area Configuration tool that install along the SQL Server. Next problem might be that the SQL login is not enabled by default, only Windows authentication is (might cause you troubles if you have process in unix wanting to join the fuzzy SQL world). This can also easily be changed through the free "SQL Server Management Studio Express (http://www.microsoft.com/downloads/details.aspx?FamilyId=C243A5AE-4BD1-4E3D-94B8-5A0F62BF7796&displaylang=en)". This tool is a basic version of the Query Analyzer and SQL Enterprise Manager in one. Simply right click the SQL Server and choose properties, then select Security, change to mixed mode and restart the SQL Server.

If you want to use the "sa" login you will need to enable it as well, also done through the Management Studio, connect, open the Security tree node, open Logins, right click "sa" and chose properties. Open Status and check enable.

Before the 2005, the express editions were missing useful management tools and you were forced to use the command version (sqlcmd, osql etc) which is fine for installation scripts, but not really when you want to develop and change a lot of a stuff often, a GUI really is the way to go (unless you love wading through manual pages to figure out the commands).

Give it a try, the tool works with SQL 2008 so it can be useful for you if your production test database is something you like to fiddle with without buy another license (not sure you are allowed to connect to a production system). The Express edition of 2008 (updated tools coming soon) is out and comes with plenty of new and very cool features such us Power Shell integration (http://technet.microsoft.com/en-us/magazine/cc434690.aspx).

Java in the mobile

Posted: August 18, 2008 in Computer and Internet

A short note on how to get started on developing java for a mobile phone.

I am not fond of eclipse but for java development it gets the job done fairly well (the debugger integration really needs to be fixed, which is one of the main reason you (or at least me) actually chose an IDE over another)

There is one part of the Java standard that is specifically targeted for mobile devices, it is called J2ME, and we are going to leverage that here. You will need to following

  1. Install the JRE
  2. unzip eclipse.
  3. Install the WTK (remember where you put it, you will need it soon). Start eclipse and go to Help->Software updates. Add the eclipse me update site, install eclipseMe.
  4. Go to Window->preferences->J2ME, set the WTK Root.
  5. Go to device management, import, once again point to the WTK root, press refresh, import the devices.

A note, remember that eclipse is silly enough to store the devices for the WTK in the workspace, so if you create a new workspace you need to redo this operation (5). Never really understood the workspace idea in eclipse, I guess it is useful if you work on a million different things at once and want them separated, but it makes a mess keeping in synch.

You are now set to create your first Me application, there is a new project type called J2ME Midlet Suite, create one and start coding!

You will need to derive your main class from MIDlet, there are many samples out there in the web. Here is a very simple one

   1: import java.io.IOException;
   2: import java.io.InputStream;
   3:  
   4: import javax.microedition.io.Connector;
   5: import javax.microedition.io.HttpConnection;
   6: import javax.microedition.lcdui.Command;
   7: import javax.microedition.lcdui.CommandListener;
   8: import javax.microedition.lcdui.Display;
   9: import javax.microedition.lcdui.Displayable;
  10: import javax.microedition.lcdui.Form;
  11: import javax.microedition.lcdui.StringItem;
  12: import javax.microedition.lcdui.TextField;
  13: import javax.microedition.midlet.MIDlet;
  14: import javax.microedition.midlet.MIDletStateChangeException;
  15:  
  16: public class TestApp extends MIDlet implements CommandListener {
  17:  
  18:     private Command exitCommand = new Command("Exit", Command.EXIT, 1);
  19:     private Command connectCommand = new Command("Request", Command.OK, 1);
  20:     private boolean firstTime;
  21:     private Form mainForm;
  22:     private Display display;
  23:     private StringItem messageItem;
  24:  
  25:     public TestApp() {
  26:         firstTime = true;
  27:         mainForm = new Form("TestApp transaction request");
  28:         messageItem = new StringItem(null, "");
  29:     }
  30:  
  31:     protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
  32:     }
  33:  
  34:     protected void pauseApp() {
  35:     }
  36:  
  37:     protected void startApp() throws MIDletStateChangeException {
  38:         if (firstTime) {
  39:             mainForm.append("This demo of TestApp, UserID and password");
  40:  
  41:             mainForm.append(new TextField("UserID", "", 15, TextField.NUMERIC));
  42:             mainForm.append(new TextField("Password", "", 4, TextField.PASSWORD | TextField.NUMERIC));
  43:             mainForm.append(messageItem);
  44:  
  45:             mainForm.addCommand(connectCommand);
  46:             mainForm.addCommand(exitCommand);
  47:             mainForm.setCommandListener(this);
  48:             firstTime = false;
  49:         }
  50:  
  51:         display = Display.getDisplay(this);
  52:         display.setCurrent(mainForm);
  53:     }
  54:  
  55:     public void commandAction(Command cmd, Displayable disp) {
  56:         if (cmd == exitCommand) {
  57:             try {
  58:                 destroyApp(false);
  59:             } catch (MIDletStateChangeException e) {
  60:                 e.printStackTrace();
  61:             }
  62:             notifyDestroyed();
  63:         } else if (cmd == connectCommand) {
  64:             Form waitForm = new Form("Waiting...");
  65:             display.setCurrent(waitForm);
  66:             Thread t = new Thread() {
  67:                 public void run() {
  68:                     connect();
  69:                 }
  70:             };
  71:             t.start();
  72:         }
  73:     }
  74:  
  75:     private void connect() {
  76:         HttpConnection hc = null;
  77:         InputStream in = null;
  78:         String url = "http://www.funky.uril/login.asp"; //getAppProperty("TestAppMIDlet.URL");
  79:  
  80:         try {
  81:             hc = (HttpConnection) Connector.open(url);
  82:             in = hc.openInputStream();
  83:  
  84:             int contentLength = (int) hc.getLength();
  85:             byte[] raw = new byte[contentLength];
  86:             int length = in.read(raw);
  87:  
  88:             in.close();
  89:             hc.close();
  90:  
  91:             // Show the response to the user.
  92:             String s = new String(raw, 0, length);
  93:             messageItem.setText(s);
  94:         } catch (Exception ioe) {
  95:             messageItem.setText(ioe.toString());
  96:         }
  97:         display.setCurrent(mainForm);
  98:     }
  99:  
 100: }

Collection of sun software

http://developers.sun.com/mobility/allsoftware/