Tuesday, October 20, 2009

Take Control of Your Soundscape

This is a quick, informative talk on the influence the sounds around us have on our feelings and behaviors; check it out. It's a good thing I work in a "Library" like atmosphere...

Thursday, September 10, 2009

Web Service Not Reading the Lmhost File?


I recently spent 1/2 of my work days trying to figure out a problem reported to me by a client. I am working on a three tiered application that has a windows forms application that communicates to a web service. The web service performs all the communication with the database which is located on a different server from the web service.

I was told that they could not longer upload or download data to or from the windows forms application. They also mentioned that they installed a firewall. .Net remoting can use tcp or http as the protocol and either of those can use soap and/or binary encoding. I read that firewalls block binary transfers of data... uh... not really. So with a grain of salt I began going down that path. I determined that the web.config file for the web service is where the encoding type is set (in the remoting section). I happened to have http with soap and binary. I commented out the binary line, and ran the program. BOOM! I got an error regarding incorrect binary string. So without changing the program quite a bit I cannot have the soap protocol only.

Well, it turns out that it had nothing to do with the binary format of the stream. The client's web server was not translating the server name they entered to the correct IP address of the database... So they entered the IP address of the database server. fixed. firewall still enabled.

What did I learn? There's a lot of garbage assumptions out there in Google space... So apparently in their setup, the web server was not reading and translating the server name from the lmhosts file. I wonder if Microsoft has any detail on that?

Wednesday, April 22, 2009

Internet Explorer 7, Print Preview Page Generator


I found a bug (or at least what I think is a bug in Internet Explorer 7.  Here’s the scoop: when you print preview a page in IE7, you get a nice little popup of the page(s) and how it will print.  Great.  Well depending on how the page is created, it might not work.  Down at the bottom of the preview it gives you a “Page 1 of X” (where X is the total number of pages).  As you can see from the image, the number of pages is 2076, but what you cannot see is that it is still increasing…  doh! 

Under certain circumstances you can make the function that calculates the total number of pages to print to “freak out” or rather infinitely loop, thus never displaying the actual preview of the page.  This is only an issue in IE7.  The same test works fine in Firefox 2.0.0.6.  I have not yet tested it in any other browser or version of a browser.

 

I have not completely narrowed down the issue yet either.  But I have found that if you use DIV tags and a CSS style sheets to layout your pages, you may come across this issue.  Some facts: this page is built dynamically.  My div tags are all fixed width.  There are nested div elements up to 3 or 4 levels, and there are label elements with empty “for” attributes.  All the layout is done using the style sheet and div attributes.  The interesting thing is that this issue only happens on pages that are longer than about 2 print preview pages; which means that it seems to either be the data in the elements, or the number of elements on the page. 

 

First, I made sure that all my tags had appropriate closing tags and formatting (text case and all that).  I threw it into Visual Studio 8 and formatted and validated the text.  Same issue.  Next, I started from the bottom of the page and started commenting out the div blocks one by one and testing the print preview after each.  After commenting out two of them, the issue went away and the print preview displayed fine.  So I thought there must be something wrong with one of these divs.  Turns out that there is nothing wrong with them.  I found that I could uncomment those divs and comment out the first few divs and the problem would also be resolved.  So then I uncommented all the divs again (essentially restoring the problem), and removed the CSS stylesheet reference.  Again the problem went away.

 

Okay, now this is messin’ with my brain…. 

 

So ultimately, I submitted the issue to Microsoft.  Right now, this currently looks like a bug.  I found the following article on MSDN: http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/5defae18-1e29-4f75-a47c-670c82ab15de and submitted my issue there.  The original issue was reported in 2008, so I’m not sure if anyone is still tracking the problems.  If you have any solutions to this issue please post your comments here.  I still need to resolve this issue.  Thanks!


The problem is resolved in the latest version of Internet Explorer 8.

Wednesday, April 1, 2009

How to Speed Up Finding an Element in a System.Collection.IList

I've been working on a program for some time now that I inherited. It's a great program, most of the code is designed well, but some of the implementations of the design have been less than desirable, especially when you are talking about speed. Let me explain:

I've recently found a bottleneck in some of the code I've been optimizing. For instance, I have a System.Collection.IList that is basically given to me to use (since it has been implemented using a third party tool, the trade-off for removing it was not an option). I don't recall what the IList was implemented as, but the IList does not allow me to call a List.Contains(object value), or List.IndexOf(object value). If it did, I would not be in the situation I am. The bottom line is that I needed to have an implementation of the .Contains() and .IndexOf() methods. So here's how it was implemented:

public bool Contains(Guid _reviewAnswerId)
{
int listCount = myList.Count;
for (int i = 0; i < listCount; i++)
{
if (myList[i].ReviewAnswerId.Equals(_reviewAnswerId))
return true
}
return false;
}


public int IndexOf(Guid _reviewAnswerId)
{
int listCount = myList.Count;
for (int i = 0; i < listCount; i++)
{
if (myList[i].ReviewAnswerId.Equals(_reviewAnswerId))
return i;
}
return -1;
}


As you can see from the code above, the way you find a match is to loop through each object (I could have used a foreach statement, but I was trying to optimize and a for loop helped slightly) and match the value. If a match is found then "true" is returned and if not then "false" is returned for the Contains() method. For the IndexOf() method, you are looking for the index where the object resides in the IList, so you can reference it in some other place of the code.

So this is all fine and dandy if your collection is garanteed to stay small (which was the intention of the collection at design time). This method of search is a linear search, O(n). But you'll see that its actually O(n^3). Since then, the design has been extended to allow the collection to contain upwards of 5000 objects (which really is not that many, so I thought). It turns out, that these objects have multiple data elements, and everytime the object was referenced it would take a very long time to check (I found it by pausing the debugger when the program was halted for the time it was performing this routine). This looping and checking would not be performed once, but between 2000 to 4000 times, and that would be performed 400 to 800 times, so the number of times the list is accessed would be more like 800 * 4000 * 5000 = 16,000,000,000 billion times. OUCH!

So there are a few things that I did to fix the search time. First of all, where I could, I pulled all the direct calls to the object ("List[i]") into a local variable to reduce the overhead of those calls (though this did not do much). Second, I implemented a System.Collections.Hashtable that was pretty much a clone of the IList (a clone of the objects and the number of objects, not the order they are stored). Hashtables are typically O(1). Which means that you'll find you value a heck of a lot faster than a linear search. So each time I add an object to the IList, I add the same object to the Hashtable, and the same goes for removing objects. I then changed the Contains() method to the following:

public bool Contains(Guid _reviewAnswerId)
{
return _hashTable.ContainsKey(_reviewAnswerId);
}


The IndexOf() method then goes away, since you can then reference the object in the following manner:

return (CastToMyObject)(_hashTable[_reviewAnswerId]);

BINGO! Problem solved.

Saturday, March 21, 2009

Don't DIY Starter Removal Instructions 97 MAZDA MPV 4WD

I'll make this short and sweet. Last Sunday, my wife got in our 1997 Mazda MPV after church and tried to start it. Nothing. Turns out that the starter was on a bad spot and would not crank. Ratz! Since I could not find out where the starter was at the time, I had it towed to my house. I validated that it was indeed the starter. I remove the front plastic dirt guard and found the starter. It's not in a very nice place. I took my long mag light and banged on it a few times, then it cranked over. Yep it was the starter.

Yesterday, I finally purchased a new starter (first mistake). I then went out to pull out the old starter. After removing the metal plate that protects the front differential, I could see the starter bolts. It looked a little tight.


After taking off the front differntial drive shaft, I attempted to remove the 3 bolts that hold the starter on. After some strenuous efort I got the lower bolt off.

However, the scond bolt proved to be so stubborn I decided to take another approach. There is a large cable assembly the runs right in front of the second bolt and so I used a angle bracket on my wratchet to get at it better (second mistake). Well, I did not have enough pressure on the wrench and so I stripped the bolt (slightly). After fretting a bit and looking at it for a while, I realized that even if I got the bolts off, there was no way I could pull out the starter. There are two obstacles, the front differential and the engine heat shield that covers the starter. I have no way of removing the front differential (3 strikes and I'm out). So, I'll be taking it to a pro. This is the first time I've been beaten. Yes I'm very depressed. I wish I had a car lift... I could do it all then.

Lessons learned:
1) Buy a manual first. You'll learn what the real dissassembly instructions are and there by know what you'll get into before you actually get into it.

2) Don't buy the new starter, until you get the old one out. Now I have to take the new starter to the mechanic and then get the core from them to get my core rebate... more work.

Monday, June 9, 2008

When In Mexico, Do The Truffel Shuffle...

Mexico can be a great place, only if you know the rules... You guessed it, this last week my family and I took a road trip with some friends across the border to the land of PEMEX gasoline and where everything seems to be "almost free for you, amigo!" Puerto Penasco (a.k.a. Rocky Point) has some great attractions as well as some that are no-so-great (and painful might I add).

I had been there before a few times (not Rocky Point, but near enough), however, my wife had never been. It was exciting for both of us and our little ones. It started out amazingly wonderful. A storm has just rolled through the weekend before and the air was cool and delightful. The beach, ohhhhhh the BEACH! It was delectable; such a lovely place to lounge around in my bathing suit and sun tan lotion all day long. We built a massive sand castle, of which I will happily take credit for the design and architecture (I cannot take credit for the killer drip castle trimmings done by the one and only KaseyMage). It took a few hours to finish it. But alas, it turned out great. The water filled it's mote properly then slowly the water ate it away, so did the kids...

Day 3, was quite the adventure, however. Up until this point one of the guys we were with kept telling us that he did all this reading about stingrays and to "shuffle your feet in the water" to scare the stingrays away. None of us believed him... Then the inevitable happened. I got stung by a stingray! Imagine someone taking a dull barbeque skewer and jamming it into your foot and leaving it there for a while. That's what a stingray feels like. I thought I was in big trouble since we weren't sure if the stinger was still in there or not. So, we headed down to the local Red Cross. It was great. They cleaned me up, gave me a shot of some pain killer, and sent me on my way for $30. I'd say that's one of the best medical deals I've had in a long time. That's right...NO DEDUCTABLE, NO QUESTIONS. haha. They told me to put it in the hottest water I can stand and then take pain killers every eight hours. And as I walked out the nurse said, don't forget to "shuffle your feet in the water". Haha. We were all shuffling our feet in the water...

I really thought this part of the trip was great. It's not very often you get in a tight pince in a country you're unfamilar with. So the rest of the trip was smooth. We all had a seriously good time the rest of the week. So if you have that urge to cross the boarder and take a dip in the salty seas of Puerto Penasco don't forget to do the Truffel Shuffle.

Wednesday, June 4, 2008

Tub and General Fiberglass Repair - HowTo

This is a great article for those who are needing tub or other fiberglass repair. I'm sure at some point in my life, I'll be performing this...


How to Repair a Fiberglass Tub or Shower


from wikiHow - The How to Manual That You Can Edit

Fiberglass showers and bathtubs are durable, easily maintained, and attractive fixtures, but they may still be accidentally damaged. Fortunately for homeowners, there are inexpensive kits available that can be used to make repairs if this happens.

Steps


  1. Purchase a suitable kit for your shower (or bath tub). You should make sure your shower or bath tub is fiberglass before going shopping, as these instructions will not give good results on cast iron or other types of fixtures.
    • Make sure your shower is fiberglass by tapping it with your knuckle or a wooden spoon or similar item which will not damage the finish. A fiberglass unit will have a soft, hollow, non-metallic sound, and depending on where you tap it, may even seem flexible.
    • Choose the appropriate color for the kit you will purchase. Most kits come with colorants (tinting products) to change the color of the product to match common colored fixtures, such as white, off white, or almond.
    • Make sure the kit you buy comes complete with everything you need, or purchase these materials and tools seperately. The following is a list of what your kit may contain:
      • Polyesther resin
      • Hardener (catalyst to harden the resin)
      • Fiberglass mesh or mat (for large or structural repairs)
      • Colorants
      • Sandpaper in assorted grits, from 80 grit (coarse) to 400 or 440 grit (very fine)
      • Thickener (to stiffen the resin for vertical applications)
      • Protective gloves resistant to the chemicals included in the kit
      • A mixing container and stirring tool


  2. Clean the area to be repaired. Cut any jagged or protruding glass fibers around the damaged area, sand it lightly with a medium grit sandpaper to remove wax, oil, soap scum, or other surface contaminants, and rinse with acetone or another solvent to assure proper adhesion of the repair product.
  3. Determine if the damaged area will require fiberglass cloth reinforcing. If it does not, skip to the step describing mixing and tinting instructions. If the crack is over one fourth of an inch (1/2 cm) wide, or is actually an open hole that the resin mixture will not fill alone, cut a piece of fiberglass mesh or cloth slightly larger than the hole. For large holes or cracks, more than one layer of cloth may be needed to get good results.
  4. Read the mixing and tinting instructions of the product you have purchased. Since individual products may vary, and measuring the materials you mix is essential, make sure you understand these instructions before proceeding.
  5. Place a protective material like cardboard or heavy construction paper on the surface you will mix the material on. Place the container you will mix in (usually supplied in the kit you purchased) on this surface.
  6. Measure the amount of polyesther resin into the mixing container you think you will need for your repair. Most kits have mixing proportions for fractional portions of the resin provided, such as 1/4th of the volume, 1/2, etc., mixed with an equal proportion of hardener.
  7. Add the colorant from the correct tube that came with the kit. An example would be for almond, mix 5 parts white with 1 part brown, to 20 parts of resin. For basic white, use the white colorant added until the resin is thoroughly opaque. Mix these components thoroughly, and check the color against the fixture you are repairing before adding the hardener.
  8. Mix thickening material into the resin/colorant mixture until it is a desired consistency for your patch. Vertical surfaces need to be very stiff so the product does not sag, drip, or run. For horizontal repairs the material can be thinner, but it still should be stiff enough that it can be tooled smooth with the applicator.
  9. Add the hardener according to the kit's instructions. If you cannot find a workable proportion, you may have to make an educated guess as to how much you will need. Generally speaking, too much hardener will only accelerate the process, allowing less working time, and too little will delay the setting time. If you fail to add enough hardener to set the resin, however, it will remain tacky indefinitely. For a ball-park estimate, add 5 drops of hardener to each tablespoon of resin/colorant mixture.
  10. Mix the repair material thoroughly. The longer you stir the material, the better the results will be, making sure that all of edges and corners are incorporated so that it hardens equally. Remember, though, that once you add the hardener, the reaction that solidifies the resin will begin, so you can only expect 10 to 15 minutes total working time before the resin becomes unusable.
  11. Using a flat tool like a putty knife or wooden tongue depressor, scoop out some of the mixture and apply it to the damaged area. If you are using fiberglass cloth for your repair, place the piece you have cut over the damage, and press it into the resin repair mixture. Make sure you spread it evenly, and to a level slightly higher than the original surface so it can be sanded down and feathered smooth when you finish. Once the repair material is applied, allow it to harden, typically about 2 hours at room temperature.
  12. Sand the patch carefully, trying not to scuff the adjacent areas. If you used fiberglass cloth, you may need to trim any fibers that are protruding with a sharp utility knife before sanding. Begin with a fairly coarse grit of sand paper, depending on how much of the patch has to be removed to make it flush with the original surface. Work your way from a coarse or medium grit to a fine, then very fine grit sandpaper, until the repair is smooth. If you need to build up the repair further, mix another application and apply it to the damaged area, then repeat the sanding.
  13. Mix another batch of resin and colorant to overlay the first patch, without the thickening agent. You can apply this with a small artist's paintbrush, or if it is a small chip or ding, even a cotton swab will do. Smooth this application as much as possible, allow it to harden, then sand it with very fine sandpaper.
  14. Buff the finished repair with the buffing compound provided in the kit to restore the gloss finish so it matches the original.
  15. Clean up the area, and admire your handiwork.


Tips


  • Large cracks or holes will require using fiberglass reinforcing mesh or cloth, which will usually come with the kit you purchase. This may make the repair a little more difficult, and you may even want to seek help from someone who has experience using it.
  • For large holes in the floor of a tub or shower unit, use an expanding foam product to fill the cavity below the floor. This will help support the floor, preventing future cracks. Use the product according to the directions on the can, and trim or sand off any excess foam that is protruding about the finished surface.
  • A power rotary tool equipped with a buffing pad will save a lot of time and effort when buffing out the finished repair.
  • Polyesther resin products are temperature sensitive, so providing a heat source will accelerate the hardening. On the other hand, if you are concerned about having time to complete the repair before the resin solidifies, you can cool it before mixing to extend its working life.
  • Use disposable tools and mixing containers if possible. Cleaning polyesther resin requires a strong solvent like acetone, and must be done immediately after use, so usually it is not practical to do so.
  • For very large repairs, a power sander may make the process much easier.


Warnings


  • Use rubber or plastic gloves (usually provided with the kit) when using cleaning solvents and mixing the polyesther resin.
  • Make sure you have plenty of ventilation while doing this repair.
  • Acetone or other solvents are highly combustible, so be sure there are no ignition sources like water heater pilot lights in the immediate area prior to beginning the repair.
  • Avoid using styrofoam cups or containers for mixing your materials. Acetone and related solvents will dissolve styrofoam and spill the solvents or resins onto your bathroom fixtures and floor.


Things You'll Need


  • Fiberglass tub/shower repair kit described above
  • Cleaning solvent, such as acetone
  • Rubber or plastic gloves


Related wikiHows





Article provided by wikiHow, a collaborative writing project to build the world's largest, highest quality how-to manual. Please edit this article and find author credits at the original wikiHow article on How to Repair a Fiberglass Tub or Shower. All content on wikiHow can be shared under a Creative Commons license.