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

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 ;)

Married

Thanks to Allah I got married to the most beautiful lady :D

This is the biggest thing in my life and there is nothing like it…

I hope everyone would have the chance to have this too.

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 ;)

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!!?????

يا مقبلتي

يا مقبلتي….

يا طيب قبلتك الأولى .. يرف بها

شذا جبالي .. وغاباتي .. وأوردتي

ماذا على شفتي السفلى تركت .. وهل

طبعتها في فمي الملهوب .. أم رئتي؟

وقتا .. مرا عليها يا مقبلتي

وعطرها لم يزل يجري على شفتي

كأنها الآن .. لم تذهب حلاوتها

ولا يزال شذاها ملء مخيلتي

كيف كدت أن أغيب عن وعيّ

لولا أن كل جزء مني شدني

لم يرد لهذه اللحظة أن تنتهي

لم يبق لي منك .. إلا خيط رائحة

يدعوك أن ترجعي للوكر .. حبيبتي

ذهبت أنت .. وهي باقية

نبعا من الوهج .. لم ينشف .. ولم يمت

تركتني جائع الأعصاب .. منفردا

أنا على نهم الميعاد .. فأتني

الإهداء: إلى زوجتي

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:)

SyriaTel releasing a new service - My Backup

One of the two Mobile networks in Syria, SyriaTel, is about to release a new service called “My Backup”.

The service let you backup your mobile by first installing a software from the company (a .sis file some program) and then it uploads all kinds of data from the mobile like the SMS, MMS, Contacts, Calendar, and folders to be stored online, where you can manage them.

I heard the service will be like a subscription, there is a 3 months plan, 6 months, and a year subscription. The one year subscription costs 350 S.P (~$8). Without GPRS costs probably.

This service is especially useful when you lose your mobile or when it gets stolen, so then you can restore your mobile data.

I see this as a really cool feature and great advance in services provided by the SyriaTel.

There is a service which I’ve been using for a while to back up my mobile and it is Mobile Network independent, which is ZYB. The only thing I miss with ZYB is that it doesn’t backup MMS, SMS, nor special folders.

Read Sharepoint 2007 Scale Survey with some statistics

Just an hour before letting the employees hit the survey link on our Sharepoint server, the department changed their mind and they doesn’t want the Single Choice for each question Survey I did. They wanted to change the type of the survey from Multiple radio buttons choices for each question(Which returns one Choice) to Scale Survey (GridChoice Survey in Sharepoint terms or Rating Survey) where the vote is of 1 to 5 scale for each point in a question.

Sharepoint does have a Scale Survey, but if you glimps at it you can’t tell who got the best score, which is something they wanted for the “Employee of the month”.

So in the same way I did to read the items of the Choice Survey, I did it again with some modifications. So instead of looking for the “Choice” type, I used “GridChoice”. Also, the value of the response is different. In a GridChoice value you woud see something like:

Co-operation#4#Skills#3#Outgoing#4#Ideas#3#Attendance#2#

This means the employee got a vote of 4 out of 5 for Co-operation,3 for Skills,4 for Outgoing,3 for Ideas and 2 for Attendance.

So now all I had to do is find a way to extract the numbers out of the string and sum up the numbers for each employe. To do that I did the following C# function:


  private int ResponceScore(string expr)
  {
  String[] numbers = System.Text.RegularExpressions.Regex.Split(expr, @”[^\d+]“);
  int total = 0;
  foreach (String number in numbers)
  {
  if (number != “”)
  {
  int num = int.Parse(number);
  total += num;
  }
  }
  return total;
  }

What the funtion does is it recieves the response’s text, use a regular expression to select or extract the numbers in the string, sum up the numbers of the response and send it back to be saved in an array or in a variable (Like adding to a variable for each employee).

So the final code is something like:

 

foreach (SPListItem item in SurveyList.Items)
  {
  foreach (SPField field in item.Fields)
  {
  if (field.TypeAsString == “GridChoice”)
  {
  if (field.Title.ToString() == “Employee Name”)
  {
  empScore+= ResponceScore(item[field.Title].ToString());
  }
}
}

So that is how I managed to do a web part to show the top scores in a Scale Survey in Sharepoint.

Have fun ;)
kick it on DotNetKicks.com

How to read Sharepoint 2007 Survey list and get some statistics

Sharepoint Services is awesome new framework from Microsoft. And these days where I work, I mostly do Sharepoint 2007 and MOSS development.

I got this request where they wanted a Survey. Sharepoint does have survey, but it lacks statistics on the survey. In their Survey, the Choices for all the questions are identical. For example voting on “Employee of the Month”. MOSSAfter responding to this survey, they wanted to show the top employee in each Choice. The style of the answers are Choice type, where the user choose one of the option under the name of the employee. For example:
- Emplyee name 1
Choice 1: Co-Operation
Choice 2: Great Example

- Emplyee name 2
Choice 1: Co-Operation
Choice 2: Great Example
.
.
.

So the best solution is to make your Web Part read from that Survey’s items.

And to do that, we just need to loop through the Items of the Survey List, look for the “Choice” type of field in it and read its content (The choosen Choice. Choice 1 or Choice 2 … etc). The title of the field is the question text(Employee name).

So we need two loops one to look for the items, and one to look for items’ fields with the type “Choice” - then its title and content.

This is the code to do the loops and readings:

using (SPSite mySite = SPContext.Current.Web.Site)
{
using (SPWeb myWeb = mySite.OpenWeb())
{
SPList SurveyList = myWeb.Lists["Employee of the month"];
foreach (SPListItem item in SurveyList.Items)
{
foreach (SPField field in item.Fields)
{
if (field.TypeAsString == “Choice”)
{
if (item[field.Title].ToString() == “Co-operation”)
{
coop += field.Title.ToString() + “,”;
}
else if (item[field.Title].ToString() == “Great Example”)
{
example += field.Title.ToString() + “,”;
}
}
}
}
}
}

Here I used normal string variables to store the names of the employees for each Choice, maybe you would like to use some sort of array instead, but I didn’t since I dont have many questions.

So when the code run, I will have something like the following in my variables:
Co-Operation variable: “Hasan B, Ahmad D, Farah H, Aya K, Hasan B, Amal K, Ahmad D”
Great Example variable: “Tahseen K, Sebhi J, Jafar A, Tahseen K”

Now by counting how many times each name is repeated for each choice, I can get an idea of who got the most votes for each choice.

I used the following C# function to count how many times each phrase or word accured in a string variable:

private string CountWords(string input)
{
char[] delims = new char[] { ‘.’, ‘,’, ‘;’ };
string[] wordlist = input.Split(delims, StringSplitOptions.RemoveEmptyEntries);
SortedList words = new SortedList();
foreach (string item in wordlist)
{
if (!words.ContainsKey(item))
words.Add(item, 1);
else
words[item]++;
}
StringBuilder sb = new StringBuilder();
foreach (KeyValuePair kvp in words)
sb.Append(kvp.Key + “: ” + kvp.Value + ”
“);
return sb.ToString();
}

So now from my Web Part I can write:

writer.Write("Co-Operation” + ”
” + CountWords(coop) + ”
” +
Great Example” + ”
” + CountWords(example))

And the function CountWords will return me the number of times a name accured in that passed string variable which represents the Choice.

For my example the output would look like:

Co-Operation
Hasan B: 2
Ahmad D: 2
Aya K: 1
Amal K: 1
Farah H:1
Great Example
Tahseen K: 2
Jafar A: 1
Sebhi J: 1

This code needs some additions to make it more useful, but I searched on the net, and I didn’t find answer for this, so I thought I would share with you what I got so far. I’m probably going to work more on this.

Hope it helped.
kick it on DotNetKicks.com

Vista DVI problem

This is how I solved a problem which a lot of people are facing when they try connecting Windows Vista computer to a Flat Panel like LCD through the DVI output - you get “No Signal” or such a message from your TV.

I did a lot of research about this, and it seems to be the problem is in Vista drivers and how it handles DVI. If the LCD have VGA it would be much easier since the VGA is Plug and Play.

Microsoft promised to fix this bug with SP1. Now SP1 is out and seems it didn’t really fix the problem! At least it didn’t for me when I was trying to connect the computer with a 52″ Sharp LCD through DVI.

I tried updating the Graphics’s card driver, didn’t help. Tried to use a program called PowerStrip to define custom resolutions to be compatible with the LCD, also didn’t help.

At the end, I replaced the DVI cable with “DVI -> HDMI” cable, and finally it did work!

I didn’t remove the PowerStrip software, because I think I need to use it to define a custom resolution for the big LCD.

Charity Garage Sale

Charity Garage Sale will be held on the 1st and 2nd of March 2008 from 10 AM to 7 PM at the Arabic Cultural Center in Kafarsouseh area - with the sale income donated to Basma(Kids Cancer Support organization) .

Look at this flayer for more info:

Charity Garage Sale Flayer

Kids Cancer Support Walking

Last Friday (15 Feb 2008) Kids Cancer Support Walking 2008 took off in Damascus, Syria.
Kids Cancer Support Walking 2008 in Damascus, Syria

The event was organized by Basma organization and the marketing campaign by U.G.

This walking was arranged to raise the attention and understanding about Kids Cancer, and at the same time try to entertain the Kids.

There were some activities for the Kids like Painting, Painting on the faces, Clowns, lunching balloons, gifts, and some other stuff like small dances :)

A few facts I learned about Kids Cancer and some people should know about:

  • Kids Cancer can effect kids from the ages 1 month to 18 years old.

  • It is curable, but costs so much and needs specialized doctors. Unfortunately in Syria there isn’t enough support. There is one Center in Damascus which is lacking financial support and expertise. The available doctors aren’t much specialized in this.

  • Cancer is NOT contagious! I heard stories saying that some parents lock their infected kids from the world!

Basma is an organization which try to help in this. Visit their site to get to know more about this and learn how you can help.

UPDATE: Here is a small Video capture I took from the event when the kids released the Balloons.

Kids Cancer Support Walking - The best video clips are right here

Zain is about to buy SyriaTel

There are some strong rumors saying that Zain a big telecommunication company is about to buy SyriaTel one of the two mobile networks in Syira.

It looks like the company is becoming a major telecommunication player in the area serving customers in 22 country in the Middle East and Africa with a net income around $820 million dollars a year!

Zain LogoThe rumors can be true since we saw that the company did recently buy a mobile network company called Fastlink in Jordan, and the MTC company which is originally in Kuwait but also has branches in Iraq, Yaman, Sudan, Bahrain, Lebanon, and other branches in ~14 country. So it seems to be a natural move if they did really buy the SyriaTel network.

From what I heard they offer great modern services. There is this cool feature which let you make International call with the fees of a local call! Of course only if both parties have a Zain phone number.

Personally I hope this rumor is true.

My new vHome

Hello all,

Yes I’ve been away for some time, and now I’m back with my new Virtual Home :) so make your self at home and take a look around. You’re welcome.

See you ;)