Author Archives: Hasan Bazerbashi

About Hasan Bazerbashi

My name is Hasan Bazerbashi graduated from New York Institute of Technology with B.Sc. in Computer Science. I’m the kind of guy who loves the Computer and everything about it and about Technology. And let’s not forget about Robots! I do .NET programming, and have lot of projects I’ve done using it and lot in my mind that I want to do using this great technology. As for my hobbies, I like taking photos and learning about photography and still an amateur photographer, also I enjoy playing video games from time to time, and of course watching movies and listening to Music.

Cleaner streets campaign

While visiting a computer store, I noticed a pile of paper bags with some brochures at the desk, on a closer look I found a pleasant surprise!

It was a campaign for having a cleaner street focusing on the habit of throwing trash out of the car’s window! Which is something I totally despise!

The campaign package consists of two things, the brochure which talks about how it is very hard to collect all the trash thrown out of the car’s window and how it needs an army of cleaners to collect that trash, because of course there are a lot of cars and a lot of people who are not aware of this issue. The second thing is a paper bag which you can stick on the car’s interior and put your trash in. Nice idea!

It is really nice to see people getting more aware and more civilized about this issue!

Thanks for the organizers and sponsors of this campaign:

Execution and planning:

– Scouts Syria
– UNHCR Damascus
– Twenty-fourth Division

Sponsors:

– DigitalNet
– Zad ISP
– Al Waten

Share

Synaptic or apt-get through a proxy

If you are like me behind a Microsoft ISA server proxy on a domain network or any other type of proxy, you will find problems getting the Linux applications Synaptic package manager or apt-get to work.

The best way I came across to solve this issue is to use a software called ntlmaps.

This application is a proxy software that allows you to authenticate via an MS Proxy Server using the proprietary NTLM protocol. This is useful when you start getting error “Error 407 Proxy Authentication Required” which drove me crazy the whole day!

I’m using Ubuntu as my Linux OS. If you were able to make Firefox work so you can go to http://packages.ubuntu.com/ , select your Ubuntu edition , browse all packages and look for ntlmaps, download it and install it.

After that open the file /etc/ntlmaps/server.cfg and make sure you fill the parameters correctly such as the Listening port (The port to use in the proxy) NT_HOSTNAME (Which is the Domain Controller’s computer name on the network) and NT_Domain.

After that configure the Network proxy to use your new proxy for example: 127.0.0.1:5865

Good luck 😉

Share

Handle Date formats problems in .NET

Recently I faced a problem when I was deploying a project on a remote server.

Locally my ASP.Net web application was working like breeze, but when I deployed it on a remote server the problem appeared. When the user try to generate a report selecting a date range and hit go, the user gets an error message “String was not recognized as a valid DateTime”.

The report is consisted of two Calendars with “dd/MM/yyyy” date format, a Grid View and a Text box to filter the grid. I used the Visual Studio to create the GridView which takes the Select parameters from both Calendars when binding. The date column in the MS SQL Server 2005 is of DateTime format and it shows like “31/05/ 2009 11:10:00 AM”.

So obviously there is a misunderstanding of the date entered, which means a difference in the Culture environment. I tried changing the regional settings of the server to match local machines settings, but that didn’t work; still the same error. I also tried to force the Culture info in the web.config, but that also didn’t work for me!

Then I was only left with formatting the date manually to the server’s taste 🙂

To do that, I used the Selecting event of the SQL Data Source to modify the parameter data before going to the Database. Note that if your case is with updating or deleting, .Net also has those events for you to use.

So I used the following function to convert the date format of my Calendar which is “dd/MM/yyyy” to whatever the machine likes 🙂 (Is compatible with).

Public Shared Function ConvertToDate(ByVal dateString As String, ByRef result As DateTime) As Boolean
Try

‘Here is the date format you desire to use

Dim supportedFormats() As String = New String() {“dd/MM/yyyy”}

‘Now it will be converted to what the machine supports

result = DateTime.ParseExact(dateString, supportedFormats,System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None)

Return True
Catch ex As Exception
Return False
End Try
End Function

And from the Selecting event of the SQL Data Source:

Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting

Dim d1, d2 As Date

If txtFrom.Text <> “” And txtTo.Text <> “” Then

ConvertToDate(txtFrom.Text, d1)
ConvertToDate(txtTo.Text, d2)

e.Command.Parameters.Item(0).Value = d1

e.Command.Parameters.Item(1).Value = d2
End If
End Sub

I just wanted to share this, I hope this would help 😉

Share

ADSL new prices in Syria

Ok so after like two years since the last ADSL prices cut, they did it again.

This time they introduced new type of subscription which depends on how much of Gigs you download.

Prices are as follow:

Limited by bandwidth

256 Kbps costs 900 SP a month (~ $19) – 2 GB bandwidth – each extra 1 GB costs 200 SP (~ $4)

512 Kbps costs 1200 SP a month (~ $25) – 4 GB bandwidth – each extra 1 GB costs 200 SP (~ $4)

Flat rate (Open bandwidth)

256 Kbps costs 1450 SP a month (~ $30)

512 Kbps costs 2300 SP a month (~ $48)

1 Mbps costs 3350 SP a month (~ $71)

2 Mbps costs 6100 SP a month (~ $130)

4 Mbps costs 11600 SP a month (~ $246)

8 Mbps costs 22600 SP a month (~ $480)

So these are the new prices, what do you think?

Well I don’t they are bad.

But the crappy thing is that they doesn’t have any subscriptions available!! It means that if you and want to subscribe, they got non! That’s what they say. Speed and stablility still sucks.

So what good are the new prices if there is no subscriptions!!?????

Share

How to Dispose a Form in C# without closing the Application

As a good programmer you should be thinking about the resources your software uses and be as gentle as possible on the Computer’s memory.

With C# you would be probably clearing the objects you no longer need from the memory using the Dispose method.

But if you dispose a Windows Form in C#, the whole application will quit! WHY?

That’s because by default C# select a start up form defined in the Program.cs file like this:

Application.Run(new Form1());

So to fix this just delete the “new Form1()” , and load up an instance of the form you want from Main() in the Program.cs so the whole thing will look like:

Form1 frm1 = new Form1();
frm1.Show();
Application.Run();

Now you can load and dispose forms all you want without the application quiting on you:)

Share