العلم والقراءة

سماحة الشيخ أحمد بن حمد الخليلي –
من أهم ما يبني حياة الإنسان العلم ، فإن العلم له قدرٌ رفيع في حياة الناس بل جعل الله تعالى ميزة الإنسان هي العلم ولذلك ميّز به آدم وبيّن بالعلم مرتبته التي تقتضي أن يسجد له الملائكة قال الله سبحانه :«وَإِذْ قَالَ رَبُّكَ لِلْمَلَائِكَةِ إِنِّي جَاعِلٌ فِي الْأَرْضِ خَلِيفَةً قَالُوا أَتَجْعَلُ فِيهَا مَنْ يُفْسِدُ فِيهَا وَيَسْفِكُ الدِّمَاءَ وَنَحْنُ نُسَبِّحُ بِحَمْدِكَ وَنُقَدِّسُ لَكَ قَالَ إِنِّي أَعْلَمُ مَا لَا تَعْلَمُونَ، وَعَلَّمَ آَدَمَ الْأَسْمَاءَ كُلَّهَا ثُمَّ عَرَضَهُمْ عَلَى الْمَلَائِكَةِ فَقَالَ أَنْبِئُونِي بِأَسْمَاءِ هَؤُلَاءِ إِنْ كُنْتُمْ صَادِقِينَ، قَالُوا سُبْحَانَكَ لَا عِلْمَ لَنَا إِلَّا مَا عَلَّمْتَنَا إِنَّكَ أَنْتَ الْعَلِيمُ الْحَكِيمُ، قَالَ يَا آَدَمُ أَنْبِئْهُمْ بِأَسْمَائِهِمْ فَلَمَّا أَنْبَأَهُمْ بِأَسْمَائِهِمْ قَالَ أَلَمْ أَقُلْ لَكُمْ إِنِّي أَعْلَمُ غَيْبَ السَّمَاوَاتِ وَالْأَرْضِ وَأَعْلَمُ مَا تُبْدُونَ وَمَا كُنْتُمْ تَكْتُمُونَ» في هذا ما يدلنا على شرف العلم ولذلك يقول الله سبحانه وتعالى :« قُلْ هَلْ يَسْتَوِي الَّذِينَ يَعْلَمُونَ وَالَّذِينَ لَا يَعْلَمُونَ إِنَّمَا يَتَذَكَّرُ أُولُو الْأَلْبَابِ» ويقول الله سبحانه وتعالى :«يَرْفَعِ اللَّهُ الَّذِينَ آَمَنُوا مِنْكُمْ وَالَّذِينَ أُوتُوا الْعِلْمَ دَرَجَاتٍ» معنى ذلك أن الله تعالى يرفع المؤمنين درجة ويرفع الذين أوتوا العلم بجانب إيمانهم درجات وهو يختصهم برفعهم درجات.
ولا ريب أن هذا العلم الذي يرفع الله سبحانه وتعالى به مقامات عباده هو علمٌ يطلب من وسائله ومن أهم هذه الوسائل تثقيف النفس بالاطلاع على ما دوّنه المدوّنون وما أثّره المؤثّرون من أنواع العلوم فبهذا يرقى الإنسان درجات الخير ويكون بانياً حياته على ما ينفعها وعلى ما يصلحها.
ونجد في كتاب الله سبحانه وتعالى التنبيه على ذلك عندما خاطب الله عز وجل نبيه صلى الله عليه وسلم أول خطابه فقد صدّر هذا الخطاب بكلمة «اقرأ» وكلمة «اقرأ» لا تغني عنها أي كلمة أخرى إذ لا تسد مسدّها كلمة أخرى فإن القراءة إنما هي قراءة للمكتوب ولذلك لو قيل: «اعلم أو تنبّه أو تفضل أو أدرك أو افهم» أو نحو ذلك لما سدّت هذه الكلمات مسدّ كلمة «اقرأ» وأكد ذلك سبحانه وتعالى بقوله:« اقْرَأْ وَرَبُّكَ الْأَكْرَمُ ، الَّذِي عَلَّمَ بِالْقَلَمِ، عَلَّمَ الْإِنْسَانَ مَا لَمْ يَعْلَمْ » فذكر التعليم بالقلم والقلم هو وسيلة نقل العلم من جيل إلى جيل ومن أرض إلى أرض ومن أمة إلى أمة وفي هذا ما يدل على أهمية تثقيف النفس بالعلم وتدوين هذا العلم لأجل نشره ولأجل حفظه والله المستعان.

Advertisements

Ignore and Pause in C

I hate using non-standard code, and I also feel uneasy about telling someone to learn non-standard code. The reason is because this reduces the portability of code. Someone who uses non-standard code, have to learn new things every time they change their tools (i.e., OSs, compilers, IDEs, etc.).Unfortaunally some College teachers resolve to non-standard code to simplify thier lives. For some C programming instructors, use the library which is a library only available in Windows for a limited set of old compilers. This header file is used because it contains the getch function which basically causes the terminal screen to pause until the user hits the key.

The  standard alternative to getch function is getchar which can be used by including file. The problem with getchar is that it does not work if you use it after a previous call of scanf.  The reason is that a scanf does not remove the the end of lines in the input buffer which are  a result of a user hitting the key after each request of input. For getchar to work, you need to simply ignore what ever in the input buffer after each call to the scanf function before you call getchar. While C++ comes with a nice ignore method function, C unfortunately does not. However, it is not hard to code one by your self.

Here is my implementation of a an ignore function which I use after a scanf, and this helps me call getchar to do a proper and standard pause.

// FileName: area.c
// Compute the area of a cicle
// Shows the use of ignore and pause functions.

#include <stdio.h>
#include <math.h>

void ignore(int n, char delim)
// Pre : n is initialized to number of characters to ignore
//       delim is initialized to the some delimiter character
// Post: The function has extracts characters from the input sequence and
//       discards them, until either n characters have been extracted,
//       or one compares equal to delim.
{
    int count = 0;
    char c;
    while ((c = getchar()) != delim
        && !feof(stdin)
        && count != n)
        count++;
}

void pause()
// Pre : The input stream cin is empty.
// Post: The program has displayed a one-line message
//       beginning in column 1 and then paused.
//       The user has pressed <ENTER>.
{
    char returnChar;

    printf("Press <ENTER> to continue ... ");
    returnChar = getchar();
}

int main()
{
    const double PI = 3.14159265359;
    double r, area;

    printf("Enter radius: ");
    scanf("%lf", &r); ignore(80, '\n');

    area = PI * pow(r,2.0);

    printf("\nArea of a circle of radius %lf is %lf\n", r, PI);

    pause();

    return 0;
}

I hope you find this useful.

Creating A Local Maven repo from 3Rd party JARs

Sometimes you might need to package 3rd party JAR files in a way that allows you to incorporate them into a maven project easily.  To do so, you need to put the JARs in a local repository to so that the can be picked up by Apache maven. You can  achieve this by using the maven-install-plugin by running the following command:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

To illustrate this with an example, let us assume that we want to add the  Algorithms Book library to your local repository. You need download first the algs4.jar to your machine (i.e. ~/Downloads). Once you have done so, you can run the following command to add this file to your local repository.

mvn install:install-file -Dfile=~/Downloads/algs4.jar -DgroupId=edu.princeton.cs \
-DartifactId=algs4 -Dversion=1.0 -Dpackaging=jar

Once you added the jar file to the local repository. You can use the following XML in your project’s pom.xml.

<dependency>
	<groupId>edu.princeton.cs</groupId>
	<artifactId>algs4</artifactId>
	<version>1.0</version>
</dependency>

Happy Coding.

To 9/11 victims: You country is as Responsible as Saudi Arabia

The US Senate and House of Representatives recently approved a bill allowing the victims of 9/11 to sue Saudi Arabia for being backing the terrorists who were responsible for 9/11.

At the surface this might seems a noble cause, however, they forget that their own country is as responsible as Saudi Arabia. They seem to forget that their successive governments have long supported directorships in the Middle East and Islamic World. Dictatorship regeimes in countries like Egypt, Saudi Arabia, Jordan, and Pakistan have long enjoyed the support of the USA which has condoned the oppressions of such regimes. Such oppressions resulted in the rebellion of certain individuals like Osama Bin Laden who ended up establishing an Al Qaeda The victims of 9/11 also seems to forget that their own country has funded Al Qaeda and helped in establishing it during the Afghanistan war against the Soviet Union.

It is a bit ironic that the victims of country whose government is responsible the biggest atrocities in the 21st centenary. The USA government repeatedly lied to make the case for invading Iraq in 2003 which has results in the destruction of Iraq. Not only this, but they let the country to be taken extremist groups like Al Qaeda and later on Daesh.

Somehow the Americans think that they have the moral high ground when it comes to the war on terror. Yet, their government is stained with the blood of innocent victims who died because of the wars that of the USA in the Middle East.

If you really want to seek justice, you should then start at your own backyard and sue your own government.

Opening Up a port on RedHat

By default RedHat comes with strict configuration for protecting you from hackers. If you want to open up certain ports for network traffic you will need to use iptables command.  Here is how you might open tcp port 3030 for network traffic


$ sudo iptables -I INPUT -p tcp -m tcp --dport 3030 -j ACCEPT
$ sudo service iptables save # saves rules to /etc/sysconfig/iptables

Alternatively you can use  firewall tui tool


$ sudo system-config-firewall-tui

Replacing URIs with labels in RDF object fields using sparql

Here is how it is done with an example from Linked Movie Database

prefix movie: <http://data.linkedmdb.org/resource/movie/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

select ?s ?p ?o
WHERE {
    {
       <http://data.linkedmdb.org/resource/director/102> ?p ?o1 .
       optional {?o1 rdfs:label ?o.}
       BIND (<http://data.linkedmdb.org/resource/director/102> as ?s)
       FILTER(bound(?o))
    }
    UNION
    {
       <http://data.linkedmdb.org/resource/director/102> ?p ?o .
       optional {?o rdfs:label ?label.}
       BIND (<http://data.linkedmdb.org/resource/director/102> as ?s)
       FILTER(!bound(?label))
    }
}
order by ?p
limit 25

Females in DBPedia

Here is a simple SPARQL query to list all females in DBPedia

SELECT ?property ?hasValue ?isValueOf
WHERE {
  { <http://dbpedia.org/ontology/Person> ?property ?hasValue }
  UNION
  {
       ?isValueOf ?property <http://dbpedia.org/ontology/Person> .
       ?isValueOf <http://dbpedia.org/property/gender> ?gender .
       FILTER regex(?gender, "female", "i")
  }
}