Mohanad Kaleia

Idea for a cause

OOP in Python

During my Master as a Computer Engineer, I worked with Python for data analysis, machine learning and deep learning projects. Python becomes more and more popular especially for writing AI and machine learning algorithms. But that is not the only thing that makes it great programming language, Python is just as C++ and Java supports Object Oriented Programming OOP. Which makes it suitable not just for research purposes but also for large scale applications.

In this article I will discuss OOP concepts in Python. As well as, we will highlight the differences in OOP between C++ and Python as a comparison between the two.

Python is designed from the beginning to support Object Oriented Programming concepts, providing the ability to build  large scale applications. If you don’t know or you kind of don’t remember the concepts of OOP we will review them here briefly in this article. OOP concepts are divided into 5 aspects as follow:
  • Class: represents a prototype for an object. This prototype describe object’s attributes and behavior
  • Object: an instance of its defined class (prototype). An object can hold values for attributes and execute functions defined by its prototype. 
  • Abstraction: with abstraction a class can hide some of its details and expose only specific information to the outside 
  • Inheritance: one of most important aspects in OOP is inheritance for code reusability. 
  • Polymorphisim: means the ability to have same function with different behavior.
We will go through these concepts one by one with an example for each of them. 

Read More

Interpreted Languages VS Compiled Languages

Have you ever wondered what is the difference between interpreted languages and compiled languages. You may already used some interpreted (scripting) languages like Python and some other compiled languages like C++. In this post I will explain briefly what is the difference between scripting and compiled languages.

The main difference between scripting and compiled languages is the former are interpreted where they do not require compilation step while the other do. For example a scripting language (e.g., Python) you can write a code and execute it write away without the need to compile it first and then execute it. The interpreter is execute the code line by line, that’s why interpreted languages considered slower than compiled languages. While a compiler convert the source code into a middle phase named as Byte-code. The byte-code is an executable version of the code that can be executed by an interpreter.

Examples of interpreted languages are PHP, JavaScript and Pyhon. While,  C++ for example is considered as a compiled languages.

There are many advantages of interpreted programming languages, some of them:

  • Interpreted languages saves the compilation time, that’s why they are good for proof of concept application and for scientific applications
  • Interpreted languages are platform independent, unlike in the compiled languages where we have to produce a compiled version for every platform and operating system. This is very useful in web, for example JavaScript application can be run on different browser under different operating system. Just imagine if JavaScript is compiled language then for any webpage we have to test what is the platform and send an appropriate compiled version of the code to the client!
  • Smaller executable package size comparing with a compiled source code

Now we need to speak about the advantages of compiled languages:

  • Compiled languages are considered to be faster in the execution than interpreted languages. Because of that many large and critical projects are written in C++. (e.g., Linux operating system, many web browsers, IDEs, games, …, etc)
  • Secured. the compiled version of a code is not clear and cannot be read this makes application written in compiled languages (e.g., C++) are hard for reverse engineering.

There are many other advantages and disadvantages of both, but I want to limit this post to highlight only the major differences between interpreted and compiled programming languages.

 

References:

  1. https://www.geeksforgeeks.org/whats-the-difference-between-scripting-and-programming-languages/
  2. https://www.codeproject.com/Articles/696764/Differences-between-compiled-and-Interpreted-Langu

Pin Plotter – pin some markers on maps

Hi :)

Google maps is one of the most famous API for developer to work with maps. I worked on several projects in the intelligent transportation systems domain, analysis traffic data. Dealing with Google maps was one of essential things. Sometimes, I had to quickly plot points on the maps that reflect specific segments on highways, for that reason I developed a very simple tool to plot markers on the map based on Latitude and Longitude data. I like to make it open source and available so anyone can work on it on fly.

Oops, forgot to say, the tool is implemented based on HTML, CSS and JavaScript. You really don’t need to install anything, find it on my website:

https://mohanadkaleia.com/pinplotter

or find the open code on github:

https://github.com/mohanadkaleia/pin-plotter

 

Cross Compilation of QT/C++ application for Windows under Linux

السلام عليكم ورحمة الله

من المعروف أن لغة C++ هي من بين اللغات التي يمكن أن تعمل على مختلف أنظمة التشغيل .. والتي تسمى cross-platform language، حيث يمكنك ان تقوم بكتابة برنامج وبناءه ليعمل على نظام تشغيل Windows و Linux وحتى على الموبايل..

في هذه المقالة سأشرح كيف نقوم ببناء مشروع QT based application على نظام Ubuntu بحيث يعمل على نظام Windows

Read More

Const and constexpr in C++

In C++, there is two type of constant, a constant expression which can be determine at compilation time, and normal const which takes its value during running time, 

const int i = 20; // This is const expression ,

const int j = i; // This is const expression, 

const int k = getSize(); // This constant can't be constant expression because the value of getSize can't be detected else of running time

 

Note: in C++11 we can define a function to be const expression, but this function should be simple enough so the compiler can get its output during compilation

 

Mohanad Kaleia, 

C++ Primer

How to configure Ratchet with SSL

If you are using Apache web server (2.4 or above), enable these modules in httpd.conf file :

  1. mod_proxy.so
  2. mod_proxy_wstunnel.so

Add this setting to your httpd.conf file

ProxyPass /wss2/ ws://ratchet.mydomain.org:8888/

Use this URL in your JavaSscript call when you want a WSS connection:

var ws = new WebSocket("wss://ratchet.mydomain.org/wss2/NNN");

Restart Apache web server and make sure that your Ratchet worker (web socket connection) is open before applying the settings (telnet hostname port).

 

Source:

http://stackoverflow.com/questions/16979793/php-ratchet-websocket-ssl-connect

How to steup XAMP with MSSQL server

تحتاج للترجمة للعربية، ولكن جربتها وهي ناجحة:

المصدر:

http://samalpramod.blogspot.com/2014/03/connect-sql-server-2008-from-xampp.html

https://gist.github.com/mycodee/f1616d3ff7cecdf90fb9

 

Troubleshoot

1. ظهرت لي مشكلة بعد ان قمت بتضمين الملفات لم يعمل فكان الحل بتنصيب odbc نسخة 64 بت 

https://www.microsoft.com/en-us/download/details.aspx?id=36434

2. ظهرت مشكلة ثانية هي أن من سطر الأوامر يظهر أن تعليمة الاتصال مع قاعدة البيانات غير معرفة .. سبب المشكلة ان ملف الاعدادات php.ini الخاص بسطر الاوامر غيره المستخدم من قبل المتصفح .. الحل يجب إضافة ملف الاعدادات إلى متغيرات النظام system environment Path

 

كتاب أساسيات البرمجة التفرعية باستخدام معيار MPI

example 2-3

 

كلنا يعرف أهمية البرمجة التفرعية وكيف أصبحت ضرورة في كل برنامج نقوم بتطويره ليواكب التطور الحاصل في الهارد وير الموجود في حواسيبنا اليوم، يوجد عدة معايير مستخدمة في تفريع البرامج، ومنها يعتمد على التفريع على المعالج، ومنها يعتمد على استخدام المعالج الرسومي للتفريع..

أقدم لك عزيزي القارئ كتاب أساسيات البرمجة التفرعية باستخدام معيار MPI Message Passing Interface.. حيث قمت بإعادة كتابته وصياغته بحيث يكون بسيطاَ سهل القراءة والفهم، الكتاب ربما لا يغطي كافة المفاهيم ولكن يعطي أساسيات جيدة في هذا المعيار..

يمكنك التحميل من الرابط التالي: 

أساسيات البرمجة التفرعية باستخدام معيار MPI

 

MPI Programming

ساهم في هذا الكتاب:

م. تولاي شاهين

م. مهند شب قلعية

 

إخفاء الكيبورد في تطبيقات IOS

twitter-keyboard-100056244-large

 

هل بدآت بتعلم  برمجة IOS ..؟!! لابد وأنك واجهت مشكلة ان لوحة المفاتيح لا تختفي بشكل تلقائي عند النقر على زر Return.. نعم السبب انه اخفاءها يتم بشكل برمجي (يدوي) وليس افتراضي من نظام التشغيل.. لذلك سنتعلم اليوم كيفية اخفاء الكيبورد في نظام IOS

سنقوم الآن بإنشاء مشروع بسيط جداً بحيث نقوم بإخفاء الكيبورد بطريقتين الطريقة الأولى من خلال النقر على زر Return، والطريقة الثانية من خلال النقر على أي مكان فارغ بالشاشة.

Read More

Pages:123