Microsoft ISA Server 2004

Finally a resolution to the problem posted last week has been found. In ISA server, in your basic firewall rules there is an option called: “FTP Readonly”. This option was default unchecked until in 2004 Microsoft decided to make that default. This caused us a lot of problems we were unable to send data through FTP even though we could successfully connect to FTP servers. So after lots of hard working hours we found that evil checkbox.

Adobe Photoshop CS2

I have been using Adobe Photoshop CS2 for sometime now and I would like to write a review for it.

In short I don’t really think it’s worth the money to move from Aobe Photoshop CS (if you are using this version). Howerver from a 7.0 it’s a great change, here are some I noticed and liked:

Adobe Bridge
Is the new tool to explore your files. It can view RAW thumbnails and also allow you to paste settings from one RAW file to another saving you a great deal of time. It also allows for you to rank images and preview them at various sizes using a simple slider.

RAW Tool
The rool tool is updated as well. They added a new contrast curve which works much like the curve on actual photoshop but right within the RAW viewer.

Smart Sharpen
Finally, a new sharpening tool. It allows finer control than the Unsharp mask allow you to fade sharpness from highlights and shadow area individually.

32-Bits Images
Yes! You can now edit images in 32-Bit RGB. 32-Bit only seems to work in RGB and CMYK not in lab color modes. But’s it’s a way to change the levels and curves making certain that there will be no loss in the process.

More tools availabe in 16-Bit
There are more tools available in 16-Bit now almost as if you are working on 8-Bit.

I purchased a Canon 20D at the same time I moved from Adobe Photoshop CS to CS2. Now most of the images it seems like there is less work that I need to do specially when it comes to white-balance (in the shadows) and contrast. The Canon 20D seems to produce more contrasted images using the same lens compared to the Canon 10D. Anyway, CS2 seems to do a better job at white-balancing from the RAW viewer than CS did. For sometime I also used Phase One’s Capture One — which I think is a great tool and was using this while I was using CS. However since CS2 I don’t feel the need to use Capture One anymore because I think the conversion quality I get with CS2 is same if not better than Capture One.

Windows 2003 and Visual Studio .NET

If you are developing web-applications from a Windows XP box using VIsual Studio .NET and the web server is running Windows 2003 plus your inetpub folder is the not the standard c:\inetpub then you are going to have some problems. Our system administrator setup the IIS web root in a folder other than c:\inetpub let’s say in e:\wwwroot now from my Windows XP box if I try to create a new Visual Studio .NET ASP.NET project against the Windows 2003 server I get the error: “The UNC path … does not exist or you do not have permission to it”. The reason I am getting this error at first I thought was because wwwroot was not shared so I share the folder but I still get the same error message. Then I realized that th share name has to be called: wwwroot$ there has to be a dollar sign after the name. To do shares like this you actually have to go to Computer Management MMC -> Shares and add the share wwwroot$. Once I did that the problem was fixed !

Note simply sharing the wwwroot folder will not solve the problem because sharing it from Windows Explorer would name the share wwwroot. It has to be called: wwwroot$

Recursion in SQL

Oracle database supports a very strange construct called: start with, and connect by. For instance if you have a table which has two columns one that defines the parent of the other column such as:

Parent	Child
  0 		1
  1 		9
  9 		7
  7 		2

The parent of 2 is 7 and 7′s parent is nine and 9′s parent is one and so on until finally 1 who parent is 0 signifying no parent. To find the root or the top-level parent given an ID cannot be done easily without recursion and SQL server does not support recursion in SQL contructs. But Oracle does, here’s how we can solve this problem in Oracle:

SELECT *
	FROM test_connect_by
START WITH parent = 0
CONNECT BY prior child = parent;

So in the meantime I am solving this problem by recursing through a C# function. I would like to get away from that and rewrite the C# recursion into a SQL stored-procedure.
I will post that solution as soon as I am ready.

Bug 2: MTSecurityCode

When dynamically building archives if we use the MTSecurityCode tag then the image fails to validate. The reason is the following. If you open this file function.MTSecurityCode.php in the PHP and plugins folder, you will see the following code:

<?php
function smarty_function_MTSecurityCode($args, &$ctx) {
	$config = $ctx->mt->db->fetch_plugin_config("SCode");
	$maxtmp = intval($config['maxtmp']);
	$code = mt_rand(1,$maxtmp);
	return $code;
}
?>

Calling this function twice will generate two separate and independent codes. According to the documentation if you use the code supplied in step 5 of the usage section then notice how the tag: MTSecurityCode is called twice in the dynamic mode this causes the image to be generated twice.

The solution to the problem was following I modified the function.MTCodeInsert.php to fit my needs and used that instead of MTSecurityCode.

MTSecurityImage

The smarty tags for MTSecurityImage has an error which will cause the security image to not show up when the blog is set to: “Build only Archive Templates dynamically”. The way to fix this problem is to go to your cgi-bin directory go to the PHP folder, then to the plugins folder and modify the function.MTSecurityImage.php script

<?php
function smarty_function_MTSecurityImage($args, &$ctx) {
	$path = $ctx->mt->config['CGIPath'];
	//if (substr($path, strlen($path) - 1, 1) != '/')
	//$path .= '/';
	$path = 'plugins/SCode/mt-scode.cgi';
	return $path;
}
?>

Since CGIPath is already included as part of the img src source tag we don’t need to additionally append the CGIPath to the PHP path information.

Comments and MovableType 3.2

There seems to be a bug that stops users from commenting in the new version of MovableType blog (the one I am using currently). If a user comments and tries to send another comment the system reports an error saying:

In an effort to curb malicious comment posting by abusive users, I’ve enabled a feature that requires a weblog commenter to wait a short amount of time before being able to post again. Please try to post your comment again in a short while. Thanks for your patience.

The bug happens due to a TimeZone issue and has been reported to SixApart for a fix. Setting the ThrottleSeconds to 0 in mt.cfg does not seem to help either because the timezone conversion is incorrect and because of that the user needs to wait 2 hours before he/she can comment rather than 30 seconds.

Typed ToArray() from ArrayList

To get a typed Array of type int [] from an ArrayList you can do the following:

(int [])TestArray.ToArray(typeof(int));

First the ToArray() function accepts a System.Type argument which is what it uses to convert the Array to type int. However, the return type of ToArray() is still object so we will need to cast that as well which can be done using the (int []).

FTP & Microsoft ISA Server 2004

Microsoft ISA (Internet Security and Acceleration Server) 2004 is a tool to secure and accelerate (as the name suggests) networks running on Windows platforms. It’s a very powerful tool and is one of the most flexible firewalls I have seen in the market. Where I work, Microsoft ISA actually replaced several CISCO firewalls. Not only were we able to migrate all the access lists rules we were able to do far more than that.

Just so we a sense of our setup we have two Microsoft ISA servers running. One that handles the X subnet and the handles the Y subnet. All of the servers and static-IP workstations are hosted on the Y subnet. The ISA server that firewalls the Y subnet allows more incoming and outgoing ports to facilitate testing, production level data transfer and so on.

Me and our system administrators spent almost all day today trying to figure out a solution to a strange problem. When we FTP from the Y subnet (the static subnet) to a external box, we can successfully login because PORT 21 is port. However, after logging in we cannot upload any files. After some researching I found out that FTP does not receive data from PORT 21 but changes the incoming port dynamically which is set using the FTP command PORT or PASV (depending on which mode you are running your client). So even though the primary port is PORT 21 — it’s referred to as the COMMAND PORT. It’s not the PORT which is used to send/receive data. Which port will be used is randomly selected using the PORT/PASV command to minimize security issues.

The way to fix this issue only seems to be to open a range of outgoing TCP ports above the 1000 range (what this range is still remains an issue) it seems to depend on the server — and worst yet the server configuration. Most FTP servers will allow the emperical port range to change which might cause problems on our ISA server.

In any case, the issue hasn’t been resolved yet — but I will definietly post the solution once we find out.

Recursive Fun (C#)

Recursive functions can be a lot of fun! I was playing around with a collegue of mine at work about solving recursive problems. And we both worked on a problem of deciding weather a number is the median in a list of numbers. Here’s my solution:

using System;

public class MedianRecursive {
	private delegate bool Function(int A, int B);

	private static bool GreaterThan(int A, int B) { return A>B; }
	private static bool LessThan(int A, int B) { return A<b; }

	private static string Partition(int[] List, int M, int Position, Function Compare) {
		if(Position>=List.Length) return "";
		else return ((Compare(List[Position], M))?List[Position].ToString():"") + Partition(List, M, Position+1, Compare);
	}
	private static bool Median(int[] List, int M) {
		return (Partition(List, M, 0, new Function(GreaterThan)).Length == Partition(List, M, 0, new Function(LessThan)).Length);
	}
	public static void Main(string [] args ){
		Console.WriteLine("Is Median: {0}", (Median(new int[]{1,2,3,4,5,6,7}, 4)?"Yes":"No"));
	}
}

The most obvious way of solving this problem is to sort the list of numbers, go the middle of the sorted list and check to see weather List[Middle] == M. However, that’s a little overkill. Why sort when all we need to do is check if a number a list’s median? The method I used partitioned the list into two subsets. The first subset contains all numbers less than M and the second subset contains all numbers greater than M. If M is the median of the list then the first subset’s length should equal the second subsets length. SIMPLE!

There are three main group of functions. The first function Median(int[], int) is the function that makes the call to Partition with proper arguments. Partition accepts the List, the median value M, the starting Position and finally and comparision delegate (function).

Notice how, Median makes two identical calls to Partition one with a GreaterThan delegate and the other with a LessThan delegate. If both this Partition calls return the same length string then M is the Median!

Page 4 of 18« First...2345610...Last »