Wednesday, March 4, 2020

Deep Cloning

Had to debug an issue that turned out to be an issue deep cloning a complex object that had an IEnumerable list in it. The deep cloning would throw an Exception which was not very descriptive. 

The fix was to change the deep cloning and use json serialization.
You can see the first method is good but it caused the issue. The second fixed it and made he a happy coder.


#CSharp

Tuesday, February 25, 2020

Timezones on Linux and Windows 


When working on teams who run different development operating systems, tests might fail.
This happens when the tests is os dependent like timezones.
Example : setting the timezone string like this will not work on windows:

TimezoneString = "America/Los_Angeles"

The fix for this is:

This will allow the timezone to be set correctly for both Linux and Windows envionments.

I hope this helps :)

Monday, July 12, 2010

How can I update my user interface from a thread that did not create it?

I had to do this for a test app... Did a long time ago for a production app and need to reference the code.. so here is the link..

Friday, March 19, 2010

Getting data from HTML

I had this issue on an old project.

The problem was how do I pull data from html easily. I found a tool on the gotdotnet website to do this. You can now find it here http://code.msdn.microsoft.com/SgmlReader.

This takes in html and outputs valid xml. Now all you have to do is work with xml.

Simple enough.

Monday, March 8, 2010

Easy way to scale images

Goal: A bucket full of images from Bike week to upload to Flikr.

Issue: Images are to big to upload.

Solution 1: edit each pic manually.

Solution 2: script scaling.

I went with Solution 2.
  1. Installed Imagemagick ( exe
  2. I have cygwin to script, you'll need it.
  3. create script in directory with images:
  4. Run script.
Script:
#!/bin/bash

for i in `ls *.JPG`;
do
n=`echo $i| awk -F "." '{print $1"a."$2}'`
echo $n
/cygdrive/c/Program\ Files/ImageMagick-XXXX/convert.exe $i -scale 800x600 $n
done


That is it. This will convert all JPG files in directory to 800 x 600, creating a copy with an 'a' in the name.

You are welcome. :)

Monday, March 1, 2010

AJAX JSON Information Fetch


Need a web page which fetches information given some arguments from a web service? here you go.

  • Web Service reference 
  • JavaScript
  • Web Service

Address:
City:
State:
Zip:

Friday, February 5, 2010

IE + Flash + SSL = $%$#%@

Found out that if you want to server up images in a secured Flash application in IE, is a pain. Firefox and Chrome no issue.

After searching, yes google, found a link to this Microsoft KB. http://support.microsoft.com/default.aspx?scid=kb;en-us;316431
It says that "The problem occurs if the server is using Secure Sockets Layer (SSL) and has added one or both of the following HTTP headers to the response message:"
This speaks about office documents, but also applies to active x objects, ie Flash.



So, if you response header is returning any of the following, will cause issues.

Pragma: no-cache Cache-control: no-cache,max-age=0,must-revalidate, no-store
You can see this in Fiddler ( you have to check decrypt ssl).

Solution:

Check you web.config make sure you are not caching anything. This sucks for server performance, but will allow the application to work. We also found out that Flash will utilize IE's caching, which benifits the user.

If you still see any of the above in the response header, check the server. IIS has caching settings, clear these out.

After all this is done, the application will server images in Flash, in IE over SSL.

The upseting thing, Microsoft says that "This behavior is by design."

At least I learned something new.