How to put codes nicely in Blog Using SyntaxHighlighter

Link

Change template is one time thing. After that, whenever you need put codes into blog, in HTML mode, put codes between

<pre class="brush:java"> ... </pre>

<script type="syntaxhighlighter" class="brush:xml">
</script>

You have the option to change the type of language, just as we are using java here, here is the list of the supported languages.

class='brush:java'
class='brush:as3'   //action script 3
class='brush:bash'
class='brush:css'
class='brush:groovy'
class='brush:js'    //java script
class='brush:py'
class='brush:sql'
class='brush:xml' //xml, xslt, html

My Template: add before </head>

Faster Copy Files

 
public static void copyFile(File sourceFile, File destFile) throws IOException 
{
  if (!destFile.exists()) 
  {
    destFile.createNewFile();
  }

  FileChannel source = null;
  FileChannel destination = null;
  try 
  {
    source = new FileInputStream(sourceFile).getChannel();
    destination = new FileOutputStream(destFile).getChannel();
    destination.transferFrom(source, 0, source.size());
  } 
  finally 
  {
    if (source != null) 
    {
      source.close();
    }
    if (destination != null) 
    {
      destination.close();
    }
  }
}
    
Link

XStream

http://xstream.codehaus.org/
http://www.ibm.com/developerworks/xml/library/x-xstream/
Library of serializing object to XML and deserializing object back from XML
1) Example of converting a list of object into a XML file:
public boolean XStream2XML(List importEntryList, String strOutXMLFilePath) 
{
  XStream xs = new XStream();

  //by default, xstream will use class's full name
  //you could use alias to avoid that
  xs.alias("entryList", List.class);
  xs.alias("importentry", ImportEntry.class);
  xs.alias("attribute", Attribute.class);

  try 
  {
    FileOutputStream fs = new FileOutputStream(strOutXMLFilePath);
    xs.toXML(importEntryList, fs);
    //a simpler version
    //String xml = xs.toXML(importEntryList);
    fs.close();
  } 
  catch (Exception e1) 
  {
    //e1.printStackTrace();
    return false;
  }

  return true;
}
2) Example of converting XML back to Java Object
String xml = "......";
Person newJoe = (Person)xstream.fromXML(xml);

Create Symbolic Link

ln -s source_file link_name

Java Preferences

Here is the situation, you want to save some user preferences, for example, I like certain columns for a given table, I don't want to customize it every time, I'd like to save it. Originally, I thought I might need a configuration file to achieve this, but soon I realize that it would be a pain, first of all, where to put this file? if my application is achieved, I don't even have the access the application folder. Secondly, every time I update the file, I need search this file and remove the old entry. I think there got to be a better way to do this.

Link
Link

In windows, it's stored under
HKEY_CURRENT_USER\Software\JavaSoft\Prefs

Just so we know, that we could import and export part of Registry, in this way, if we change our machine, we could just export/import and go.

Back up your precious data

Robocopy "C:\Documents" "E:\Back Up\My Documents" /E /V /PURGE /R:5 /W:15

How To Install SSD

Needless to say, SSD is the man at the moment. Let's get down to how to install and transfer your OS.

1. First decision you need make is: install OS fresh or migrate your current system. Install OS refresh is really easy but time consuming, here I take migration path.
2. Back up the data that you don't want to loose. In general, it's pretty safe to migrate your OS to SSD, but you have to prepare for the worst.
3. You might want to clean up your system to save spaces, besides the spaces that your current system takes should be smaller than your SSD size. try Defraggler and CCleaner.
4. Update Chipset Drivers. AMD or Intel
5. Shutdown your PC and install SSD, should be very easy: SATA data cable and SATA power cable.
6. Restart PC, going into BIOS, make sure your IDE is in IACH mode, usually it should be already.
7. Go to buy Paragon Migrate OS to SSD 2.0, it's $20, yes, there are plenty of free ways to do it, but I just find it's worth it to spend $20 to save all the troubles.
8. Run this program, and copy your current system to SSD, it will take less than 10 minutes.
9. Shutdown pc, unplug in your old hard drive, and make sure your SSD is the first choice of starting option.
10. Restart PC, you should have the exactly same system, just much faster now.

After you are done that, there are a lot of stuff that you could do or not to do, here are the lists: