November 10th, 2008 Rusty
Used to be we developers had to develop at least two sites: 1 for Mozilla and 1 for Internet Explorer. Netscape was the biggest PITA and I am happy that browser was retired. Now with Firefox, Safari and Chrome all committing to supporting W3C standards, more browsers is a very good thing. Internet Explorer has come a long way to supporting the same standards although Microsoft likes to keep their browser special.
Where is that extra margin coming from?
Sometimes, when floating an element or affecting its layout in some other seemingly unrelated way, you might introduce a little strip of space in your layout that you certainly hadn’t intended. The best way to zero in on the element that is causing the issue is to set background colors of participating elements, using css, to various random colors. This will make your elements solid so you can identify whether the space is inside the "blue" div or actually its child "red" div.
Use Internet Explorers "IE Developers Toolbar" to inspect the browser’s interpretation of your document while its running. Its similar to what you get with FireFox’s FireBug extension except that FireBug is to IE Dev TB what a heat seeking, laser guided missile is to a 5 pump pellet gun. Nonetheless, its very useful. If you aren’t using firebug with firefox yet, go get it immediately …and then come back and finish reading this post.
Using the toolbar, or background color manipulation, to find the element that has the margin or padding added, you are very close to where you need to be to fix it. Try to avoid adding negative margins to fix a problem caused by IE weirdness. Sometimes you have little else and as a last resort can get you on to more important problems.
Look Around a Bit
Once you found your offending element (or pair of elements) don’t become too sure of yourself. If the problem isn’t present in Firefox, its probably something unusual. More often than not, I find that extra margin between two elements, where margins are explicitly set to zero, can be the result of a bordering child in one of the elements setting margin and pushing the parent’s sibling away. It is NOT supposed to do that but we’re talking about some pretty complicated rendering based on competing scripted rules and behaviors and sometimes one rule causes a little hiccup. I almost always find that I can modify how I am spacing child elements so that FF and IE behave the same.
I am proud to say that I don’t believe I have any browser specific "hacks" in my css at this time. I have certainly had to make some adjustments to accommodate browser weirdnesses but these I can live with.
If you just downloaded FireBug, go mess with the Edit Html feature and the css real time modifications. Soooo cool. If you don’t have it yet, choose a career that does not involve web development. You are only causing yourself unneeded pain
Posted in Programming | No Comments »
September 14th, 2008 Rusty
On this one, I’ll be short and sweet. Read Apples memory management paper.
Objective C memory management, simplified - or - head, meet wall. repeat.
Here are the golden rules that I’ve discovered to overcome the EXC_BAD_ACCESS monster.
- When you create a pointer, its just a pointer. for example: NSString *someString; There’s nothing there yet. When you assign value, you have a pointer to some allocated memory space. This is true in all programming languages, we just tend to forget as many modern languages abstract this away from us.
- If you reference something that you received from a method, don’t release it. for example:
NSArray* resultSet = [entropyRepository queryWithClass: classType];
I didn’t allocate or create that array, its not mine to release. When my pointer goes out of scope, it will decrement the reference count. Whoever created it is ultimately responsible for its release. It may be auto-released or the creator may have a dealloc method. However, if you release it, somewhere down the line, the originator may try to access it and you’ll get "EXC_BAD_ACCESS". Unfortunately, this error will occur sometime in the future, long after you’ve made your mistake. This was happening to me when the autorelease pool was being processed and I’d already released that array when I was done with it. Ooops. There went a week of "head, meet wall. repeat".
- If you use "alloc", you need to release the referenced memory. Basically, "alloc" is, "initialize this memory space for me." If you don’t release it, it’ll just sit there, forever and ever… You can opt to use autorelease or you can explicitly send a release message.
- In addition to alloc, methods used to get a reference that "create" an object using a method whose name begins with “alloc” or “new” or contains “copy” are yours to release. This rubs me as hack-a-logical as it leaves so much up to naming conventions. But, whatever…
Posted in Programming, iPhone SDK | 1 Comment »
September 12th, 2008 Rusty
This morning I needed to copy a 300 MB file from my dev server to my local machine. I was lazy and Windows Explorer was already open. So I called up my ftp:// url and copied the file to my local folder. It showed 1 hour and some odd minutes to complete. That’s an amazing 50k per second! Wow… broadband has brought us so far.
2 hours later, the dialog stated 39 minutes remaining. Hmmm, perhaps that initial prediction was a little fuzzy. Vista must be applying some fractal logic to determine how long things should take. Then, KABOOM. "Windows was unable to copy the file"
Now I remember why I started using FileZilla and why I stopped hating ftp.
So I launched old FileZilla, connected to my same server, and copied the same file. Now I can see that it, indeed, is achieving around 40k per second. FileZilla handles communication issues much better. I failed to time it but I was able to leave the transfer window minimized and continue on with other work.
I still don’t like ftp but no-one has really come up with a great alternative. Although I am now checking out Drop Box. Looks promising…
Posted in Programming, Windows | No Comments »
September 2nd, 2008 Rusty
This is specifically for the developer who wants to get source control going quickly as well as to instruct a colleague on how to jump onto a project without excessive ceremony. I’m going to skip the part about associating the project with SVN in the first place, importing the project initially, etc. The project has to be imported into SVN before you can then check it back out and work subversively. I’ll assume you can figure out how to add a directory to Svn using the command line. The basics (and then some) are covered on Subversion with XCode on Apple.
Open XCODE and Configure SCM with Subversion
a picture says a thousand words…
Add a Repository
Click the "+" to add a repository
Give it a name so you can tell it apart from the Skynet alpha Svn repository
Configure your Svn
Click "OK"
Checkout your XCode Project Structure
Navigate to the root of the Code project and "Check Out"
Navigate to an appropriate project location on your file system.
An alert will indicate that it is complete
Choose "Open xxx.xcodeproj"
Use integrated SCM with SVN
If the project was previously associated with SCM, you can skip this step. In other words, if you cange a file and an "M" shows up next to it, you’re done.
Otherwise, Choose Project > Edit Project Settings
Near the bottom, choose your repository for SCM

Posted in Programming, iPhone | No Comments »
July 12th, 2008 Rusty
I tend to be a creature of habit. For example, I LOVE the Coby hamburger at Food 101 in The Virginia Highlands (1397 North Highland Ave, Atlanta, GA 30306). Whenever I eat there, I get the hamburger. They have awesome crab cakes and just about everything is fantastic but I always get the burger.
I do the same thing with other aspects of my life. Every now and then, however, I discover something that makes me regretful that I hadn’t tried it earlier (more on that later). I use Windows LiveWriter to blog. Its awesome, really. However, I have to fire it up. If my VMWare Vista isn’t running, I have to launch that. If it was suspended, that takes a minute.
I’m writing this post using ScribeFire. ScribeFire is a FireFox extension that is tightly integrated into your active browser window. You get alot of context at your fingertips that will save time when creating links to resources outside your blob (or even in your blog). It appears to have social bookmarks built in as well. I also added the del.icio.us bookmark add-in from Yahoo because it looks pretty feature-rich. Navigating to Del.icio.us turns out to be the barricade between me and my social network savvy self. With all the machine refreshes I’ve had lately, and the sheer number of computers I use every day, I am sharply beginning to realize the value of centralized, shared bookmarks.
While I still expect to use Windows LiveWriter to blog in general, providing quick access and integration with browsing is a crucial efficiency enhacement that I wish Safari had. I’ve been a Safari fan for a while now but I may start using FireFox on my mac now that FireBug is compatible with FF 3.0.
I couldn’t program as efficiently as I do without FireBug. Period. I expect my blogging will increase due to ScribeFire. While I sometimes get too busy to see what tools are emerging, failing to do so costs me and everyone around me time and money. Being diligent in purposefully discovering new options for old behaviors is a very valuable exercise. For example, I found that adding Food 101 Truffled Honey Mustard to their Coby burger is terminally delicious.
Posted in Blogging, Programming | No Comments »
July 8th, 2008 Rusty
Usually its IE, these days, that consumes my spirit as I try to make pixels submit to my command. Back in the Netscape days (thank goodness that browser is long gone), IE seamed like it could do no wrong because Netscape was such an example of code gone wrong. Now Firefox gets the same holier than thou reputation.
I’m creating a range bar chart in html. Why Html? Well, because we already purchased Dundas. SInce it cost as much as a full MSDN license, we aren’t at liberty to try competitive tools. Not to slander too hard but D is such a pain in the ass that I’d rather draw raw html than attempt a chart in that throw-back to Netscape quality and expected behavior. Note to tools vendors and their developers and project / product managers. Usability testing is your friend. Just because the developer who wrote the code can make it render a really nifty chart does not mean your product is meeting the needs of the public. You have to bring in real users to see what comes when they try to implement the feature… (if only I always took my own advice)
A range bar chart is just boxes so why not draw with html?
The problem
Notice the second bar. Isn’t 9.3 less than 10? Hmmm… Inspecting the html in Firebug reveals that the percentages are correct. No matter what I do, the larger bar stretches just a hair further than it should and winds up below the bar low to its right. If I reduce the range, things clean up.
FireBug also revealed that setting the font-size to a very small number inside the font-less tables fixes this weird issue.
TABLE.barchart{
height:100px;
width:100%;
border-collapse: collapse;
table-layout:fixed;
font-size:1px; /*setting this fixed incorrect bar height in ff*/
}
![CropperCapture[6]](http://www.vitaminzproductions.com/technology-blog/wp-content/uploads/2008/07/croppercapture6-thumb.jpg)
Oooooo, thas mo’ bettah!
Don’t look a gift horse in the teeth
I have no idea why that makes any difference. Perhaps someone has an idea? I really don’t care! It worked. I can move on. I don’t necessarily like having css in my stylesheet that is noting but a hack but there are certainly a few "IE Hack"(s) so why not stuff in one "FF Hack" ?
Posted in Programming | No Comments »
June 19th, 2008 Rusty
I was asked yesterday whether my new site, beta.ockhamresearch.com, was developed using Ruby on Rails. In a very indirect way, sort of. Ok, no, not at all! Its Asp.Net MVC.
Mvc stands for Model View Controller, a popular design pattern for modern website architecture. I feel it is significantly more productive and effective than the page-centric architecture you find as the default in most web programming languages. Ruby’s first popular website platform was Ruby on Rails. There were other MVC implementations out there already for platforms such as Java and Smalltalk. However, Rails maid it intuitive, productive and even fun. This led other programmers to favor the pattern for developing websites (such as myself) and led to the development of Castle Monorail in dot net and other variants as well as on other platforms. Many of these were ports of Rails for folks who weren’t able to use Ruby as their target language for one reason or another. I had been using Monorail for some time when Microsoft announced the development of Asp.Net MVC. Microsoft isn’t well-known for open development initiatives and often does things the Microsoft way rather than the conventional way. The Microsoft Asp.Net team deserves much credit for the current quality of Asp.Net MVC and the integration of tremendous community feedback.
Why not just use Rails?
Competency
I have very little experience with Ruby. When I need to write some Ruby code, I need to look up each construct and find examples to work from. I can code C# in the woods on the trunk of a tree. Of course, compiling it would be a challenge.
Confidence
I know where Asp.Net and SQL Server limitations are and that the platform can achieve high performance. I know that Ruby has known performance issues and no roadmap for reconciling these issues. I’d rather not be the person responsible for overcoming performance issues on a production web server farm when we have paying clients expecting service. If I can run a commercially supported platform with current licenses and support contracts, I have someone to lean on if anything goes wrong. Furthermore, I can fix almost anything on Windows but my experience with Linux is feeble. I aim to change that but, for now, I can provide confidence to my constituents that my web app will not fail due to memory leaks or unusual bugs that are not a result of my code. Yes, there will definitely be errors in our future but using NUnit, Cruisecontrol.Net, WatiN, Visual Studio.Net and SQL Server will minimize the risk to a more than acceptable level. I don’t know where to turn for the same thing in Rails.
Community
This is the most important factor. The above two points are true for all the programmers I’ve worked with over more than the last decade. We’re all very familiar and invested in Microsoft technologies. There is no reason to switch if the features are available and productivity is commensurate with alternatives. If I need help modifying some code because I have too much to do myself or we have an awesome contract pending, I don’t want to be searching in a small pond for good people. For every good programmer, there are a hundred terrible ones that will make a mess of my beautiful code :) I can’t have that.
Why Use Rails at All?
I can’t find current data that indicates the trend for what programmers are using but I can tell you my gut feelings and personal observations. No community growth, in my technology career, has struck me with as much fervor and excitement as the Ruby and Rails explosion has. These people aren’t Windows haters like Java programmers were. They aren’t choosing Ruby because that’s where the jobs are (yet). They are choosing Ruby because they get hooked! They love working with it. More often than not, a Ruby programmer dresses hip, is very laid back, uses a Mac, drives a Hybrid. These are all traits of people with both time and money. I want more time and money and would like to be hip. However, I still prefer to burn more gas in exchange for fast times to sixty. Glutinous, I know.
When do you switch?
Rails still needs to be proven in the enterprise. My prediction is that this will happen in 2008. Sites using Ruby on Rails will publish numbers and costs of operation that make it a very attractive alternative to the company standard. The best place to try Ruby is on a new, small scoped project with just a few very close end users in a highly agile environment. Don’t be silly and just announce that you are now Ruby and expect all your devs to just pick it up. On the other hand, it would be a good idea to get some very intense training for your old school programmers (if you have them) because they are accustomed to working within the constraints of their strongly typed, compiled, high performance environment and will not naturally make the appropriate transitions necessary to achieve success, maintainability and scalability in a Rails environment. Ask yourself if your compiled apps (yes, Asp.Net is compiled) are as fast as they should be and then ask yourself whether your app will still be acceptable at 50% of that speed. On the other hand, if you have 80% of your hardware capacity remaining, you can probably virtualize and take advantage of your current infrastructure with very little cost.
Try it on like deodorant. Give it a few days and try a few different activities and then ask your wife if your pits stink. If not, take it a little further.
Posted in Asp.Net, Mvc, Programming, Rails, Windows | No Comments »
June 4th, 2008 Rusty
I ran across a strange bug today. Fortunately, Bill saw it first and lead me straight to it. I banged my head against it (unsuccessfully), trying to diagnose the cause of a System.Web.HttpException with no message being thrown from SiteNavNode.ChildNodes until my battery died on my laptop and then came into the office to continue. Good thing!
In the Financial Services industry, there is a company with the symbol PRN. I, of course, use directory urls to organize our dynamic website. PRN is a reserved word for urls because it is a reserved file system word. In my opinion, modern OS’s should not have this limitation, but I don’t know enough about it to suggest that it isn’t necessary.
If you attempt to create a file, with any extension, using the following list, it will fail to resolve in a browser.
|
Reserved Word
|
What it is
|
| AUX |
Auxiliary port aka Serial Port COM1 |
| CON |
Short for console, which Microsoft describes as the display monitor. |
| COM1 |
COM port. |
| COM2 |
COM port. |
| COM3 |
COM port. |
| COM4 |
COM port. |
| LPT1 |
LPT port. |
| LPT2 |
LPT port. |
| LPT3 |
LPT port. |
| NUL |
NULL |
| PRN |
Printer aka LPT1 |
|
|
This is also true of rewritten urls. I defensively have incorporated a lovely "~" into any url that attempts to name the path segment using one of these reserved words.
Posted in Asp.Net, Programming, Windows | No Comments »
June 3rd, 2008 Rusty
Sending notification emails from an app is a pretty straight forward thing. I can’t think of an server app that I’ve used or written where this wasn’t a requirement. A good designer will abstract the details of sending email into a notifications object model where smtp is one provider of delivery services. However, you still have to set up an email server. You will also bump against a third party product that needs smtp to function. We use Google Apps for email. By doing so we have no need for email administration. Google handles that for us. Perhaps they’ll appreciate our patronage when they take over the world. Who knows?
But I stil need a dang smtp server. Widows Server 2003 comes with IIS 6.0, which comes with a free smtp server. GREAT! There’s a pop server, too, but that’s outta scope.
Enable SMTP
Install SMTP. That link should have you running smtp services. Pretty simple, so far.
Configure Access
I’m only including the relevant screens to get it going. By no means is this an Enterprise Solution but it will get you sending email.
Open IIS Admin. Right click on the SMTP Virtual Server. Choose "Properties"
Click on the Access tab.
Click on Relay.
This is the part that messed with me all day. I was getting "Cannot Relay" errors trying to send. When I Enabled "All Except the list below", with no exceptions listed, email went out. So I played around until I got to this config.
YMMV
The first listed setting is the following:
I’m a little rusty on my subnetting (pun intended) but that should allow all local network connections to relay through this server. All I knows is that it done did worked right.
Ports and such
I experimented quite a bit with ports, only to find that changing the outgoing connection port makes it impossible to connect to real smtp server. So leave it all default unless you know what the hell you are doing.
Note: I read that leaving "Anonymous Access" enabled without some sort of authentication option means that the server never authenticates but treats all connections as autheticated. Therefore, uncheck that box on Relay Restrctions to "Allow computers which successfully authenticate to relay…" Unless you would like to see how long it takes spammers to discover your open server
Posted in Programming, Windows | No Comments »
May 16th, 2008 Rusty
I really didn’t find anyone else reporting this issue. I created a custom SiteMapProvider and it magically provided a breadcrumb for me. Sweet! Then I was demo’ing and no breadcrumb…
I discovered that deleting the trailing slash brought the breadcrumb back.
I may have added my SiteMapNode urls incompatibly with the SiteMapProvider expectations. But my urls are perfectly valid and "/my-specialurl" is the same as "/my-special-url/". In my code, I’m stripping trailing slashes before comparison. Shouldn’t the SiteMapProvider do the same? Who knows?
Code change was easy:
(note: I edited this from the original post as I discovered that I overrode the less ideal signiture of this method, this covers both )
public override SiteMapNode FindSiteMapNode(string rawUrl)
{
// base method doesn’t handle trailing slash very well
SiteMapNode match = base.FindSiteMapNode( rawUrl );
// base method worked!
if( match != null ) return match;
// try without trailing slash
if( rawUrl.EndsWith( "/" ) ) match = base.FindSiteMapNode( rawUrl.Substring( 0, rawUrl.Length - 1 ) );
return match;
}
Posted in Asp.Net, Programming | No Comments »