Recent Post

Categories

Archives

Cow Computing

10 Mar 8

Wordpress Error: Cannot Modify Header Information

Have you ever encountered the error: “Cannot modify header information” when you try to access the admin page of wordpress? The debug message might have suggested you to look at “pluggable.php”. When searching thru google, people often advise you to turn off installed-plugin one by one to see if the problem get resolved.

The above might work, but i would suggest you to try the following method before going thru the turn-off plugin cycle. For example, if you have modified “functions.php”, and the above header information header appeared right after, you can easily resolve this by removing all the extra whitespace before the “<?php” and “?>” tag. Viewing thru editor, you might not notice any whitespace, but try this trick:

  1. Remove the “>” from the “?>” tag at the end of file
  2. Then keep holding Delete key (not backspace) for a few seconds. (*note that the cursor should be locate after the “?”)
  3. You will notice some whitespace being deleted. Amazing isn’t it?
  4. Add the “>” after the “?” to properly close the php tag
  5. Save the file, and try accessing it, the header information error should have been resolved
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Twitter

10 Mar 4

Finding Files with particular extension or Pattern in Java

Often, to find a file with a particular extension or naming pattern within a directory, we might implement as below:

// The directory which search would be conducted
File directoryForSearch = new File("C:\folder");

// This may not be the best way to accomplish the task, please bear me with it
File[] allFile = directoryForSearch.listFiles();
File[] resultFile = new File[allFile.length];
int resultCount = 0;

// loop thru the list of files to find the required files
for(int i=0; i<allFile.length; i++)
{
    if(allFile[i].getName().matches(".*\\.java")
    {
        resultFile[resultCount] = allFile[i];
        resultCount++;
    }
}

Read More / Comment »

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Twitter

10 Mar 3

Some Hidden Mac’s Tips (Terminal Cmd)

In this post, i would like to share a couple of hidden terminal command on mac to help unlocking some useful feature. To use these feature, simply type the command as if it’s shown on the terminal, andd there you go.

  1. Using current Screensaver as the Wallpaper. This can be gorgeous, however, depending on which screensaver you pick, it might take up some CPU & memory. (*To stop it, simple press “Ctrl+C”)
    /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background
    
  2. Enable hidden files/folders be shown on Finder. This is very useful in particular when you want to locate some important hidden files like “.ssh” or “.bash_rc”.
    // Change TRUE to FALSE to disable the effect
    defaults write com.apple.finder AppleShowAllFiles YES
    
    // Restart the finder to take effect
    killall Finder
  3. Enable the highlight effect on Stack (Highlight the icon when mouse hover)
    // Change yes to no to cancel the effect
    defaults write com.apple.dock mouse-over-hilte-stack -boolean yes
    
    // Restart the Dock to take effect
    killall Dock
  4. Read More / Comment »

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Twitter

10 Feb 8

Fsutil – The Useful Administrative Tools in Windows

Fsutil is a command-line utility for performing file system related tasks,  such as displaying/managing file or drive properties, dismounting or extending a volume etc. Fsutil is a very powerful tool and is meant to be used by system administrator to perform advance operations. In this post, i will try to share my knowledge on fsutil to perform some simple yet useful tasks.

(*Do learn about what you are doing before executing a command.)

1. Creating a file of a specific size instantly, e.g. 1GB

# fsutil file createnew <filename> <filesize>
fsutil file createnew testfile 1073741824

Read More / Comment »

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Twitter

10 Feb 7

HTML 5 nth-Child

As we all know, HTML 5 is on its way, and there’s going to be a huge addition to the current syntax. In this post, i shall share with you about the “nth-child” feature. Often, we would like to create a table or list with alternate row color as follow:

// HTML Snippet
<div id="test-area">
  <ul>
    <li>row 1</li>
    <li class="even-row">row 2</li>
    <li>row 3</li>
    <li class="even-row">row 4</li>
    <li>row 5</li>
    <li class="even-row">row 6</li>
    <li>row 7</li>
    <li class="even-row">row 8</li>
    <li>row 9</li>
    <li class="even-row">row 10</li>
  </ul>
</div>
// CSS Snippet
ul {
  list-style: none;
}

// color the even rows
.even-row {
  background-color: #ccc;
}

Read More / Comment »

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Twitter