Monday, September 21, 2009

Snow Leopard 64 bit kernel on a MacBook5,1


I was playing around with Snow Leopard today and for no better reason than "It's neat" I decided to try and boot into the 64 bit kernel. Apple has left the default kernel, on non server editions, to default to 32 bit. Many people have complained about this stating it's slower and can't access > 4GB of memory and can't run 64 bit apps correctly etc etc. Well it's all a little bit of FUD. Apple also included the 64 bit kernel ability but defaulted it to 32 mainly to avoid 3rd party software/drivers/kexts that rely on the 32 bit kernel. Windows Vista 64 had similar issues with drivers etc. And while in 32 bit kernel mode applications can still run in 64 bit mode just fine, without any type of 64 to 32 virtualization. So right now there really is no reason, for most, to run in 64 kernel mode other than "It's neat".

If you'd like to try, and have a 64 bit cpu with 64 bit EFI (Core 2 duo / Xeon), simply reboot/turn-on and hold down the '6' and '4' keys. If it works your computer will boot a little bit slower as it makes the switch (if you set it to always boot in 64 bit mode you wont see this delay). You can check wether it worked or not by either checking the kernel process in the Activity Monitor or type
  uname -a
in the terminal. The result will end in 'x86_64' if it worked. Or you can also click the 'Apple' and go to 'About This Mac' and click the 'More Info...' button. From there click the 'Software' group towards the bottom. The line that says '64-bit Kernel and Extensions' should say 'Yes'.







If it didn't work then you may be lucky like me and have a MacBook or Air etc. Apple has black-listed these and deemed it an option only available for the elite Pros (MacBook Pros, MacPros...and XServes). But you can still try it thanks to this guy, Amit Singh. It's been a while since I've had to use a hex-editor for something like this but it was fun :)

0xED, and Hex Fiend are both good...

Basically I followed his post pretty close. Simply made a copy of /usr/standalone/i386/boot.efi (I called it boot64.egi) as   /System/Library/CoreServices/boot64.efi
Then opened it with a hex editor and adjusted the 'black-flag' bit value for my corresponding machine.
(I didn't have to chown the file or chflags as my copy was already set)
Then blessed it with
  sudo bless --folder /System/Library/CoreServices --file /System/Library/CoreServices/boot64.efi
This sets the newly modified .efi to be used during boot.

After that you can now use the '6' + '4' and the '3' + '2' options while booting/restarting.

I also set mine to always load using the 64 bit kernel, again for no better reason than "it's neat-o". This can be done by editing the file
  /Library/Preferences/SystemConfiguration/com.apple.Boot.plist
And change this
  <key>Kernel Flags</key>
  <string></string>

to this
  <key>Kernel Flags</key>
  <string>arch=x86_64</string>


Now Snow Leopard will boot by default with the 64 bit kernel, you can still hold down the '3' + '2' to boot using the 32 bit kernel.


Problems:
I'm running on a pretty fresh install of Snow Leopard and haven't done a whole lot of testing yet. But so far most things run great. 32 bit applications still function fine in their 32 bit modes as well. The only application that hasn't worked so far is VMWare Fusion, but this may change with the next version or so. VirtualBox does indeed work with the 64 bit kernel though so I will be trying that out with Windows 7 in the next few days.

Friday, September 18, 2009

Windows 7 and Visual Studio SLN files.... uggh

My 2003 server VM went out the other day at work so I figured I try out the new Windows 7 that I've been hearing so much goodness about.

I downloaded the ISO and began the install (installing within Fusion). I left to go get a drink thinking it would take no less than an hour. I came back to my desk and was very nicely surprised to see that the install had finished. I think this was the fastest Windows install I've ever done.

Another nice thing I've noticed so far is how much easier it is on my system. Before 2003 was always using some of my cpu doing whatever it is that it does. 7 on the other hand lets my system idle at around 3.5% (running in Fusion). It also seems snappier as well. So far I was really quite impressed, well first impressions anyway.

Then some ugliness started shining through. The "Yes I really really really do want to run this application" UAC stuff isn't as bad as it is in Vista, but it's still pretty annoying at best. I began loading my work projects over and tried to double click a web solution. Well, it threw up about 4 dialogs that I had to click whatever on to make them go away. These where all UAC related dialogs. I then set VS to always run as administrator, so much for the UAC protection eh. Then all seemed to be good in the world, until I tried to double click the solution again. I watched as the little loading spinner briefly popped up and then went away. Then I waited... and waited... Nothing, no error message, no UAC.... NOTHING. So I took the option to always run as admin off and I was back to where I started.

I found this 'feature' according to MS
That is quite frankly, stupid.
I guess you can set .sln files to always load with VS2008, or whatever, and that fixes it. But it's just kinda ugly. The sad thing is that the bug was reported back in 2007 so I don't think it will be resolved any time soon.

I guess I'll hope that I love everything else about it and that nothing else is wrong..

Tuesday, September 08, 2009

I guess after six years I can't complain

I was a little late paying my internet bill this month to Comcast, as they kinda screwed it up the month before.... It went out today and I thought it may have been just because the bill was late.

For the last six years I've had two cable modems on a single account. Comcast hadn't ever quite figured it out. It's been nice having Vonage on one modem with a wireless router and everything else on the other modem.

Well when I finally called in today to see if it had just been disabled because of my bill the support person informed me that they had removed a 'rogue' modem that had been on my account.

It's been there for six years so I can't complain I guess. But I sure will miss the thing

Monday, September 07, 2009

IE8 document.compatMode

With all the proliferate hacks out there for IE browsers, IE8 stacks some more on top.

During our last release cycle our QA department started sending back issues revolving around the new IE8 browser. Many of these where related to javascript. One simple fix to get this out the door was to just force IE8 into compatibility mode until we had more time to deduce all the little issues. Unfortunately this fixed some issues while creating others, ugh.

Basically it boiled down to this. Our ASP application says that the browser is IE8, and in javascript it will also say that it is version eight, while in normal mode. The issue, when in compatibility mode, is that it still registers in ASP as IE version eight, but in javascript it now says it is version seven, or whatever compatibility mode is used. So additional IE specific code was added on top of already IE specific code to now check document.documentMode as well.

I do like working with IE8 much more than it's predecessors, but it is still not quite up to par which just adds more development time to now make things work in all the different, very different, flavors of IE.

Here's a good summary of things IE8 finally got right and others that are still not.

And VML also took a hit with the new browser.

Another issue with VML that I noticed the other day was that IE8 now supports element.hasAttribute/getAttribute. But I guess the support is not that great, at-least for VML.
I had a simple script that works with both SVG, the standard, and VML, the non-standard.
There was a method that did something like

if(elem.hasAttribute) { do standard SVG stuff here }
else { do non-standard VML here }

With IE8 the first condition will now be hit, which is good but also bad since IE doesn't support SVG. So yet more IE code was added to resolve this issue. I figured I'd take advantage of the newly getAttribute functionality in IE8 to get the 'fillColor' attribute of a VML element.

Well, this didn't quite exactly work. The attribute was never found. IE8 seems to only report a single attribute for every VML element regardless of how many are actually in the XML. So I could get the first attribute using the new 'getAttribute' in IE8, but unfortunately 'fillColor' was not the first attribute within my VML, so it was back to changing the code yet again for IE to ignore the newly added 'getAttribute' and go back to elem['attrib'] instead, since this would actually give me ALL of the attributes per element.

I guess this is what we have to look forward to until ver. 9 :)

The Way It Should Be

Upgrading/Moving from one computer to another is always painful and usually the only thing that makes it worthwhile is if you're moving to a newer, much nicer, machine. I recently got a MacBook 13.3" (3 weeks before the pro was released, sad) and have been living partially on that. My tower, Mac Pro, has been feeling somewhat neglected. My wife has been doing more video editing lately and needed something a bit faster. I decided to give her my tower, gulp, since I haven't been using it much anyhow.

I was already partially up on my laptop so it was just a matter of copying over any remaining items. After this was done I did a fresh install on the tower. I've seen the 'MIgration Assistant' application before but had never really given it much thought. I had made the basic assumption that it wouldn't do exactly what I wanted and there would be a bunch of manual intervention as well. I had installed the new Snow Leopard on the tower while her old laptop was running the previous Leopard. I decided to give the Migration Assistant a try, expecting a lot of additional work afterwards. I hooked up the computers via Firewire and started the Migration....

The assistant started up and located the old mac right away. Then it searched through it and gave me a check box list of items I could move/leave. I left everything default and let it run. My wife has our whole family album all digitized in iPhoto, about 130 Gigs not including videos, so you can imagine that it did take some time.

Once this was all finished I was very surprised by the results. It actually migrated over her user from the old computer. It kept her login items, login image etc. It even set her wallpaper to what it was before with all the same settings. Screen saver was the same, along with settings. "That's pretty neat" I thought as I opened up iTunes. Wow, iTunes kept everything just as it was on the old machine, ratings etc. Next I opened up her email. All her emails where setup and it even moved over her existing inbox emails! Her calendar kept all her events and so did Address Book. Then I looked down in her application bar. It was setup just as it was on her previous computer. It even moved over applications that hadn't been installed yet!

When everything was said and done the only thing she noticed after the move was that her computer was faster. There was nothing else that she noticed different from the day before.

Thursday, April 23, 2009

IE still sucks...

I was given a small internal web project to work on last week. The best part about it was that I was given free reign on it's design and technologies used. I was pretty excited since I could finally use all of the new HTML/CSS/ECMAScript standards (existing and proposed). This was mainly nice since I didn't have to do stupid hacks and things for all of the different flavors of IE.

I didn't 'have' to support IE for this project but decided that I'd finish the project and then see how the new IE8 faired.

Well... I was, not surprisingly, let down again by IE. Here are a few things I noticed right off the bat.

1) No canvas support :( STILL!!! Firefox, Safari, Chrome and Opera support this. I guess MS is not being pro-active about supporting new standards as the canvas tag is part of the HTML5 spec. There is however this project ExplorerCanvas which does some nice javascript conversions to VML for IE so that you can use most of the features of the canvas tag.

2) Proposed ECMAScript Harmony features have been left out. This is funny since MS was one of the big proponents of limiting the proposed features of ES4 and yet they still can't get the limited functionality implemented (of which Firefox and Safari already support). For instance the new getters/setters and 'foreach' function of arrays makes IE8 confused (these are just a couple I noticed).

I wasn't too surprised by this lack of new features. But I was surprised to see some CSS3 selectors working, and that the site rendered very close to how Firefox and Safari/Chrome did (but not exactly, as there where still some things that where off). So I guess I'm happy that IE has made a huge jump since IE7, but it's still not there which sucks since IE6 is still one of the most dominant browsers used so I guess we can all look forward to missing things in IE8 for the foreseeable future. Ugghh..

Wednesday, May 14, 2008

missing ( before formal parameters


I ran across this little error the other day when I ran some javascript that was working fine in IE but Firefox just didn't like.
It was pretty easy, but vague, to track down what Firefox was complaining about and it was just another difference between JScript and Javascript ugh.
Here's a little example of what was causing this issue.

<script type="text/javascript">
// just create some dummy variables for namespaces
var some = {};
some.namespace = {};

(function($) {
function $.testFunc() { /*some code here*/ }
})(some.namespace);
</script>

The problem is when creating the testFunc function. JScript allows the '.' in the declaration and Javascript does not. Here is a quick and simple fix for this that will work in both IE and Firefox (and Safari).

<script type="text/javascript">
// just create some dummy variables for namespaces
var some = {};
some.namespace = {};

(function($) {
$.testFunc = function() { /*some code here*/ }
})(some.namespace);
</script>

Thursday, February 28, 2008

Some Fun Generating 'the power of' With F#

So for my first bit of fun with F# I figured it'd be fun to play with the BigNum (used for crazy big numbers) I figured I write up some quick functions that simple generate the power of some number, resulting in some crazy big numbers :)

(*all of my examples include '#light')

My first function doesn't use the BigNum but it's very simplistic.

let rec pwrof x y =
     if y = 1 then
         x
     else
         x * pwrof x (y - 1)

So for everyone new to F# 'pwrof' is a recursive function that takes 2 ints. 'rec' lets the compiler know that the function is recursive and the 2 parameters get resolved down to being ints at compile time. This came pretty naturally for me coming from a C# world, so lets try to mix it up a bit.

let rec pwrof x y =
     match y with
     | 1 -> x
     | _ -> x * pwrof x (y - 1)

This function does the exact same thing, but instead of using a familiar if/else statement we're using pattern matching (these are widely used in F#). It's like a switch statement. If y matches 1 then we return x, otherwise if y matches anything else, '_', then we recurse.

These were kinda fun, but I wanted to calculate crazy big power of calculations like 5000^5000. So here's an example that resembles my first function

let bpwrof x y =
    let x = Microsoft.FSharp.Math.BigNum.of_int x
    let pwr = x
    let rec pwrof x y =
        if y = 1 then
            x
        else
            pwrof (x * pwr) (y - 1)
    pwrof x y

And here's an example that resembles my second function

let bpwrof x y =
    let x = Microsoft.FSharp.Math.BigNum.of_int x
    let pwr = x
    let rec pwrof x y =
        match y with
        | 1 -> x
        | _ -> pwrof (x * pwr) (y - 1)
    pwrof x y

These are tail recursive so you can create some really, REALLY big numbers. If you call one of the last 2 functions you can calculate say 5000 to the 9000th power. It ends up taking a lot more time to print the result to the screen than it does to do the calculation(its pages and pages of number madness). I even tried 5000 to the 90,000th pwr, that's a big number.

 

Oh well, that's all for now...

Sunday, February 17, 2008

F# again

I had blogged about F# a while back and though I had tinkered around with it a bit, I got a little busy, and a little lazy. I've decided I'm gonna stick with it this time and learn it :) which means more upcoming blogs about F# (I haven't blogged in a while either so this will get me motivated)

I'm not one that enjoys scouring the web for information on things so I usually just go buy a book on whatever it is that I'm interested in. I decided the other day to head down to the local Borders and there was one copy left of Robert Pickering's F# book, titled 'Foundations of F#'. I'm currently only a few chapters in but it seems like a pretty good book thus far. It hasn't required a background in functional programming which is good and also seems to be a good read for the novice to expert programmers.

Well that's all for now, maybe next time I'll have some F# knowledge to share :)

Monday, November 19, 2007

14% done VS-2008

Eber told me today that the VS2008 was on MSDN.. I was pretty excited so we both logged into MSDN (which was amazingly slow today :)..
But we couldn't find it listed in the DevTools section..

We ended up finding it on the main page of MSDN(before you log in).

It's under the 'Top Downloads' section..

Sunday, October 28, 2007

Leopard

Leopard came out the other day and I started to loose anticipation for the release when it seemed more and more features were being dropped, or were just not being added as features. I was expecting that with the new Boot Camp there would better NTFS support, but the sales pitch from Apple on this is “Leopard understands the Windows FAT32 disk format”. I guess I could use NTFS-3G’s driver for this, but I guess I’ve been spoiled for too long and wanted it built right in :).

A feature that was actually on Apple’s web-site but then mysteriously disappeared was “Fast Switching” for Boot Camp. This would basically put one OS into hibernation and load up the other OS (Awesome if you don’t want to close all your programs down before switching).

BUT! There are a lot of things that I really like about the new OS. Probably one of my favorite things is the path bar in Finder (bread crumb like trail of where you are in the file system). This is one thing that always drove me nuts, when you had a file up and you had to do info or something on it to know where it was in the FS.

Spaces is probably one of my other favorite things. If you have a laptop and need a lot of stuff on the screen it’s nice to be able to place things in different spaces. I wasn’t too excited about this until after I loaded up Parallels and I could go full screen on one space and easily go back to a screen with all my Mac stuff. Parallels has Coherence but with all the Windows stuff I sometimes have loaded it’s easy for my screen to get cluttered.

I’ve never used iChat, simply because most of my contacts are using MSN. Well iChat still doesn’t support MSN BUT it does support Jabber now (as well as Google Talk, since it’s a Jabber too). So all I had to do was find a Jabber server that had MSN/AOL/Yahoo etc transports. The only bad thing was that I had to use Psi to create an account on the Jabber server I found to create my Jabber account. Once my Jabber account was created I could point iChat to it and I can now talk to all my MSN/Yahoo..... contacts. The other downside is that if you have Google Talk and a Jabber account (or more than one account of anything iChat supports) then each account gets loaded in it’s own window, instead of consolidating all your contacts into just one window. I’m still up in the air about iChat, I may still go back to using Adium since it pretty much supports anything you’d ever use, and they have announced that they are going to support video chats in the near future.

So far for the most part I like Time Machine. I don’t like the dock if it’s on the bottom (don’t like the reflective thing the icons sit on) good thing I always place it on the left (no reflectiveness if the dock is on the sides of the screen) I guess you can turn it off, I found a quick little shell command to do it but didn’t bookmark the site where I found it :). I don’t care for the little cross-walk in the dock (used for changing the dock size). Oh I forgot, I love the new Quick View feature too, much quicker to quickly grab something from a dock instead of loading up whatever to view it. Other than that I’m happy with it, they didn’t make major changes to where everything is so I didn’t feel lost like I did with Vista.

Whoa whoa! just as I finished writing this I think I just found my biggest complaint! I use Pages to do my blogging, I export it as HTML and use a Ruby script to make it Blogspot happy and get rid of the extra CSS it generates. Well just as I finished I went to export it as HTML and well.... that feature is GONE! (Right after I installed Leopard there was a Pages update so I figure that removed it). I’m not quite sure why they removed that :(.

Saturday, September 01, 2007

I love c#.. but lately.. whoa!

So lately I’ve been wanting to get into some programming on my Mac (yes I own a mac and develop .NET at work). Well I don’t really have a lot of time to devote to some new language like Objective-C. Yes I could use Java.... but I’ve really started to like c# a lot better than Java lately (maybe because it’s just what I’m used to, and I want to avoid people bashing me for taking sides :) ).
 
Anyways I’ve kept tabs on the Mono project every now and again and recently decided I’d give it a go. So I downloaded the latest (right now it’s 1.2.5) and started to tinker. I did the cheesy ‘Hello World’ console stuff just to start out. Well I’d really like to develop ‘real’ things, ‘useful’ things, but I was a little concerned about the GUI aspect (WinForms). I’d read a few places saying you need to install GTK and blah blah to get it working and that kinda turned me off of the whole thing.
 
Well I think I had been reading some slightly out-dated material. I wrote a little program to just pop-up a MessageBox and what do you know.. it worked!... and it worked on my Mac! (well you do have to run X11 first, but hey it’s a small price to pay)..
 
Then I wanted to see what new stuff was added to Mono. So I implemented a quick Lambda just for fun. Well it didn’t work right off the bat but after a couple Google searches I found the answer.
 
To use Lambdas, and some of the other c# 3.0 features, you need to use the ‘gmcs’ not the ‘mcs’ mono compiler command. (I remember reading that gmcs was newer and they plan on getting rid of mcs I think with v 2.0... don’t quote me though that’s from my wonderfully not so good memory). AND you need to provide this argument to compiler ‘-langversion:linq’. And that’s it!
 
So here’s my little program I did..
 
using System;
using System.Windows.Forms;
 
namespace Test {
   delegate string GetMessageDelegate(string name);
      public class Test {
         public static void Main(string[] args) {
            Console.WriteLine(“Hello from the console”);
            GetMessageDelegate getMsg = name => string.Format(“Hello {0}”, name);
            MessageBox.Show(getMsg(“Frank”));
      }
   }
}
 
And here’s what I did to compile and run.
 
gmcs -langversion:linq -r:System.Windows.Forms Test.cs
 
 
So basically you’ll get the message on the console and a message box that displays “Hello Frank”;
 
So I’m pretty sure I’m gonna stick with Mono/c# as my choice for development on my Mac :)

Sunday, August 19, 2007

ASP.NET color priority

This is fun :)
 
WebControl.Style[HtmlTextWriterStyle.BackgroundColor] = Color.White.Name;
OVERRIDES
WebControl.BackColor = ColorWhite;

Saturday, August 18, 2007

Setting up SVN to authenticate against a domain

At work we’ve been developing our latest and greatest project and when we first started we inherited a version control application from a previous team. It has worked okay so far, but we’ve hit the point now where we want to start doing releases for different clients keep specific features with certain versions etc. Our inherited version control software didn’t do the whole versioning thing very nicely so we began looking into different options.
 
SVN ended up being the final choice. A few reasons went into the decision factor. For one it’s free, it’s also widely used, tried and true, and it does versioning much less painfully than our current solution. One thing we wanted to get rid of was having a different set of credentials for our version control. We wanted to just use our domain authentication so we don’t have different passwords for everything. SVN makes this pretty easy to accomplish, so for this article I’m going to give some quick steps on how to achieve this.
 
First you’ll need SVN
 
Second you’ll also need to download Apache. Why do you need Apache for version control?? Well you don’t HAVE to have it, but if you want to authenticate against a domain controller then just download it :)
 
Third you’ll want to download mod_auth_sspi for domain authentication with Apache.
 
Awright now we’re ready to go. Install Apache, this is pretty straightforward, once you’ve got this installed you should be able to view the default root page from a web browser, if not check out the Apache docs :( (Apache should install without a hitch though)
 
Next copy over the files mod_authz_svn.so and mod_dav_svn.so from the bin folder of SVN into Apache’s module folder. And while were copying files we might as well copy the mod_auth_sspi.so file there as well.
 
Now lets go ahead and install subversion. This should be pretty straightforward as well. Once you’ve downloaded it just make sure to add the bin folder to the path. After you’ve done this create your initial repository using something like this
 
    svndmin create c:/some/path/your/want/to/use
 
Now open up the httpd.conf file and add these lines into the modules section
 
    LoadModule dav_module modules/mod_dav.so
    LoadModule dav_svn_module modules/mod_dav_svn.so
    LoadModule sspi_auth_module modules/mod_auth_sspi.so
    LoadModule authz_svn_module modules/mod_authz_svn.so
 
Also at the bottom somewhere add this line
 
    Include c:/some/path/to/your/repository/subversion.conf
 
Don’t worry that file doesn’t exist yet but we’ll get to that right now!
 
So in your repository path (the one we created just a bit ago) go ahead and create a text file called subversion.conf. Edit the file and add something like this.
 
<Location /some/url/for/apache/to/use/>        #make sure to add the last ‘/’ in the url
    DAV svn
    SVNParentPath c:/svn/project/path
    SVNListParentPath on  #this just allows you to view the contents from a web browser
    AuthName “put whatever you want here”
    AuthType SSPI
    SSPIOmitDomain on #allows you to not supply your domain with your user name every time
    SSPIAuthoritative On
    SSPIDomain yourDomainThatYouLogInto.com
    SSPIOfferBasic On
    Require valid-user
    AuthZSVNAccessFile “c:/the/path/to/your/repository/svnaccess.conf”
</Location>
 
You can also add support to authenticate against multiple domains, or one domain and username/password pairs in a text file etc. All you need to do is just add those after one another in the Location tag.
 
And finally edit the svnaccess.conf file for the repository we created earlier. Here is a sampler
 
[groups]
svnadmins = DOMAIN\joe.williams, Joe.Williams, joe.williams
developers = DOMAIN\bob.williams, Bob.Williams, bob.williams
 
 
[/]
@svnadmins = rw
[yourSVNProjectName:/]
@svnadmins = rw
@developers = r
[yourSVNProjectName:/trunk]
@developers = rw
 
You’ll notice we have three entries for each user. This is because different apps may use one of the three variations so to avoid some headaches just add all three for each user. You only have to do it once anyway.
 
So that’s pretty much the quick run-through for setting it up.. Below is a list of links that I found useful when setting this up :) enjoy
 
 
 

Tuesday, June 12, 2007

ASP.NET Html Encoding

So have you ever had an ASP.NET application where you placed a couple of TextBox’s on but soon realized that when you entered in something like ‘1 is < 2’ or even more blunt and to the point “<div> hello </div><script type=’text/javascript’>alert(‘something bad’)</script>” and when you performed a post back you would get a nice little error from the server? Well if you haven’t had this happen you may experience this some time in the future so hopefully you’ll remember this bit of info and you wont be left scratching you head.

So this is actually a feature. I mean if you mistakenly forgot to verify some user input you might end up with some nice html injections on your site, and no-one wants those right. So this will display an error (not just a little ‘hello here I am now you can move on’ error, but an error that you probably don’t want people seeing either). So if you want to handle on your own you can disable the error that gets displayed by adding this little bit of text to your page directive (you can also add a setting to the web.config to make a system wide change, but I don’t think it’s recommended since you may overlook a place where they’re not being handled)

ValidateRequest=”false”

Now you’ll no longer get the errors. But now what? How are you going to handle these potential pests? Another little built in feature is the HTML encode/decode functions of the HttpServerUtility class. You might quickly find out though that this is a sealed class with no available constructors so there’s no making your own instance of this class. This class is however available to your Pages through the Server object (Server.HtmlEncode / Server.HtmlDecode). So now when someone sends in ‘<div>hello’ you can handle this by passing the text into the HtmlEncode(string) method and you’ll get back the encoded text ‘&ltdiv&gthello’ and if you want to update your text-box with the newly added info you can simply make a call to HtmlDecode(string) and get back ‘<div>hello’.

Sunday, June 10, 2007

Fun data retrieval

So I have a cousin who just bought his girlfriend a laptop. Well I guess he had the laptop for a couple weeks when someone gave him a.. well... not so legal copy of Windows and told him that it had everything he needed on it (Office etc). He figured it'd be pretty simple to get it installed and everything..

I got a call from him basically saying that the laptop would no longer boot, and he had installed Windows 3 times and now he just gets a blue screen. He asked if I could take a look at it for him. Well he bought it from HP so it had an XP Home edition license sticker on the bottom so I don't ask me why he was installing this other copy of XP. I figured it'd be pretty easy. I have a little USB adapter that I can plug into laptop hard drives that have the standard pin setup. We'll he brought it over and I took the drive out and it was some other different configuration (go go standards) so my little USB conversion wouldn't work. I needed to get the data he had on there off (didn't want to loose their files etc). I coulda installed Windows on an external drive and then booted from that to get to the files on the drive, but that'd take too long. Then I remembered my good ol' days of tinker-ing with BSD's and Linux and downloaded a Linux 'Live' distro (you know.. the ones that boot completely off of a cd). I decided upon using Ubunto because it's been getting a lot of rave lately. So I popped it in, booted up, and the only thing I had to do was get Nautilus running with super user rights to access the NTFS file system. The rest was down hill. I copied everything over and formatted the drive. Then I installed his original copy of Windows using the license that was issued to the laptop and he was on his way. So the next time I need to get data off of a non-bootable computer that I can't easily just take the HD out and plug it into a functioning computer I'll remember the little trick I did this time.


Need an SSL cert to test your site?

Sometimes when you're developing a website that you know will be served on 'https' it's nice to be able to test using 'https' to make sure things work as expected. You could go the route of creating your own certificate using something like

makecert -r -pe -n "CN="%computername% -b 01/01/2000 -e 01/01/2036 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12

but then you have to deal with the pesky messages that let you know that it's NOT a valid certificate, and/or adjust your browsers settings for your site etc. There is an easier approach to this. Many certificate authorities are now offering trial certificates. All you have to do is just give them a little bit of info about yourself (I guess you could use someone elses though) and you're good to go for a period of time.

I recently received a certificate from Thawte that will last me 90 days. This is plenty long enough for dev/testing of our site on SSL and I have a valid certificate that wont cause my browser to yell at me. Thawte was just the one that I happened to go through you can also get a trial from VeriSign although the trial isn't as long.

Saturday, June 02, 2007

Source Code Formatting... ugh

So I started a new blog and do most of the work for that blog on a Mac. I mainly use windows for this blog (since I post mainly about .NET) and have been fairly happy with Windows Live Writer and a code formatting plugin. Well I was looking for a good blogging tool for my Mac to use for my new blog. I looked into Ecto, Qumana, ScribeFire and I wasn't extremely thrilled about any of them. They would screw up my formatting mainly when doing code snippets. Why does it have to be such a pain to simply just post some source code in a blog as it appears in your code editor? Well after an hour of playing around with some of the mentioned blogging tools I finally remembered "Hey you're making this harder than you need to, remember you have a Mac and things are easier". After that little thought it took me a few seconds to get some source code into nice HTML form.

First I just did a simple copy of the source code straight from Eclipse.

Then I loaded up Pages and pasted what I copied.

Then I exported it to HTML and voila! Magic!

Thursday, May 24, 2007

asp:FileUpload not posting back?

This is fun.

Didn't really find a whole lot out there on this so I figured I'd post it just in case I ever forget :)
We had a little upload pop-up in an ASP.NET application. We are just using the 'asp:FileUpload' control for this. We have another regular ASP button that has a server-side click event that will perform some validation and then save the file into a database and a few other things. Well someone reported a bug stating that if you just typed in anything (ie 'asdf') then it wouldn't let you know that it was an invalid file. No validation would be performed. We'll I started looking into this and noticed that the button click event wouldn't even post back? It would only post back if you had something that was somewhat valid entered in. (ie. 'c:\bob.txt').
Well here's the reason. This happens only when using IE. This is an IE specific issue. If you try this same thing in FireFox or Opera you'll notice that the post back will be fire off just as expected. IE trys to validate this before calling back. So if you enter something in that is just invalid IE wont even bother posting back, thus you'll never see your lovely button click event ever being called.

Don't believe me. Try it for yourself. Here's a link to a site that already has a sample 'asp:FileUpload' control loaded. Try it in IE and then in some other browser both with valid files and some junk like 'asdf'. You'll notice you only get the postback with the junk data on non-IE browsers.

Tuesday, May 22, 2007

Silverlight Airlines

I stumbled across this today and had to link it here. It's just a cool Silverlight demo application from Microsoft that shows a few of the new really cool things you can accomplish with the new Silverlight (previously WPF/E) project.

If you don't already have the Silverlight 1.1 installed you'll need it before the demo will work. You can download it here.