Archive

Archive for the ‘Fixes & Tips’ Category

QuickTip: Mapping your GAC folder in Windows with Subst

December 30th, 2010 1 comment

Here’s a quick tip if you want to browse the files in your GAC easily without messing about with commands all the time. Map the folder  containing the assemblies with the Subst command.

To do that, bring up a console window (Windows Key + R or Start > Run), then:

subst G: C:\windows\Assembly

This will map the Global Assembly Cache folder to your G drive in Windows Explorer. You can also peek around and see how the GAC works.

The folders you’ll find in the mapped drive include – on a 64bit system *:

  • GAC – Non-native assemblies used by .NET 1.x
  • GAC_32 – Non-native 32bit assemblies
  • *GAC_64 – Non-native 64bit assemblies visible only on 64bit Windows.
  • GAC_MSIL – Non-native MSIL (AnyCPU) assemblies.
  • NativeImages_v* – Native assemblies for the framework version and the architecture (Eg. NativeImages_v4.0.30319_64 is for the .NET 4.0 64bit native Assemblies)
  • temp / tmp – Temporary directories (duh!)

To remove the binding, use the Subst command with the -D option.

subst G: /D

That’s it! Have a safe & happy New Year!

{lang: 'en-GB'}
Share

Google opens up VP8 with WebM Project

May 20th, 2010 2 comments

You kind of knew it was going to happen but the mighty Google has open-sourced On2’s VP8 codec and set it free (in the form of a BSD-style license). Don’t forget to read an intro to the WebM VP8 SDK and get the code (the files). Some of the companies backing it and the ideas behind WebM are posted on the first blog entry.

So what is WebM?

WebM includes:

  • VP8, a high-quality video codec we are releasing today under a BSD-style, royalty-free license
  • Vorbis, an already open source and broadly implemented audio codec
  • a container format based on a subset of the Matroska media container

Wonder what MSFT and Apple are going to do? In either case, interesting times ahead for video.

Oh hai, I almost forgot, from their FAQ, some interesting points – besides the Licensing bits.

If I have a video card that accelerates video playback, will it accelerate VP8?

The performance of VP8 is very good in software, and we’re working closely with many video card and silicon vendors to add VP8 hardware acceleration to their chips.

Will WebM files play on my TV, set-top box, PVR, etc.?

Stay tuned! The WebM community is working with hardware manufacturers to bring WebM support to a wide range of devices.

When will other Google products support WebM and VP8?

WebM support in Android is expected in the Gingerbread release (currently planned for Q4, 2010). We expect many other Google products to adopt WebM and VP8 as they prioritize it with their other product requirements. Keep an eye on the WebM blog for announcements.

Man, Google rocks!

{lang: 'en-GB'}
Share

OpenSolaris FIX: Server refused to allocate pty (SSH)

May 11th, 2010 5 comments

Just upgraded a friends OpenSolaris boxen to SNV_134 (latest available from the OpenSolaris dev repository) and after rebooting we realised we couldn’t SSH into it.

Server refused to allocate pty

DOH! This is caused by a known bug that has been around for a few builds now.

You’ll need to modify /etc/minor_perm and add the following to the bottom of the file.

clone:ptmx 0666 root sys

And what happens if your terminals don’t accept keyboard input? You could drop back into the shell *or* be lazy like me, find gText editor in your Accessories, add it to the panel and change the properties to run it as a privileged user:

pfexec gedit %U

Then run the file, open the /etc/minor_perm file, save and reboot. Make sure you change back the shortcut path 🙂

{lang: 'en-GB'}
Share

Ubuntu 10.04 and getting Sun JRE instead of OpenJDK

May 2nd, 2010 1 comment

If you’ve downloaded the latest Ubuntu 10.04 Lucid Lynx you’d realise that they ship with the OpenJDK instead of the Sun (Oracle) JRE. The Ubuntu team has decided to move the Sun Java bits to the partner repository which means we need to do a couple of things prior to getting it through apt-get.
First add the repository to your /etc/apt/sources.list via the add-apt-repository command, then do a full update.

$ add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ apt-get update

Then lets install the Sun JRE & JDK as required.

$ apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts
$ apt-get install sun-java6-jdk

Once installed you can verify the correct JRE is installed with:

$ java -version

I have to say, this release of Ubuntu is incredibly refreshing 🙂 Its matured so well in a short period of time, its definitely got the Lynx Effect(NSFW).

{lang: 'en-GB'}
Share

FIX: WordPress Older Posts not working in IIS with Permalinks

April 28th, 2010 2 comments

I spent some time tweaking my blog today after moving it to some fresh hardware. You may find that everything is loading much faster now which can be attributed to two plugins in addition to the hardware upgrade – wp-super-cache and wp-widget-cache.

I’ve also fixed a long standing bug with my particular configuration of WordPress that runs on IIS which causes the “Older posts” link at the bottom does not function for the second page. The WordPress generated URL for this is

http://www.thushanfernando.com/index.php/Index.php/page/2

Which is a bit problematic, this ofcourse can be reproduced only on IIS from my musings (serves me right eh?). There are a couple of suggestions by people on the forums already, but I wasn’t too keen on them as they seemed too high-level fixes.

I’ve enabled Permalinks with this format:

http://www.thushanfernando.com/index.php/2010/04/28/sample-post/

So I looked through the sources to see why this was happening. After a bit of snooping about I got to the get_pagenum_link function in wp-includes/link-template.php file.

Heres a bit of source for reference – this is with WordPress 2.9.2:

function get_pagenum_link($pagenum = 1) {
	global $wp_rewrite;

	$pagenum = (int) $pagenum;

	$request = remove_query_arg( 'paged' );

	$home_root = parse_url(get_option('home'));
	$home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
	$home_root = preg_quote( trailingslashit( $home_root ), '|' );

	$request = preg_replace('|^'. $home_root . '|', '', $request);
	$request = preg_replace('|^/+|', '', $request);

	if ( !$wp_rewrite->using_permalinks() || is_admin() ) {
		$base = trailingslashit( get_bloginfo( 'home' ) );

		if ( $pagenum > 1 ) {
			$result = add_query_arg( 'paged', $pagenum, $base . $request );
		} else {
			$result = $base . $request;
		}
	} else {
		$qs_regex = '|\?.*?$|';
		preg_match( $qs_regex, $request, $qs_match );

		if ( !empty( $qs_match[0] ) ) {
			$query_string = $qs_match[0];
			$request = preg_replace( $qs_regex, '', $request );
		} else {
			$query_string = '';
		}

		$request = preg_replace( '|page/\d+/?$|', '', $request);
		$request = preg_replace( '|^index\.php|', '', $request);
		$request = ltrim($request, '/');

		$base = trailingslashit( get_bloginfo( 'url' ) );

	if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) )
		$base .= 'index.php/';

		if ( $pagenum > 1 ) {
			$request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
		}

		$result = $base . $request . $query_string;
	}

	$result = apply_filters('get_pagenum_link', $result);

	return $result;
}

This function (from reading through) essentially generates the links for the page numbers & page navigation taking into account Permalinks if configured. This is all fine and dandy for Unix hosts but for Windows, unfortunately this bit of code fails us.

...
$request = preg_replace( '|page/\d+/?$|', '', $request);
$request = preg_replace( '|^index\.php|', '', $request);
$request = ltrim($request, '/');
...

As the preg_replace is case sensitive, it will not replace the invalid Index.php that is seen on IIS. So the easiest fix is to tweak the regex pattern a little bit and tell it be case insensitive.

...
$request = preg_replace( '|page/\d+/?$|', '', $request);
$request = preg_replace( '/|^index\.php|/i', '', $request);
$request = ltrim($request, '/');
...

This will then generate the (invalid) urls and the preg_replace will remove any additional Index.php’s from the request URL as its already mentioned in the $base variable a few lines below:

...
if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) )
$base .= 'index.php/';
...

Once you make the change and upload the files, your “Older posts” will start working again. I’ll submit a patch to WordPress I’ve submitted a patch to WordPress Trac, now its just a wait and see what they say, in the meantime here’s a patch file if you don’t want to modify sources manually. If there any issues, post a comment 🙂

{lang: 'en-GB'}
Share

Upgrading non-Global OpenSolaris Zone to latest BE

January 14th, 2010 1 comment

I’ve been tracking the latest dev version of OpenSolaris (as of writing I just upgraded to Nevada SNV 130 ) because of some issues surrounding CIFS in the 2009.06 image of OpenSolaris.

To update to the latest BE, simply update your packages and image-update (after configuring the dev repository!).

# pkg refresh --full
# pkg image-update
# reboot

If you’ve created zones in your OpenSolaris system after upgrading to the latest BE you will need to upgrade your zones as well. Here’s a simple guide on how to update a zone named tomcat to the BE on the global zone.

# zoneadm -z tomcat halt
# zoneadm -z tomcat detach
# zoneadm -z tomcat attach -u
# zoneadm -z tomcat boot

The output of the attach and upgrade command appears below, here I am upgrading from 127 to 130.

Log File: /var/tmp/tomcat.attach_log.23aWZl
Attaching...

       Global zone version: entire@0.5.11,5.11-0.130:20091219T044839Z
   Non-Global zone version: entire@0.5.11,5.11-0.127:20091111T131831Z
           Publisher Check: Zone preferred publisher does not contain
                            entire@0.5.11,5.11-0.130:20091219T044839Z.
           Publisher Reset: Copying preferred publisher from global zone.
  Updating non-global zone: (Stage 1).  Output follows
DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                              130/130   6842/6842  191.0/191.0

PHASE                                        ACTIONS
Removal Phase                              3529/3529
Install Phase                              7108/7108
Update Phase                               5247/5247
  Updating non-global zone: (Stage 2).  Output follows
No updates necessary for this image.
  Updating non-global zone: Zone updated to entire@0.5.11,5.11-0.130:20091219T044839Z
Attach complete.

Thats it, the updated zones are now booted! Whilst I’m posting this, if you want to upgrade to a specific version of OpenSolaris you can do that too!

# pkg refresh --full
# pkg image-update --be-name opensolaris-128

This will upgrade your BE to 128 instead of the latest – 130.

{lang: 'en-GB'}
Share

QuickFix: jQuery $.getJSON() fails in IE6 & IE7

October 27th, 2009 15 comments

Had a nasty issue with jQuery + jSON + IEx just now – still at work because of it!

This bit of code works perfectly fine on Firefox and Chrome:

function onUnitsModified() {
            $.getJSON("<%=Url.Action("GetTotalUnitCount", "ProjectReaper")%>", null, function(result) {
                if(result > 0)
                  // Do stuffs here
                }
            });
            return true;
}

But in IE we’ve come to realise that the first hit is successful, future json requests ones are not hitting the ASP.NET MVC actions (I put a breakpoint). You could append a time stamp to get rid of this annoying caching bug, but alternatively you can use the ajaxSetup options to disable caching.

function onUnitsModified() {
            $.ajaxSetup ({ cache: false}); 
            $.getJSON("<%=Url.Action("GetTotalUnitCount", "ProjectReaper")%>", null, function(result) {
                if(result > 0)
                  // Do stuffs here
                }
            });
            return true;
}

Darnit! Hope someone else doesn’t waste their time trying to fix this now 🙂

{lang: 'en-GB'}
Share

FIX: OpenSolaris Package Manager fails after adding Extras Repository

October 16th, 2009 No comments

After setting up the extras repository for OpenSolaris I tried to install VirtualBox via the package manager.

thushan@zeusy:~$ pfexec pkg install virtualbox
Traceback (most recent call last):
  File "/usr/bin/pkg", line 2598, in ?
    __ret = main_func()
  File "/usr/bin/pkg", line 2541, in main_func
    return install(mydir, pargs)
  File "/usr/bin/pkg", line 710, in install
    update_index=update_index)
  File "/usr/lib/python2.4/vendor-packages/pkg/client/api.py", line 203, in plan_install
    self.log_operation_end(error=e)
  File "/usr/lib/python2.4/vendor-packages/pkg/client/api.py", line 1410, in log_operation_end
    self.img.history.log_operation_end(error=error, result=result)
  File "/usr/lib/python2.4/vendor-packages/pkg/client/history.py", line 680, in log_operation_end
    self.operation_result = result
  File "/usr/lib/python2.4/vendor-packages/pkg/client/history.py", line 279, in __setattr__
    raise AttributeError("'history' object attribute '%s' "
AttributeError: 'history' object attribute 'operation_result' cannot be set before 'operation_name'.

pkg: This is an internal error.  Please let the developers know about this
problem by filing a bug at http://defect.opensolaris.org and including the
above traceback and this message.  The version of pkg(5) is '87d6ba4c8e1c'.

Uh-oh, what the hell did I break now I thought? After some messing about I realised the time on the machine was a few hours behind – this was just installed on the new hardware I picked up the other day, the certificates were timestamped and I figured this was probably a clash of the space-time continuum. Instead of opting to manually set the time, I let it sync (periodically) with an NTP Server local to us here in Melbourne.

To do this, we enter our NTP server in /etc/inet/ntp.conf like so:

server ntp.mel.connect.com.au

Then we tell it to update itself:

thushan@zeusy:~$ pfexec ntpq -p
 remote           refid      st t when poll reach   delay   offset    disp
==============================================================================
*yarrina.connect mumnunah.csse.u  2 u   20   64  377    50.22  -11.747    0.44

Done, now you’ll find that your package manager will no longer fail with the stack-trace as the timestamps will match correctly!

UPDATE: There’s already a bug report about this in the OpenSolaris Bugzilla.

{lang: 'en-GB'}
Share

Thunderbird 3.0 Beta 4 fixes corrupted summary files!

October 6th, 2009 No comments

Since ditching Outlook after Outlook 2003 (Outlook 2007, 2003 was fine in comparison) came around I’ve been using Mozilla Thunderbird as my ever faithful email client. Its fast, lightweight and not as bloated as Outlook is – couple it with Lightning and you’ll be laughing!

Thunderbird 3 brings some cool features for users with the biggest being tabbed message windows (and calendars etc). If you downloaded the new 3.x betas make sure you get Beta 4, the long standing issue with the Messagebox Summary file being corrupt has been finally addressed. Its been a pet hate for a long time now, sometimes searching a folder can corrupt an MSF (means having to go and remove the MSF so it rebuilds the index!), no more! Thunderbird will now fixup any problematic MSF files in the background, yay!

The search in Thunderbird 3 is a massive improvement over the other clients I’ve used, give it a go!

After you download Thunderbird, make sure you get the latest nightly for Lightning Calendar Addon and Google Provider and use them.

{lang: 'en-GB'}
Share

Microsoft releases Windows Vista SP2 and Windows 2008 Server SP2

May 27th, 2009 No comments

Quick note to let you know that Microsoft has released Service Pack 2 for Windows 2008 Server & Vista for the general public.

Download: Vista SP2 / Server 2008 SP2 x86Vista SP2 / Server 2008 SP2 x64
Download Size: 348.3 MB | 577.4 MB
Direct Downloads: Windows6.0-KB948465-x86.exe | Windows6.0-KB948465-X64.exe

KB Article: Microsoft KBQ948865

Service Pack 2 Details

x86

Build: 6002.18005.090410-1830
File Name: Windows6.0-KB948465-X86.exe
Size: 365,230,920 bytes
CRC: 3368C777
MD5: C9394FD32DB15619328AF4FF0315750A
SHA1: 106C0484D7449CC4B70353C21D0C0D63E4BA66C3

x64

Build: 6002.18005.090410-1830
File Name: Windows6.0-KB948465-X64.exe
Size: 605,410,472 bytes
CRC: 1737E14D
MD5: A3BCB1FFDB366397FA5FAB0898EB098D
SHA1: BE8D74ADC029FA7350FC1F0D32BEF853C0519A92

Enjoy! You can also slipstream this release into an existing SP1 installation media using vLite, just be weary of a couple of caveats.

{lang: 'en-GB'}
Share