ForrestLedbetter.com Rotating Header Image

Geek Stuff

Theres no place like 127.0.0.1

Quick Reference Bash

Quick Reference Bash

Heres a handy little list of common bash commands. It is by no means exhaustive, but it is a good link to have if you are new to finding your way around the linux command line.

Still liking Fedora

Its been over a week now, and I can’t say I have missed windows at all. I started out with gnome as it installs by default, even though I’ve always preferred KDE. After a few days, I installed KDE too. I remembered instantly why I like it so much.

KDE just seems so much more “grown up” to me. Administration is a snap, and everything is right there ready to go. I also prefer a single panel, as opposed to the top and bottom panels of gnome.

I’ve tried Looking Glass, a java windows manager, but its still a bit sluggish for my taste. I have a decent machine, plenty of horsepower, but lg3d was still a little slow. Next up, I plan to give Beryl a shot. The features list is sick.

Fedora

I ran into some issues with Windows Firewall (which I disabled) last night, so I trashed windows and installed Fedora Core 6. It took about an hour to get the whole thing installed (including openoffice and more development tools than I know how to use). About 15 minutes later, my browser was good to go with all the needed media plugins, and I’m back up and running.

I’ll still be using win for development at work, unless I end up taking the Java route. If that happens, I’ll request a nix rig or maybe a mac for development. Of course, streaming content to my xbox and most pc games will require a windows installation, but I can just use virtual machines for that.

Last night, I had about enough of my pc telling me what I HAD to have installed and running. Now, I’ll be the one telling my pc what it has to have…even if that means a week of downtime here and there while I figure out what the hell I did to fry my linux installation.

Schedule large web downloads

Over the years, I have ripped a bunch of cds to mp3. I wanted to take them to work so I could listen there, but my work pc does not have a dvd drive, and wasting cd’s for a few albums didn’t seem like the way to go. So…what to do?

Well, I decided to zip them up, dump them on my web space, and download from work. Considering the network is full of data that is actually important to the company during the work day, downloading during work hours was not prudent. Plus, bandwidth throttling at work caused a single album download to take over an hour.

Of course, the best idea would have been to use my thumb drive, but a) its only 256mb, and b) I can’t find the damn thing. So, I installed wget for windows* on my work pc, wrote a batch file for each file I wanted to download, and set them to run as scheduled tasks starting at 3am. (If I had a linux box at work, I could have just made a cron job and been done with it.) Now, I am no longer concerned with slow download speeds or clogging the network and impeding the transport of important data.

*Wget for windows is a port of a linux command by the same name. W(eb)get does just that: it gets any web accessible file from the command line, making it perfect for batching. It allows for http username/passwords, so you can password protect your directories and still schedule downloads to run whenever you want.

VB.Net and C# Comparison

Side by side comparison of VB.Net and C# syntax. This was very useful for me when starting out in C# since I already had VB.Net experience.

Javascript libraries roundup

Here is a great post containing a list of several javascript libraries. These are great for speeding up web development. Form field validation, ajax, visual effects… each implemented with usually one line of code.

Pixel2life Free Tutorial Search Engine

Pixel2life is an awesome source of tech tutorials including graphic design, coding, 3D animation, photoshop, and on and on. There are tons of things to learn there.

Modal Dialog Forms

Personally, I don’t like using Modal Dialogs because they are IE only – BUT some times thats what the client wants, so thats what they get. One of the biggest annoyances when using Modal Dialogs is the little quirk of opening a new window when trying to submit a form located within the dialog. The solution is easy enough, it just took a while for me to find so I thought I would post it here:

Code:
<head>
  <base target="_self" />
</head>

Thats it. I don’t recall where I found this exactly, but it was on some message board after scouring Google search results for quite some time.

So, how do you tell whether to use modals or pops? Thats a pretty easy one too, but its a pain because of all the extra coding required:

Code:
var oInput = new Object();
var oReturn = new Object();
if(!window.showModalDialog)
{
  //code for browsers not supporting modal dialogs goes here
  //
  window.open("testpop.htm","testpop","height:570px;width:700px;help:no;scroll:yes;"")
}
else
{
  //code for browsers supporting modals goes here
  oReturn = showModalDialog("testpop.htm", oInput, "dialogHeight:570px;dialogWidth:700px;center:yes;help:no;scroll:yes;");
  tstFormElement.value = oReturn.value;
}

This is more robust than checking whether the incoming browser is IE or not, because who knows when or if the other browsers will integrate modal dialogs? Of course, this just handles opening the window. If you want to manipulate any data on the page opening the dialog/pop, you have to place a similar block in the opened page because the opener is referenced differently. Wait…what?

Code:
if(!window.showModalDialog)
{
  //code for browsers not supporting modal dialogs goes here
  opener.document.getElementById('elementID').value = "test value";
}
else
{
  //code for browsers supporting modals goes here
  var oReturn = new Object();
  oReturn.value = "test value"
  //place code to change values when this object is returned
}

So the last (?) hurdle here, is making your faux modal window act like a modal dialog, which is to say, it retains focus and does not allow the user to return to the calling window. I wrote a basic script – placed in the opening window – checking whether the opened window was still open or not. If it was still open, the opener returned focus to the dialog. This worked nicely at first, but when I started hammering away at it I could get it to fail. If anyone has a better suggestion, please let me know – just don’t bring up Mozilla’s modal=true bs, because its crap and it doesn’t work – at least not for me. And even if it does, its only for Mozilla.

There are probably other techniques for this, but these work adequately for me when I am forced to take this route.

Modal Dialogs are bad. If you feel you have no other choice, take a step back and find another way. It will save you blood, sweat, and tears.

Notepad++

Notepad++ is an awesome text editor. Its a great replacement for classic notepad. My two favorite features are visible line numbers and tab visualization. If you do any kind of coding and need a quick, lightweight text editor for those tasks too small to bring into a full service IDE, this is perfect.

Name Mangling, Solution 3

UPDATE:
Master pages are quite useful. Use them when applicable, but pay careful attention when you have thousands of lines of legacy javascript. I will leave the original post as is…this is a learning experience for me as well. Note my frustration below:
/UPDATE
UPDATE 2:
Paragraph 2 doesn’t make any sense to people that were not working on that project. I should have made this much more generic
/UPDATE 2

My suggestion: don’t use Master Pages. That is, until MS releases a tool to retrofit your existing javascripts or prevent master pages from name mangling. From what I hear, it is hell on CSS as well, but I haven’t run into that yet.

Instead, I just created 2 user controls, one containing the head of my layout, and one containing the footer. Simple enough for me, and I don’t have to waste time figuring out why my scripts don’t work. If that’s not good enough for you, you’ll need to make use of the .clientID property in your code behind pages – it just was not a viable option in my particular case.