I have moved my blog to Github Pages !!

Standard

I believe WordPress isn’t proper for these days so I decided to move to another place. I moved my blog to Github Pages and I have successfully migrated all previous posts. You can reach it via
this link. Feel free to go there , check posts , comment and give me your feedback about this move. Thanks a lot for your caring.

How to get the Hijri Date in Windows 8.1 Accurately?

Standard

I was trying to get the Hijri date while developing a windows 8.1 app but it wasn’t an easy task to do so especially when you know that unlike the normal .Net Framework , you can’t access Hirjri Calendar Class here although it is available due to MSDN documentation.

 

To save your time , at first I used a simple web service that provides Hijri Date as a text and parsed it. The nice thing is that this service is provided by Al-Azhar (Dar Al-Iftaa) so it is credible and accurate and wouldn’t stop after a short time.

 

I will share with you the code I wrote to get the date from this service

    ConnectionProfile connection = NetworkInformation.GetInternetConnectionProfile();
            bool internet = connection != null && connection.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess;
            if (internet)
            {
                HttpClient client = new HttpClient();
                string res = await client.GetStringAsync("http://www.dar-alifta.org/dateservice.aspx?LangID=1");
                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(res);

                DateTimeFormatter df = new DateTimeFormatter("longdate", new string[] { "ar-sa" });
                var date = df.Format(DateTime.Now);

                return doc.GetElementbyId("lblDate").InnerText;

            }

To parse the HTML result , I used HTML Agility Library.

Although the previous solution would be accurate , it still needs internet to get the result which would result in a problem if the user’s device isn’t connected to internet all time. So here is another way to get the date if there is no internet connection

 

      DateTimeFormatter df = new DateTimeFormatter("longdate", new string[] { "ar-sa" });
            var date = df.Format(DateTime.Now);
            return date.ToString();
                    

Combining these two ways should satisfy your user who wants to be aware of the Hijri Date anytime.

 

Regards ,

 

Ahmed Kamal

ACM Solution Manual

Standard

Today I received some questions from a student in Ahram Canadian University about ACM and how he can join and prepare himself so as a try to answer all these questions, I will write this blog in Q&A style. I hope that all these answers could help people trying to know more about ACM and problem solving in general.

I wrote before a blog about some resources that could help students looking to participate in problem solving contests like ACM, Top Coder and other programming contests so I will not repeat myself and you can check it of course before reading this blog.

So let’s start clip_image001

How could we initiate an ACM branch in our university?

Like other activities (IEEE, MSP Program, GSA Program), ACM has some rules that you need to follow until you would be able to initiate an ACM Student Chapter inside your university.

I guess you could contact with Eng. Mohamed Fouad as he is the one who could help you with this stuff as far as I know especially if you want the chapter to be an official one. However, let us say that having a chapter inside your university is a good step that would help you organize trainings and contests and raise the awareness of students of computer science and problem solving.

Should we initiate a branch inside university before being able to participate in ACM different Competitions?

I guess the answer here is NO. You can participate with any two students from the same university as long as you would be able to cover the cost of registration and transportation.

The coach can also be one of these three students.

To know more about ACM rules, check this website http://www.acmacpc.org/

How can I get the needed training to prepare myself for the competition?

Thanks to god, now many available resources should help you in your journey if you are interested in improving these skills.

1- Arabic Algorithm Series : As its creator describes it, it is “An Arabic Series in Algorithms and Data Structures from competitive programming perspective with emphasize over thinking skills.”

Dozens of videos have been prepared until now and there are more coming I guess.

2- Competitive Programming Book : In my opinion, this book covers all what you need to become a good problem solver. If we added it to the first resource, I think this would be enough at least for the start.

Download it from here if you could not buy it.

3- Offline Trainings: As I mentioned before you could organize a training inside your university if you have a branch. In addition, some trainings are usually held in universities that have branches and always participate in the different programming competitions like Alexandria, GUC and Cairo University. You should try to follow up and communicate with them to be able to attend.

When and where would the next competition be held?

I guess you can get this info through the official Facebook pages or from the official website of ACM ACPC

Regards,

Ahmed Kamal

Why clean code !!

Standard

A7med Kamal:

Deserve Reading !

Originally posted on Clean Code:

This is Ahmed Adel blogging for you the first topic in Clean Code series of posts.

A while ago I was developing an android app. Actually it was my first app :D and it was the biggest program i have ever written …

Due to the lake of experience, my code was a big – sorry not big i mean huge – pile of mess. If I needed to do some changes I would have to stay for hours fighting – literally – with the code ….

After a bit of time i started to set a system for myself – even though – it was filled with errors and disorganizing but it helped me to keep track of my code and be able to change it with a less  fighting, cursing and most important less time :D

I have heard the term Clean Code millions of time and with practice…

View original 428 more words

How could you master any technology easily ?

Standard

When I first heard about Windows 8, I decided that I want to learn how to build apps for this new and promising platform. This was around 2011 and in this time Windows 8 was just a developer preview version. There weren’t any tutorials or videos that could help ! I opened dev.windows.com – by the way it wasn’t as rich as it is now – , installed the needed tools and made my ‘Hello World’ application.

Yea , I made it , now let’s dig deeper but actually what came next wasn’t like this good start , frankly everything went wrong ! The code samples were too complex to be understood by a guy who only knows C# programming basics. The support was weak so one couldn’t easily find any help. I remember that I asked a Microsoft employer how I could learn  Metro Style Apps development  (The old name of Windows 8 Store Application ) and where I should start , he didn’t tell me anything except that I should check MSDN. “Again!” said to myself.

I didn’t stop trying, I read some articles and check may be all the tutorials that were available at this time. After some time I figured out that what I really in need to is studying a lot of concepts so as to become ready for developing polished and professional apps.

May be you are asking yourself how some people are able to learn a technology in just few weeks and sometimes in only a week or less. Actually there are two opposite cases :

1- Geeks who already have strong technical foundations and excellent understanding of the main concepts of this technology and then are able to absorb any new features or new releases easily and fast.

2- Beginners who don’t have enough knowledge or experience and all their projects or apps are made with the help of code snippets , tutorials and may be video tutorials that they often don’t truly understand.

So how could you solve this problem if you are a beginner who looks really for mastering a technology not just making some simple and repeated applications ?

1- Focus on learning concepts at first

BuildingBasement

Concepts are like the basement of any building , The stronger it is , the stronger and taller your building would be.  So don’t be hasty and give as much time as possible to mastering basic concepts stage and even if you face a  feature / option that depends on a concepts or something that you aren’t aware of , face the problem and give your self the enough time to go back and learn this thing before you continue. for example if you are going to learn Android mobile development , make sure that you mastered Java concepts and object oriented concepts and are aware of xml and the basic concepts and problems that any mobile developer should know.

“The formulation of the problem is often more essential than its solution” Albert Einstein

2- Read , Read , Read

Reading

Although I recommend video tutorials -if they are available- to learn the basics of any technology , I can’t deny that reading is essential and it is the only thing that could make you aware of the details of anything  and therefore understand it well too. Reading shouldn’t be limited to text books. There are hundreds of blogs that have tons of excellent information that are extremely beneficial. Sites like CodeProject , MSDN , JavaDoc , StackOverflow should be in your bookmarks if you  are serious about learning technology and definitely  you should spend hours reading new things in them,

3- Learn by doing

Do

Watching and reading tutorials is good but isn’t enough at all. There are several skills -Debugging is one of them – which you won’t acquire unless you get your hands dirty in code. Download hands on labs and try to build them on your own , apply what you learnt and make simple projects. This would keep you motivated and would make you better programmer of course.

4- Keep updated

update

Technology is changing everyday and you should keep up with these changes and continuously update your knowledge if you want to compete in this market. There are many tools and ways that could support you. Subscribing to technology geeks blogs , following them in Twitter and regularly check dev. sites should help a lot. Attending technology related events is indispensable.

Finally, there is an excellent blog about how you could stay on top by Bob Tabor that I recommend reading.

I hope this blog could help you learn to avoid most of the mistakes that beginners commit and use your time wisely too. For non-beginners , I would be happy to hear from you especially if you have other advises or recommendations that you believe should be added to this blog. Good Luck !

Ahmed Kamal

Difference Between Class and Struct

Standard

I think many of who are learning Programming have confusion about the difference between “Class” and “Struct” concepts in C#.

One of the great explainations can be found in MSDN Library and in this post content depend on it .

Classes and structs are two of the basic constructs of the common type system in the .NET Framework. Each is essentially a data structure that encapsulates a set of data and behaviors that belong together as a logical unit. The data and behaviors are the members of the class or struct, and they include its methods, properties, and events, and so on, as listed later in this topic.

A class or struct declaration is like a blueprint that is used to create instances or objects at run time. If you define a class or struct called Person, Person is the name of the type. If you declare and initialize a variable p of type Person, p is said to be an object or instance of Person. Multiple instances of the same Person type can be created, and each instance can have different values in its properties and fields.

A class is a reference type. When an object of the class is created, the variable to which the object is assigned holds only a reference to that memory. When the object reference is assigned to a new variable, the new variable refers to the original object. Changes made through one variable are reflected in the other variable because they both refer to the same data.

A struct is a value type. When a struct is created, the variable to which the struct is assigned holds the struct’s actual data. When the struct is assigned to a new variable, it is copied. The new variable and the original variable therefore contain two separate copies of the same data. Changes made to one copy do not affect the other copy.

In general, classes are used to model more complex behavior, or data that is intended to be modified after a class object is created. Structs are best suited for small data structures that contain primarily data that is not intended to be modified after the struct is created.

 

Best Wishes ,

Ahmed Kamal

 

How to register in ACM ?

Standard

1- One of the 3 team members will register the team from this link

https://icpc.baylor.edu/login;jsessionid=qztfetiRqTZeSshTzZ+6jg23.undefined

2- Register an account for yourself and complete your own profile (this is important)

Area Of Study :In ex :  “Engineering”

Degree Pursued :In ex : ” Bachelor” 

3- Create a team and choose “The 2012 Egyptian Collegiate Programming Contest >  CAIRO”

3- Ask the other two members to create account  too and then you can add them to the team through “Add Team member”.

4- Assign team members to your team through searching for them using their names. Be sure that the e-mail of him/her is the same as the one he/she registered with to guarantee that he/she  is the right person.

5- Click on “Register Team” button.

6- Don’t forget to make sure that the registration of all the 3 member is completed.

Congratulation :) You have registered your team successfully. Don’t forget to send me the names of the members of your team so I can finish you registration at a.abdelfatah@live.com  & your mail to contact you if there was any problem.

 

Best Wiches :)

Ahmed Kamal