Tuesday, September 28, 2010

Using Watin to download files automatically

When using Watin, you can click on a link automatically or goto a download URL and save a file automatically using something similar to:


FileDownloadHandler fileDownloadHandler = new   FileDownloadHandler(featureCode2AnnouncementWavPath);browser.AddDialogHandler("file.zip");
browser.GoTo("http://www.mydomain.com/file.zip"); // OR: browser.Link(Find.ByID("download_button")).Click();
fileDownloadHandler.WaitUntilFileDownloadDialogIsHandled(15);
fileDownloadHandler.WaitUntilDownloadCompleted(20);

But IE will give you typically a notification bar warning of the type :
"IE has blocked site from downloading files to my computer" and then Watin will not download the file.


The only solution for IE8 that I found for this is to edit the registry and disable this prompting:


HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
     SOFTWARE
          Microsoft
               Internet Explorer
                    Main
                         FeatureControl
                              FEATURE_RESTRICT_FILEDOWNLOAD
                                   iexplore.exe = 0x00000000


currently, i manage to save a file using this method, but for some reason the code stops after clicking the save button and then times out with an exception:


 "Timeout while Internet Explorer state not complete"




I will update if i ever manage to solve this issue (it currently went down in priority)

Sunday, September 26, 2010

Wildcard domain problems with IIS 6.0/7.X

Today, when you want a wildcard domain to point to your site you need to do 2 things:
1) add a wildcard A record to your DNS:
   *.mydomian.com              188.188.2.97

2) add a wildcard entry to your IIS web site:
IIS control panel->right click on your web site-> properties->"web site" tab->advanced

Here you "Add" a site with en empty host header value.

This is the method to send all undefined host web server requests to this site.

For example:
if you have a few web sites defined in IIS (on the same web site node or an different nodes it doesn't matter) - for instance, foo.mydomain.com & bar.mydomain.com (these are defined with foo.mydomain.com, bar.mydomain.com host headers), when you define an additional 3rd value with an empty host header value on the same port, all other requests will go there (x.mydomain.com / www.x.mydomain.com / etc ...).
This is like defining one global wildcard per IIS instance.

This is the only way wildcards can be defined for your web site, and if you want to host multiple wildcard domains on the same IIS machine (e.g., *.mydomain.com and *.someotherdomain.com) you can't ! because the wildcard is a global one "*" and not part of a domain ("*.domain.com").

There are tricks to circumvent this problem ( ISAPI-Rewrite) but they are complicated , and microsoft IIS dev team are aware this is a problem (http://forums.iis.net/t/1095760.aspx), but they haven't provided this feature yet, not even in IIS 7.

There are even commercial products that were built to provide an answer to this problem.

One side note - in apache this is not a problem.

Sunday, September 12, 2010

Mobile application signing schemes: Symbian, iPhone, Android



http://lonelybob.vox.com/library/post/mobile-app-signing-security-android-vs-iphone-vs-symbian.html

The link above contains a great article that compares the 3 schemes used today by Symbian, iPhone & Android.

Quick summary (and some extra info):

Sybian S60 3rd: C++ (tweaked). Require a certificate from symbian company for apps to run on the phone - costs money and testing time - biggest hassle. Also different API levels require different signature levels and costs (2nd ed. and lower were open).

IPhone: Objective C (Apple only development: "Cocoa" IDE). Allow you to do your own signing - but will work only on up to 100 phones. need to join special program for better signature and for appearing on app store.

Adroid: Java (runs separate JVM on the phone for each app). Allow you to self sign and it will work fine on all phone and can be distributed.

I believe that the path Android chose (developer can sign his own apps and they will work on the actual phone) will be the winning choice ! We will wait and see ...

Monday, September 6, 2010

MSSQL why not always define varchar and nvarchar as max in length ...

Table storage wise, there is no difference in storage space used when a 4 char string is stored in varchar(10) or varchar(1000) ... it will use the same space on the disk (it stores the 4 char string plus 2 bytes for the length).

The only difference will be if there is an index built on the field, then the index space used for varchar(1000) will be larger than the index used for varchar(10).

Friday, September 3, 2010

עצמאי פרילנסר בתוכנה וגם עובד לפי שעות ? דרוש שכר שמחסה זמן חגים

בחישוב שעושים כשרוצים לחשב כמה לבקש בתור פרילנסר - אם החוזה הוא לא גלובלי, צריך לקחת בחשבון תקופות חג שעובדים שכירים יקבלו עליהם שכר ואתם לא ...

דוגמא, אם ה 100% הוא מה ששכיר מקבל ברוטו, יש להוסיף

ביטוח לאומי (המעביד משלם 5% על העובד - ועצמאי צריך לשלם את כל ה16%) : 5%
5% : מקביל להשתתפות מעביד על פנסיה לשכיר
7.5% : מקביל להשתתפות מעביד לקרן השתלמות
8.33% : הפרשת מעביד לפיצויים של עובד
ימי חופשה של שכיר בערך 20 מתוך 250 ימי עבודה סהכ בשנה : 8%
דמי הבראה 6 ימים בשנה: 2.2%
 ימי מחלה - נאמר 5 ימים מלאים בשנה : 2%
חגים בערך 10 ימי עבודה מתוך 250 : 4%

סהכ :  42%

מכאן שאם לדוגמא כשכיר מציעים לך 20,000 אז כפרילנסר עליך לבקש 28,400

שימו לב לדבר נוסף- בתור עצמאי אתה לוקח 8.33% נוספים המקבילים לפיצויים אבל אתה כעצמאי תשלם עליהם מס מלא וגם ביטוח לאומי (לעומת שכיר שפטור ממיסים בכלל עד ה 11,000 שח הראשונים לכל שנה שעבד) ומכאן אפשר בקלות להוסיף עוד 8.33% כדי להשוות. ויוצא לנו שורה תחתונה 50% מעל לשכר אילו לא היית עצמאי.