Hide Subfolder in Multiple Domains Under One Site

Filed Under (Development, DotNetArabi) by Emad Alashi on 26-12-2011

Tagged Under : , ,

After I have moved to WinHost, I was surprised they don’t support multiple domains under one site out of the box; you have to rely on IIS URL Rewrite magic to achieve that.

So as expected, I looked for a solution in their KB and the internet (you don’t reinvent the wheel, remember?) and found couple of posts here, here, here, and here that helped a lot in achieving this.
So I managed to have www.emadashi.com and www.dotnetarabi.com working fine together residing in the folders “emadashi-blog” and “dotnetarabi-root” respectively under the root; they both have same IP address, but upon request a redirection is made to the proper application folder.

Until one day my very good friend Omar Qadan generously shared a link to an episode he found interesting; and the link was as the following:

“www.dotnetarabi.com/dotnetarabi-root/episode.aspx?..etc”

Ops! that’s not right isn’t it! The URL should not include the folder name “dotnetarabi-root”! So I read more about Regular Expressions, read the above mentioned article more thoroughly, and came to the conclusion that for each domain we have we are going to write two rules:

1) Correct and Redirect undesired URL’s:
If IIS receives a request that contains the folder name (e.g “www.dotnetarabi.com/dotnetarabi-root/episode.aspx”), then:

  1. Omit the folder name from the URL, in our case the URL becomes “www.dotnetarabi.com/episode.aspx” 
  2. Redirect the request again to IIS using the new URL, by sending 301 status prompting the browser to initiate a new request with the new URL

The step above can be achieved by the following:

Figure 1:

    1. <rule name="UnWantedDirectAccessToSubFolder-DotNetArabi-root" patternSyntax="ECMAScript" stopProcessing="true">
    2. <match url=".*" />
    3. <action type="Redirect" url="{C:1}" appendQueryString="true" logRewrittenUrl="false" />
    4. <conditions>
    5. <add input="{HTTP_HOST}" pattern="^(www.)?dotnetarabi.com" />
    6. <add input="{PATH_INFO}" pattern="^[/\\]dotnetarabi_root[/\\](.*)" />
    7. </conditions>
    8. </rule>

Then we do the second rule:

2) Guide and Redirect desired URL’s to the right folder:
If IIS receives a request by the URL format we desire, which doesn’t contain the folder name (e.g. “www.dotnetarabi.com/episode.aspx”) then:

  1. Insert the folder name to the URL to be come “www.dotnetarabi.com/dotnetarabi-root/episode.aspx” in our case
  2. Rewrite the URL again within IIS using the new URL

Which can be achieved by the following:

Figure 2:

    1. <rule name="DirectToDotNetArabiRoot" patternSyntax="ECMAScript" stopProcessing="true">
    2. <match url=".*" />
    3. <action type="Rewrite" url="dotnetarabi_root/{R:0}" appendQueryString="true" logRewrittenUrl="false" />
    4. <conditions>
    5. <add input="{HTTP_HOST}" pattern="^(www.)?dotnetarabi.com" />
    6. <add input="{PATH_INFO}" pattern="^[/\\]emadalashi_blog[/\\]" negate="true" />
    7. <add input="{PATH_INFO}" pattern="^[/\\]dotnetarabi_root[/\\]" negate="true" />
    8. </conditions>
    9. </rule>

The best way to describe what happens is through this diagram I put together (the start block is the “Browser”):

clip_image001

And that was it, now notice the following:

  1. The rules should maintain the mentioned order
  2. Rule 1 uses action type “Redirect”, and Rule 2 uses action type “Rewrite
  3. We configure the rules to stop processing any rule after it is executed
  4. Your key to successful and easy manipulation of the URL is to understand the Back-references in the URL Rewriting, notice the {C:1} and {R:0} usage above, notice as well the brackets () in the URL’s; they are used to capture the back-references, check the “Using back-references in rewrite rules” in the above mentioned article
  5. To test your rules use Fiddler, IE Developers Tools (Network tab), or Firebug (Net tab), and the great tool IIS provides to test rules which can be accessed by: open IIS –> select site-> URL Rewrite –> Double click rule –> double click condition –> Test pattern:
    clip_image002

I hope you found this useful.

Let me do thanks here to  www.gliffy.com as well for providing such great service for drawing diagrams online

Best Skype Audio Chat Recorder

Filed Under (DotNetArabi) by Emad Alashi on 15-10-2011

Tagged Under : , ,

This is a shout-out to MP3 Skype Recorder, the best Skype recorder I have ever used to record Skype calls.
It’s been two years since DotNetArabi’s first episode, most of the episodes were recorded over Skype using MP3 Skype Recorder. It wasn’t the only tool I tried, I have downloaded several, but none competed with its simplicity and robustness, never hanged, never failed, and it’s totally free!

10-15-2011CropperCapture[2]

If you want the best Skype audio recorder, check MP3 Skype Recorder

Use Powershell To Follow Your Followers On Twitter

Filed Under (Development, DotNetArabi) by Emad Alashi on 26-08-2010

Tagged Under : , ,

Update: Twitter “statuses/followers” API documentation had a small note at the bottom that says that it returns only 100 followers if no paging is used, I have updated the script accordingly. Thanks to @RamyMahrous for notifying me on this in his comment below. <End of Update>

For a long time I thought that @DotNetArabi shouldn’t follow it’s own followers due to various reasons I had, but lately I discovered that I was wrong. So I have decided to follow them back no matter how many they are, but that would be a tedious thing to do manually. Here comes Powershell to the rescue.

I wrote the following Powershell script in Powershell ISE (the Integrated Scripting Environment) which is already shipped with Win7, utilizing Twitter’s API’s and it did the trick:

———————–
 $wc = new-object System.Net.Webclient
 $wc.Credentials = new-object System.Net.NetworkCredential "dotnetarabi","UseYourOwnPWbuddy!"
 $cursorCount = "-1"
 
 do { 
 
 $rest = $wc.DownloadString("http://api.twitter.com/statuses/followers.xml?cursor=" + $cursorCount)
 $xml = [xml]$rest
 foreach( $user in $xml.Users_list.users.user ) 
 { 
    $wc.UploadString("http://api.twitter.com/1/friendships/create/" + $user.screen_name + ".xml", "")
 } 

 $cursorCount = $xml.users_list.next_cursor
}
while($xml.users_list.next_cursor -ne 0)

——————-

It’s simple and straight forward; I used “UploadString” method of the Webclient class because it produces a “POST” HTTP request required by Twitter API rather than “GET”.
Note that the response you get from the “Create” API will be either an XML representation of the followed-user entity, or a server error “Forbidden” for many of reasons Twitter may have. This is how you will know if each “follow” procedure succeeded or not

Thanks to Helge Klein I could highlight my Powershell script by his script here

Exposing DotNetArabi for OData

Filed Under (Development, DotNetArabi) by Emad Alashi on 10-04-2010

Tagged Under : , ,

www.DotNetArabi.com www.odata.org

Lately OData (Open Data protocol) is gaining a great momentum, everybody is talking about, and in fact it deserves all this fuss. OData is a protocol through which you can share data provided as ATOM or JSON formats by exposing URI’s to be invoked via HTTP, check the FAQ for fast information.

One of the interesting things is that the protocol provides various options through the URI to query all sort data; conditions, ordering, filtering, smart selection, …etc, in addition to very smart linking between exposed entities.

So hereby I provide the data of DotNetArabi through OData on the link http://odata.dotnetarabi.com/odata.svc for the sake of fun and for anyone who might find it useful. I used the Entity Framework for this purpose since it was the easiest, you can find a very helpful information here.

To start playing around check:

http://odata.dotnetarabi.com/odata.svc/Guests
http://odata.dotnetarabi.com/odata.svc/Episodes?$filter=AudioFileLength gt 40

I hope you find it interesting.

If Crashing Gracefully Is Nice, Recovering From It Is Awesome

Filed Under (Development, DotNetArabi, Misc, software management) by Emad Alashi on 02-03-2010

Tagged Under : , ,

Last Saturday we had a SharePointSaturday event here in Jordan, in which I had the pleasure of interviewing Joel Oleson and Michael Noel for DotNetArabi.

At the end of Joel’s valuable interview, which can happen only in a life time, I stopped the recording by hitting the “Stop” button, simple. Surprisingly, instead of stopping the recording, Audacity just froze! I could hear myself screaming inside “NOOO!!!”, I guess even Joel heard that! the whole machine stuck that I had to force it to a Hard Shut down.

But knowing Audacity as a great piece of software, which really is, I hoped that I could still retrieve the recording. I rebooted and started Audacity again, and here comes the so refreshing alert at the start:

CrashRecovery

Some projects were not saved properly the last time Audacity was run. Fortunately, the following projects can automatically be recovered

THAT is a successful software! of course I lost portions of the recording still, but I can’t complain; I have most of the interview. So, When you design your software, DO make sure you don’t crash gracefully only, but yet to recover correctly from the crash.

DotNetArabi Podcast Equipment

Filed Under (DotNetArabi, Misc) by Emad Alashi on 16-01-2010

Tagged Under : , , , ,

After publishing 8 episodes of DotNetArabi, I think it would be nice to share on this blog how it goes and what equipment needed in the process. But before we begin, dear reader, note that I am not an expert, I am still in the beginning of the way, though it’s going good so far.pavillion

  My working machine is HP dv 6700 laptop, my first trials with recording was with simple microphone like the ones you use for chats; recording in winter made things smooth, but when summer came a long the heating problem became obvious in the low quality of the audio recorded, in addition to the higher target I needed anyway, so a different measure had to take place.

 

I looked for an audio device that would clear the recording of any noise that is caused by the internal electrical and the fan. I had different options then, but the most interesting one was the MobilePre USB audio interface which I finally got. It takes analog inputs (2 of which are XLR) and transforms to digital signal view USB.

MobilePre_3qtrMobilePre_back

Of course it appeared that it is over bloated than what I really needed, but I liked it anyway and produced the quality I looked for, though if you are going to record voice only, I believe there are other devices with lower cost.

To complete the set I got myself two XLR Microphones, not fancy ones, 15 JD’s each (about 22 US $) and that was it.

microphone xlrPort

Now on the software side I use Audacity, I find it the best free audio software.

AudacityScreen audacity

After all that, you’d find it surprising that you still need to use the Noise Removal feature in Audacity. And by that you can have your own podcast :)

DotNetArabi Episode 5 دوت نت عربي الحلقة الخامسة

Filed Under (Development, DotNetArabi) by Emad Alashi on 29-08-2009

Tagged Under :

   

Episode 5 of DotNetArabi podcast is published on www.dotnetarabi.com

Mohamad Meligy talked in this episode about ORM (Object Relational Mapping), he explained in details how they work, why we need them, their advantages and disadvantages, and listed some of the known ORM engines.

لقد تم نشر الحلقة الخامسة من دوت نت عربي على www.dotnetarabi.com. تحدث فيها محمد مليجي بإسهاب عن
الـ ORM (Object Relational Mapping). مفصلا ماهيتها، و كيف تعمل، و حسناتها و سيئاتها، و ذكر كذلك بعضا من المكتبات البرمجية  منها و حسناتها.