Thursday, June 30, 2005

Replace notepad completely...

I wonder why Microsoft doesn't choose to update some of their most frequently used programs more often.  I mean come on!  When was the last time you saw an update to Solitaire for crying out loud.  (Speaking of, there will be a new suite of card games, complete with nice gooey graphics updates, in Longhorn….)

Anyway, one of those crappy programs is notepad, which I am glad to replace with something better.

Download Notepad2, then run this guy's batch file to tell Windows to stfu and replace the notepad.exe file.

Now I get a decent editor to View Source in Internet Explorer!

Wednesday, June 29, 2005

Lessons learned -- ViewState, Server Controls, and Control lifecycle.

Note: For visitors of your site, this entry is only displayed for users with the preselected language English/English (en)

Ugh, well... I finally fixed the major issue that has held up my development for 2 days now.It really boiled down to the fact that I had properties that were persisting themselves with ViewState like this:

Which will work perfectly well as long as you don't access this property before the control's Init event... This is what I have come up with, (and someone please correct me if I am wrong) is that ViewState is really an IStateBag instance that is given to your control, which is different for each control... This helps eliminate conflicts if I add multiple controls on the same page... If I try to access the property before this instance is created (which may be when our control is added to the parent controls collection... I'm not yet sure of this) then I get a brand new string, not the one that was previously persisted... .NET doesn't give you any error or warning that this is happening, which makes it very hard to track down.

The above worked for most of my server controls, but one in particular was giving me problems. I moved the persistance code away from the property itself, which I think I like better visually anyway, and this seems to have relieved the problem.This is how you tinker with your controls viewstate:


  
private string _myName;
public string MyName
{
get { return _myName; }
set { _myName = value; }
}

protected override object SaveViewState()
{
Pair p = new Pair();
p.First = this._myName;
p.Second = base.SaveViewState();

return p;
}

protected override void LoadViewState(object savedState)
{
Pair p = savedState as Pair;
this._myName = p.First as ArrayList;
base.LoadViewState (p.Second);
}
Hopefully this might save someone a few hours of head-scratchin.... it certainly cost me a lot more than a couple headaches.
Monday, June 27, 2005

Server control Page reference

Why does the following code generate a null reference exception?

 




 

public class MyServerControl : WebControl, INamingContainer
{
private TextBox textbox1;

protected override CreateChildControls()
{
if(! Page.IsPostBack)
{
//do stuff
}
}
}


The page reference is not set. I see this sort of example all the time on the web regarding server controls. Why is it that I can not get this to work?
Thursday, June 23, 2005

My worst job ever

Leave it to Rory Blyth to stir up some well-bottled memories of my youth.

But anyway, reading that post got me thinking. I think I have 2 of the "crappiest jobs ever" ... one was a Paperboy and the other was a Popcorn wagon attendant.

I shall reminisce in the terrors that were my first 2 jobs...

When I was 12 I decided to take a job as a paperboy. My neighbor friends all had a paper route and I somtimes helped them. It was fun and easy. Until I decided to suit up. Since 3 of my friends already had routes near our houses, I had to get a route 3 miles from my house. Where my friends had 20-30 papers on their route, I had more than 60. These papers were delivered at 4:00 am on my doorstep every Wednesday and Saturday morning, and I swore I could hear the driver snicker as he dropped 2 heavy bundles of paper on my Welcome mat.

It took me nearly an hour to fold the papers and shove them in those paper carriers (I had 2 to fill -- one went on my shoulders and one on my handlebars). I finished at around 5:30 and had 2 hours to deliver the papers. I pedaled like crazy until I reach the neighborhood, which was a trailer park. If you have never graced a trailer park with your presence before, let me tell you that THEY ALL LOOK ALIKE. I was never going to memorize this route! On top of that, everybody who lived there was old and wanted their paper perfectly on their doorstep, which is right inside the carport. This meant that I had to set my bike down FOR EVERY HOUSE and walk the paper up there.

On top of all of this responsibility: I had to collect. I had to make several trips to the neighborhood to collect money: $4.00 for each house. I got to keep $1 of that. This means in a one month period I spent about 60+ hours delivering papers and trying to collect money. I made $60 for the entire month. This makes me want to cry even now. But I was a trooper and that amount in my mind equaled "one super nintendo game EVERY MONTH!"... how sad is that.




The next candidate for worst job ever was a popcorn wagon attendant for an outdoor museum in Dallas. It was called Old City Park and they had a popcorn wagon outside. It was about the size of the trunk of my Altima (read: SMALL) and I sat next to a hot-ass popcorn machine. Inside the wagon it was probably 10 degrees hotter than the Dallas summer heat outside. On a good day my wagon was only about 105 degrees F.. The saddest part of this: I got paid $4.25 / hour.

--- ahh, I feel much better now (sort of).....
Monday, June 20, 2005

Securing client-side content: Flash files

I came across this little pickle about security and flash files. Basically since Flash is a wide open standard, anyone can easily grab your swf file and decompile it. Obfuscation works a little bit here, but a determined little bastard could eventually modify your source.

Of course someone could also just run your flash movie from their own server.

I came up with this little security table for some suggested guidelines in protecting our flash component.

Flash Security
ThreatSuggested response
File could be stolen and hosted on another serverCome up with an dynamic encrypted key system-- the malicous users would have to know the scheme to get the file to unlock -- this is not 100%
File could be hotlinked from another serverflash file will only allow paths from the same domain as the swf resides... this will ensure that no one will be able to hijack our swf and load their own XML file
File could be decompiledObfuscate the code


What worries me is that none of these are 100% safeguards. They will deter the average evil-doer, but anyone smart & determined enough could get steal our file and modify it.

Does anyone have any suggestions on improving what I have above?
Friday, June 17, 2005

HDNUG

I attended my first Houston Dot Net User Group meeting last night. It was a lot larger than I originally thought. Judging by their crappy website I would have never thought that they have been around for 3 years. I estimated about 120 people attended the meeting, which they said was their largest turn-out ever.

Anyway, I enjoyed the presentation on Enterprise Library, but more enjoyed talking to my old buddy Moe Al-Kazzaz! I haven't seen him since he graduated from UH last year.

I also heard that Venkat is going to be speaking at HDNUG in August. Save me a seat for that talk!
Tuesday, June 14, 2005

DevCon 2005 afterthoughts

Man, what a day! I had a blast at this conference. I really got something from every session, which was a lot more than I was expecting... especially after reading some of Jason Olson's comments about TechEd. Anyway, I especially enjoyed the talks by Michael Stuart and Venkat Subramaniam on the new Visual Studio 2005 testing integration. My favorite features of Visual Studio 2005 are too many to list here, but mainly I think that Team Foundation Server is a huge step in the right direction. Microsoft is really paying attention to the community and providing what the developers really want/ (or already use)... but much tighter integration with the IDE. This was a recurring theme throughout the day... that you can do all of these things without leaving Visual Studio. I did think that the free books were a little lame... I mean 90% of the people that were present would not need an "Introduction to..." anything. They are obviously past that point. But I guess I shouldn't expect much for an entry price of $99. The books they handed out were:
  • Introducing Visual Basic 2005 for Developers
  • Introducing SQL 2005
  • Introducing ASP.NET 2.0
Oh well, at roughly 200 pages each it should take long to breeze through them, and I might stumble on a gem or 2 :). The ASP.NET one is written by Dino Esposito, so I will crack it open, I enjoyed his 1.1 version.
Thursday, June 09, 2005

Visual Studio DevCon 2005 - Houston

I'll be there! Look for me in the Team Systems track...
Monday, June 06, 2005

Reformats are fun -- cool utilities

Today I reformated my computer at work. It REALLY needed a fix, it was running so slow!

Anyway, I got 90% of the things I need installed in 1 day, which is pretty good. Now I'm wondering: I want to make a backup image of this install... should I use Norton Ghost or Acronis TruImage?


The first thing I like to do is customize the UI a bit... to do that I first patch uxtheme, then I download a nice visual style & background.

So far I am liking Milk, Simple Plan, and of course Water Color. I also found a good milk-look-alike called Kuantum that has extras for the Yz dock. Yz dock is a mac-cloned taskbar that auto-magnifies when your mouse rolls over it. I like this thing, and it goes great with TopDesk.

Anyway, here's a screenshot of the style in action:




YZ Dock looks like this: