<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ahmed Khaled MOhamed</title>
    <description>The latest articles on DEV Community by Ahmed Khaled MOhamed (@aaahmedaa).</description>
    <link>https://dev.to/aaahmedaa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F33371%2Ff855a88a-e4e8-42a3-933a-c3f98ce03b49.PNG</url>
      <title>DEV Community: Ahmed Khaled MOhamed</title>
      <link>https://dev.to/aaahmedaa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aaahmedaa"/>
    <language>en</language>
    <item>
      <title>Deploy Sylius to Heroku</title>
      <dc:creator>Ahmed Khaled MOhamed</dc:creator>
      <pubDate>Fri, 19 Nov 2021 12:38:46 +0000</pubDate>
      <link>https://dev.to/aaahmedaa/deploy-sylius-to-heroku-55p1</link>
      <guid>https://dev.to/aaahmedaa/deploy-sylius-to-heroku-55p1</guid>
      <description>&lt;p&gt;In this blog we are going to deploy sylius store to heroku, First you need to know that sylius will need php, node, mysql environments to load and build assets for our store so long story short we will install new app and add two buildpacks &lt;code&gt;heroku/php&lt;/code&gt; and &lt;code&gt;heroku/nodejs&lt;/code&gt; and will add add-on &lt;a href="https://elements.heroku.com/addons/jawsdb"&gt;JawsDb&lt;/a&gt; for database storage and make some &lt;code&gt;nginx&lt;/code&gt; and edit &lt;code&gt;composer.json&lt;/code&gt; to make the project runnable by heroku.&lt;/p&gt;

&lt;h3&gt;
  
  
  You should know
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;heroku will look for the required php version from the &lt;code&gt;composer.json&lt;/code&gt; and will look for &lt;code&gt;compile script&lt;/code&gt; to run the project.&lt;/li&gt;
&lt;li&gt;sylius database is too big for the free version on &lt;code&gt;Jawsdb&lt;/code&gt; so feel free to choose your package the &lt;code&gt;10$&lt;/code&gt; done the job for me.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;get A fresh copy of sylius &lt;a href="https://docs.sylius.com/en/latest/book/installation/installation.html"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;navigate to your sylius project dir and init new heroku app using the cli&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ heroku create APP_NAME
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;we need to add &lt;code&gt;heroku/php&lt;/code&gt; and &lt;code&gt;heroku/node&lt;/code&gt; &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ heroku buildpacks:set heroku/php --app APP_NAME
$ heroku buildpacks:set heroku/nodejs --app APP_NAME
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;OR&lt;/code&gt; you can navigate to settings and under buildpack add &lt;code&gt;php&lt;/code&gt; and &lt;code&gt;nodeJs&lt;/code&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;add the Jawsweb database then set &lt;code&gt;APP_END=prod&lt;/code&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ heroku addons:create jawsdb --app APP_NAME # This command will also add a new env JAWSDB_URL
$ heroku config:set APP_END=prod --app APP_NAME
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;create &lt;code&gt;Procfile&lt;/code&gt; in your root directory and add this content &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;web: heroku-php-nginx -C nginx_app.conf public/
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;create nginx config file &lt;code&gt;nginx_app.conf&lt;/code&gt; in the root directory&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;location / {
    # try to serve file directly, fallback to rewrite
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    # rewrite all to index.php
    rewrite ^(.*)$ /index.php/$1 last;
}

location ~ ^/index\.php(/|$) {
    try_files @heroku-fcgi @heroku-fcgi;
    # ensure that /index.php isn't accessible directly, but only through a rewrite 
internal;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;we need to make some changes to our &lt;code&gt;composer.json&lt;/code&gt; so heroku can run sylius install and build scripts&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    "scripts": {
        "compile": [
            "@php bin/console sylius:install --no-interaction --fixture-suite=default"
        ],
        "post-create-project-cmd": [
            "@php bin/console sylius:inform-about-gus --ansi",
            "@php bin/console sylius:show-available-plugins --ansi"
        ],
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="https://github.com/aa-ahmed-aa/SyliusToHeroku/blob/master/composer.json#L88-L99"&gt;Snippet Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and under &lt;code&gt;require&lt;/code&gt; section add to enable this php extension on the heroku app&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"ext-intl": "*"
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;then run&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ composer update 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;do not forget to remove &lt;code&gt;composer.lock&lt;/code&gt; from &lt;code&gt;.gitignore&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;to the &lt;code&gt;package.json&lt;/code&gt; file add this block to specify node and yarn versions&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"engines": {
    "node": "14.x",
    "yarn": "1.x"
},
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;to make the server prod logs appear in the instance logs edit &lt;code&gt;/conig/packages/prod/monolog.yaml&lt;/code&gt; with content&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;monolog:
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            handler: nested
            excluded_http_codes: [404, 405]
        nested:
            type: stream
            path: "php://stderr"
            level: debug
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;remove the &lt;code&gt;.env&lt;/code&gt; file from &lt;code&gt;.gitignore&lt;/code&gt; and make sure it contain these two envs reading from global env&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;APP_ENV=${APP_END}
DATABASE_URL=${JAWSDB_URL}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;we will create a repo on github and make heroku deploy from github so &lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git init
$ git remote add origin &amp;lt;github_remote_url&amp;gt;
$ git add .
$ git commit -am "init commit"
$ git push origin master
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;then go to the app heroku app to the &lt;code&gt;Deploy&lt;/code&gt; tab then select &lt;code&gt;Github&lt;/code&gt; from &lt;code&gt;Deployment method&lt;/code&gt; then choose your repository and the branch to deploy then click on the &lt;code&gt;Deploy Branch&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the &lt;code&gt;open app&lt;/code&gt; and you just deployed your first sylius store to heroku.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Referenceies
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://devcenter.heroku.com/articles/jawsdb#provisioning-the-add-on"&gt;Jawsdb mysql&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-php"&gt;PHP buildpack&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-nodejs"&gt;NodeJs Apps on heroku&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devcenter.heroku.com/articles/custom-php-settings"&gt;Customize nginx and php&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.sylius.com/en/1.9/getting-started-with-sylius/installation.html"&gt;Install sylius&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devcenter.heroku.com/articles/deploying-symfony4#logging"&gt;Symfony logs to the instance logs&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>php</category>
      <category>commerce</category>
      <category>symfony</category>
      <category>sylius</category>
    </item>
    <item>
      <title>Slack Status Setter🔮</title>
      <dc:creator>Ahmed Khaled MOhamed</dc:creator>
      <pubDate>Sat, 28 Mar 2020 16:21:29 +0000</pubDate>
      <link>https://dev.to/aaahmedaa/slack-status-setter-iln</link>
      <guid>https://dev.to/aaahmedaa/slack-status-setter-iln</guid>
      <description>&lt;p&gt;You can find the repo on &lt;a href="https://github.com/aa-ahmed-aa/SlackSS"&gt;SlackSS&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Slack Status Setter (SSS) 🤖
&lt;/h1&gt;

&lt;p&gt;It will update your slack status according to your actual presence in front of your camera every 10 minutes Follow the Docs to customize this project &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Thanks to face detector on this repo : &lt;a href="https://github.com/WebDevSimplified/Face-Detection-JavaScript"&gt;Face-Detection-JavaScript&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Installation  👀
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;open &lt;code&gt;https://api.slack.com/legacy/custom-integrations/legacy-tokens&lt;/code&gt; and under &lt;code&gt;Legacy information&lt;/code&gt; you can find your token.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;open &lt;code&gt;script.js&lt;/code&gt; and replace &lt;code&gt;&amp;lt;API_TOKEN&amp;gt;&lt;/code&gt; with your slack legacy token.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;default time interval for updating slack status is 10 minuts if you want to change that you can change the value of &lt;code&gt;time_fraction&lt;/code&gt; in &lt;code&gt;script.js&lt;/code&gt; file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;open this app in your browser and every 10 minuts it will update your slack status according to your current presence.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>slack</category>
      <category>javascript</category>
      <category>facedetection</category>
    </item>
    <item>
      <title>Your guide to Docker &amp; Kubernetes 🐳</title>
      <dc:creator>Ahmed Khaled MOhamed</dc:creator>
      <pubDate>Thu, 26 Mar 2020 18:44:32 +0000</pubDate>
      <link>https://dev.to/aaahmedaa/your-guide-to-docker-kubernetes-4162</link>
      <guid>https://dev.to/aaahmedaa/your-guide-to-docker-kubernetes-4162</guid>
      <description>&lt;p&gt;This blog post contains docker examples on GitHub 👑 &lt;br&gt; &lt;a href="https://github.com/aa-ahmed-aa/Docker-Kubernetes"&gt;https://github.com/aa-ahmed-aa/Docker-Kubernetes&lt;/a&gt; &lt;br&gt;&lt;br&gt;
&lt;br&gt; You can find this blog here 📫&lt;br&gt;
&lt;a href="https://www.notion.so/Docker-Kubernetes-0181ef3069964e7b8848fae8cc18c7e0"&gt;https://www.notion.so/Docker-Kubernetes-0181ef3069964e7b8848fae8cc18c7e0&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>kubernetes</category>
      <category>architecture</category>
      <category>anonymous</category>
    </item>
    <item>
      <title>Driven development </title>
      <dc:creator>Ahmed Khaled MOhamed</dc:creator>
      <pubDate>Sat, 08 Jun 2019 09:03:42 +0000</pubDate>
      <link>https://dev.to/aaahmedaa/driven-development-5f0g</link>
      <guid>https://dev.to/aaahmedaa/driven-development-5f0g</guid>
      <description>&lt;p&gt;if you have been in the scenario of translating business needs into an actual feature and wanted to go the right way of implementing this, I think this blog is for you.&lt;br&gt;
in this blog, I talk about TDD / BDD / DDD in-details.&lt;br&gt;
Read More: &lt;a href="https://aa-ahmed-aa.github.io/Driven-Development/"&gt;https://aa-ahmed-aa.github.io/Driven-Development/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>designpatterns</category>
      <category>testing</category>
    </item>
    <item>
      <title>Design patterns 101</title>
      <dc:creator>Ahmed Khaled MOhamed</dc:creator>
      <pubDate>Fri, 15 Mar 2019 07:57:48 +0000</pubDate>
      <link>https://dev.to/aaahmedaa/design-patterns-101-4hjk</link>
      <guid>https://dev.to/aaahmedaa/design-patterns-101-4hjk</guid>
      <description>&lt;p&gt;You can find the main blog at &lt;a href="https://aa-ahmed-aa.github.io/design-patterns-101/"&gt;https://aa-ahmed-aa.github.io/design-patterns-101/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Table of Content
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Who is this blog for&lt;/li&gt;
&lt;li&gt;Before you start&lt;/li&gt;
&lt;li&gt;Quick Review

&lt;ol&gt;
&lt;li&gt;S.O.L.I.D&lt;/li&gt;
&lt;li&gt;Dependency injection&lt;/li&gt;
&lt;li&gt;Composition and Aggregation&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Design Patterns&lt;/li&gt;
&lt;li&gt;Patterns in the real world&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Who is this blog for
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;if you want to be a better programmer (reading others code - enhancing your skills).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;if you are repeating yourself when you write code (unintentionally).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;those who think design pattern is a black box and can't really know what is a design pattern.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;sometimes you see snippet of code that you don't understand in programming language &lt;br&gt;
that you have experience with and you wonder why is this code designed this way.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Before you start
&lt;/h2&gt;

&lt;p&gt;This blog is a brief of 14 design pattern in Head first design pattern, &lt;br&gt;
so to get the biggest benefit of this blog,&lt;br&gt;
i recommend you follow these steps :-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read the pattern definition.&lt;/li&gt;
&lt;li&gt;Understand the problem introduced and try to imagine it in bigger scale.&lt;/li&gt;
&lt;li&gt;Read the UML.&lt;/li&gt;
&lt;li&gt;Trace the code example.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two important things you need to know before we go further :-&lt;/p&gt;
&lt;h4&gt;
  
  
  First
&lt;/h4&gt;

&lt;p&gt;Design pattern is just a clean way to solve a problem also provides flexibility to your code,so do not enhance any pattern until you make sure that this enhancement is successful applied by the SOLID (we will come to this later), so you can consider solid as your brakes that will stops your fantasy from pattern violation.&lt;/p&gt;
&lt;h4&gt;
  
  
  Second
&lt;/h4&gt;

&lt;p&gt;Patterns are not used separately from each others at the end of this blog you can use many patterns together like you will see in MVC.&lt;/p&gt;

&lt;p&gt;This blog is based on &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern"&gt;this repo&lt;/a&gt; &lt;br&gt;
so go ahead and star it.&lt;/p&gt;


&lt;h2&gt;
  
  
  Quick Review
&lt;/h2&gt;
&lt;h3&gt;
  
  
  S.O.L.I.D
&lt;/h3&gt;

&lt;p&gt;every letter stands for a specific word with a specific concepts so let's get started right away.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h4&gt;
  
  
  S - Single-responsiblity principle
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;A class should have one and only one reason to change, meaning that a class should have only one job.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  O - Open-closed principle
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Objects or entities should be open for extension, but closed for modification.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  L - Liskov substitution principle
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  I - Interface segregation principle
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;A client should never be forced to implement an interface that it doesn't use or clients shouldn't be forced to depend on methods they do not use.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  D - Dependency Inversion Principle
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Entities must depend on abstractions not on concretions. It states that the high level module must not depend on the low level module, but they should depend on abstractions.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Note : you can find more information about solid and code examples &lt;a href="https://scotch.io/bar-talk/s-o-l-i-d-the-first-five-principles-of-object-oriented-design"&gt;Here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Dependency injection
&lt;/h3&gt;

&lt;p&gt;we use this technique to provide more functionality to an object from another dependent objects.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

&lt;p&gt;here we injected class A to class B.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;A&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"Hello from A Class"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;B&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$A&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;A&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;A&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;showFromA&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;A&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;show&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;$b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;B&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nv"&gt;$b&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;showFromA&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Composition and Aggregation
&lt;/h3&gt;

&lt;p&gt;Composition is effectively an ownership relationship, while aggregation is a “contains” relationship. In composition, the parts can not exist outside the thing that contains them, but individual things can exist on their own as unique entities in aggregation.&lt;/p&gt;

&lt;h4&gt;
  
  
  in order to keep this blog short and sticky to the point i recommend you read this short blog &lt;a href="https://www.brainbell.com/tutorials/php/abstract-interface-composition-aggregation.html"&gt;Composition and aggregation&lt;/a&gt;
&lt;/h4&gt;

&lt;h2&gt;
  
  
  Design Patterns
&lt;/h2&gt;

&lt;p&gt;follow the link of every pattern to see pattern definition, UML, and code examples&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Do not forget to trace the code this is the most important step to get familiar with the pattern&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/Strategy%20pattern"&gt;Strategy pattern&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Defines a family of algorithms ,encapsulates each one and makes them interchangable. strategy lets the algorithm vary independently&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/Observer%20pattern"&gt;Observer Pattern (Keeping your objects in the know) &lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;you may see this pattern used alot in the front-end framework because it needs to eep track of data synced to the UI.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/Decorator%20pattern"&gt;Decorator Pattern (Decorating Objects) &lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Decorators provide a flexibile alternative to subclassing extending functionality.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/Factory%20pattern"&gt;Factory Pattern (Backing with oo Goodness)&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Factory pattern divided into two main types (Factory method and Abstract factory), In this pattern i will focus on the difference between the two subset patterns and will code only the factory method.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Check the difference between &lt;strong&gt;Abstract Factory&lt;/strong&gt; and &lt;strong&gt;Factory Method&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/Singleton%20pattern"&gt;Singleton Pattern (One of a kind object)&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Ensure that a class has one instance and provide a global point of access to it ,we can say that this pattern is our ticket to creating one-of-a-kind objects for which there is only one instance.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/Command%20pattern"&gt;Command Pattern (Encapsulating Invocation)&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Encapsulates a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/Adapter%20pattern"&gt;Adapter Pattern&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Convert the interface of a class into another interface clients expect.let's classes work together that couldn't otherwise because of incompatible interfaces.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Check the two adapter types &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/Facade%20pattern"&gt;Facade Pattern&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Provides a unified interface to a set of interfaces in a subsystem facade defines a higher-level interface that makes the subsystem easier to use.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/Template%20Method%20pattern"&gt;Template Method Pattern (Encapsulating Algorithms)&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Define the skeleton of an algorithm in an operation, deferring some steps to subclasses.Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/Iterator%20pattern"&gt;Iterator Pattern&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Provide a way to access of an aggregation object sequentially without exposing it's underlying representation.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/Composite%20pattern"&gt;Composite Pattern&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Compose objects into tree structured to request part whole hierarchies, Composite let's clients treat individual objects and compositions of objects uniformly.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/Proxy%20pattern"&gt;Proxy Pattern&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Provide a surrogate or placeholder for another object to control access to it&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/tree/master/State%20pattern"&gt;State Pattern&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Allow an object to alter its behavior when its internal state changes the object will appear to change its class.&lt;/p&gt;

&lt;h2&gt;
  
  
  Patterns in the real world
&lt;/h2&gt;

&lt;p&gt;Categorizing patterns will help us understand the difference between patterns and also will help us memorizing them.&lt;/p&gt;

&lt;h4&gt;
  
  
  Categorize patterns as (Structural - Behavioural - Creational)
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;h4&gt;
  
  
  Structural
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Decorator - Composite - Proxy - Facade - Adapter&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Behavioural
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Template Method - Iterator - Command - Observer - State - Strategy&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Creational
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Singleton - Abstract Factory - Factory Method&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Categorize patterns that deals with (Class - Object)
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;h4&gt;
  
  
  Class
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Template Method - Adapter - Factory Method&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Object
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Command - Decorator - Proxy - Composite - Facade - Iterator - Observer - Strategy - Singleton - State - Abstract Method &lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Thinking in pattern
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Keep it simple (KISS)
&lt;/h5&gt;

&lt;p&gt;solve things in the simplest way possible, your goal should be simplicity, not "how should i apply a pattern".&lt;/p&gt;

&lt;h5&gt;
  
  
  Design patterns aren't a magic bullet; in fact, they're not even a bullet!
&lt;/h5&gt;

&lt;p&gt;patterns aren't a magic bullet you can't plug one in, compile and then take an early lunch, to use patterns , you also need to think of the consequences for the rest of your design.&lt;/p&gt;

&lt;h5&gt;
  
  
  You know you need a pattern when...
&lt;/h5&gt;

&lt;p&gt;once you're sure a simple solution will not meet your needs, you should consider the problem &lt;br&gt;
along with the set of constraints under which the solution will need to operate- these will help you match your problem to a pattern.&lt;/p&gt;

&lt;p&gt;if you have any question please open an issue with your question on the github repo &lt;a href="https://github.com/aa-ahmed-aa/Design_Pattern/issues"&gt;Here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>designpatterns</category>
      <category>php</category>
    </item>
    <item>
      <title>Zeta offline judge</title>
      <dc:creator>Ahmed Khaled MOhamed</dc:creator>
      <pubDate>Sun, 16 Dec 2018 13:24:53 +0000</pubDate>
      <link>https://dev.to/aaahmedaa/zeta-offline-judge-11bn</link>
      <guid>https://dev.to/aaahmedaa/zeta-offline-judge-11bn</guid>
      <description>&lt;p&gt;Zeta 🐉 is an offline judge for programming contests 🏆.
&lt;br&gt;Githup link : &lt;a href="https://github.com/aa-ahmed-aa/Zeta" rel="noopener noreferrer"&gt;https://github.com/aa-ahmed-aa/Zeta&lt;/a&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h2&gt;
💂 Features&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Contestants auto ranking.&lt;/li&gt;
&lt;li&gt;Can add clarifications for problems.&lt;/li&gt;
&lt;li&gt;Auto judging for c/c++ solutions (java comming soon).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
🚩 Judging and Ranking&lt;/h2&gt;
&lt;h4&gt;
📌 Judging&lt;/h4&gt;
&lt;p&gt;after judging a problem the contestant can get one of 4 responses :- &lt;br&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;AC =&amp;gt; ACCEPTED&lt;/li&gt;
&lt;li&gt;WA =&amp;gt; WRONG ANSWER&lt;/li&gt;
&lt;li&gt;TLE =&amp;gt; TIME LIMIT EXCEEDED&lt;/li&gt;
&lt;li&gt;CE =&amp;gt; COMPILER ERROR&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/aa-ahmed-aa/Zeta/blob/master/screenshots/judge.PNG"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Faa-ahmed-aa%2FZeta%2Fraw%2Fmaster%2Fscreenshots%2Fjudge.PNG" alt="Alt text" title="Judge"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;green judge mean it is recommended to use this type of judging for this submmition&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Automatic 🆚 Manual Judging
&lt;ul&gt;
&lt;li&gt;Automatic judging
It will run the contestant solution and compare it with the testcases given to that problem and respond to that user submition .
&lt;/li&gt;
&lt;li&gt;Manual Judging
Adding the response manually to this submition because Sometimes users didn't follow the rules of the contest and read or write from i/o Stream Not File.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
🚖 Ranking&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Submition rank 
Submition are ranked according to time and problem rank so the ranking equation is :- 
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span&gt;                                                     &lt;span&gt;Tstart&lt;/span&gt; &lt;span&gt;-&lt;/span&gt; &lt;span&gt;Tsub&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;       &lt;span&gt;submition_rank&lt;/span&gt; &lt;span&gt;=&lt;/span&gt;   &lt;span&gt;problem_rank&lt;/span&gt;    &lt;span&gt;-&lt;/span&gt;    &lt;span&gt;_________________________&lt;/span&gt;    &lt;span&gt;-&lt;/span&gt;    (    &lt;span&gt;wrongAnswerCount&lt;/span&gt;   &lt;span&gt;*&lt;/span&gt;   &lt;span&gt;5&lt;/span&gt;    )&lt;/span&gt;
&lt;span&gt;                                                           &lt;span&gt;60&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;       &lt;span&gt;Minimum&lt;/span&gt; &lt;span&gt;Submmition&lt;/span&gt; &lt;span&gt;Rank&lt;/span&gt; &lt;span&gt;is&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; &lt;span&gt;40&lt;/span&gt;&lt;span&gt;%&lt;/span&gt; &lt;span&gt;Of&lt;/span&gt; &lt;span&gt;problem&lt;/span&gt; &lt;span&gt;rank&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;User rank &lt;br&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Users are ranked according to the highest sum of the ACCEPTED problems rank.&lt;/li&gt;
&lt;li&gt;Scoreboard Time is the time of the user last submition.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/aa-ahmed-aa/Zeta/blob/master/screenshots/scoreboard.PNG"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Faa-ahmed-aa%2FZeta%2Fraw%2Fmaster%2Fscreenshots%2Fscoreboard.PNG" alt="Alt text" title="Judge"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Time is the Time of the user last Submmition&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
🚀 PreRequirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;xampp ( if you have any problem with the calss named String it is according to PHP version read this to fix the problem : &lt;a href="https://github.com/cakephp/cakephp/issues/7573" rel="noopener noreferrer"&gt;https://github.com/cakephp/cakephp/issues/7573&lt;/a&gt; )&lt;/li&gt;
&lt;li&gt;GCC Compiler ( i used &lt;a href="https://nuwen.net/mingw.html" rel="nofollow noopener noreferrer"&gt;Mingw&lt;/a&gt; )&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
🔥 Installation&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Download the Repo &lt;code&gt;git clone https://github.com/aa-ahmed-aa/Zeta&lt;/code&gt; or via the download button.&lt;/li&gt;
&lt;li&gt;Import the database file in the &lt;code&gt;Database/zeta_4.sql&lt;/code&gt; to phpmyadmin.&lt;/li&gt;
&lt;li&gt;Go to &lt;code&gt;app/Config/database.php&lt;/code&gt; and update username and password to your credential&lt;/li&gt;
&lt;li&gt;Download &lt;a href="https://nuwen.net/mingw.html" rel="nofollow noopener noreferrer"&gt;Mingw&lt;/a&gt; compiler and copy it to your Zeta path.&lt;/li&gt;
&lt;li&gt;Now Goto &lt;a href="http://localhost/Zeta" rel="nofollow noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="http://localhost/Zeta" rel="nofollow noopener noreferrer"&gt;http://localhost/Zeta&lt;/a&gt; and user username : ahmedkhaled, password : ahmedkhaled123 to login (this is the default admin account you can use it to add other admins and contestant then delete it later)&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;h1&gt;
Before starting a contest you should go to Settings and set the starting time of the contest this time is used to ranks problems and contestant in the scoreboard&lt;/h1&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
🚧 Contribution&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Compilation and Running is based on this package (&lt;a href="https://github.com/aa-ahmed-aa/Dorm" rel="noopener noreferrer"&gt;DORM&lt;/a&gt;) so feel free to have a look.&lt;br&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If you find any problem feel free to open issues with any error you find or features you think we can add to Zeta, if you have any problem while you are installing zeta please feel free to contact me at &lt;strong&gt;&lt;a href="mailto:ahmedkhaled36@hotmail.com"&gt;ahmedkhaled36@hotmail.com&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;

&lt;/h2&gt;

</description>
      <category>php</category>
      <category>computerscience</category>
      <category>challenge</category>
      <category>programmingcontests</category>
    </item>
    <item>
      <title>Dorm introducing multi-compiler package 🏄 for php</title>
      <dc:creator>Ahmed Khaled MOhamed</dc:creator>
      <pubDate>Wed, 25 Jul 2018 10:11:21 +0000</pubDate>
      <link>https://dev.to/aaahmedaa/dorm-introducing-multi-compiler-package--for-php-15m6</link>
      <guid>https://dev.to/aaahmedaa/dorm-introducing-multi-compiler-package--for-php-15m6</guid>
      <description>

&lt;p&gt;Dorm is a multi compiler package designed to handle compilation and running of non-php code in your project, now the package support compilation and running of c, c++, python2, python3 and java.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing compilers and setting things up
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Compilers
&lt;/h4&gt;

&lt;p&gt;C        ======&amp;gt; GCC compiler&lt;br&gt;
C++      ======&amp;gt; G++ compiler&lt;br&gt;
Java     ======&amp;gt; JDK &lt;br&gt;
Python   ======&amp;gt; Python2.7 or Python 3.4 (configure it with python2 or python3 according to your needs).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nuwen.net/mingw.html"&gt;MinGw&lt;/a&gt; contains g++/gcc compilers &lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html"&gt;Java SE Development Kit&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.python.org/getit/"&gt;Python&lt;/a&gt; you can download any version python2.7 or python3.4.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;default paths are :-&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="s"&gt;"cpp"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;'C:/MinGW/bin/g++.exe'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s"&gt;"c"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;'C:/MinGW/bin/gcc.exe'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s"&gt;"java"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;'javac'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s"&gt;"python2"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;'C:/Python27/python2.exe'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s"&gt;"python3"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;'C:/Python34/python3.exe'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and configure it's paths in the &lt;code&gt;vendor/aa-ahmed-aa/dorm/src/Config.php&lt;/code&gt; for &lt;br&gt;
every compiler the default for &lt;/p&gt;

&lt;h2&gt;
  
  
  Install Dorm
&lt;/h2&gt;

&lt;p&gt;install the package using composer &lt;code&gt;composer require aa-ahmed-aa/dorm&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Compiler and run some code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This code will compile and run C++ code&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;require&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'vendor/autoload.php'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nx"&gt;Ahmedkhd\Dorm\Dorm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Dorm&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;//set compilation path&lt;/span&gt;
&lt;span class="nv"&gt;$obj&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;setCompilationPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;__DIR__&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nv"&gt;$cpp_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;&amp;lt;&amp;lt;&amp;lt;'EOT'
    #include&amp;lt;iostream&amp;gt;
    using namespace std;

    int main()
    {
        cout&amp;lt;&amp;lt;"hello, c plus plus";
        return 0;
                }
EOT;
&lt;/span&gt;
&lt;span class="nv"&gt;$comp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$obj&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$cpp_code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"cpp"&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Compilation : "&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nb"&gt;is_array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$comp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;"Success"&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Fail"&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Running is : "&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nb"&gt;is_array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$comp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nv"&gt;$obj&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Fail"&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This code will compile and run Java code&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;require&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'vendor/autoload.php'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nx"&gt;Ahmedkhd\Dorm\Dorm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Dorm&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;//set compilation path&lt;/span&gt;
&lt;span class="nv"&gt;$obj&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;setCompilationPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;__DIR__&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//java&lt;/span&gt;
&lt;span class="nv"&gt;$java_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;&amp;lt;&amp;lt;&amp;lt;'EOT'
    public class Main {
    public static void main(String[] args) {
        // Prints "Hello, World" to the terminal window.
        System.out.println("Hello, Java");
    }

}
EOT;
&lt;/span&gt;

&lt;span class="nv"&gt;$comp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$obj&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$java_code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"java"&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Compilation : "&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nb"&gt;is_array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$comp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;"Success"&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Fail"&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Running is : "&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nb"&gt;is_array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$comp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nv"&gt;$obj&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Fail"&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This will compile and run python code&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;require&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'vendor/autoload.php'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nx"&gt;Ahmedkhd\Dorm\Dorm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Dorm&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;//set compilation path&lt;/span&gt;
&lt;span class="nv"&gt;$obj&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;setCompilationPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;__DIR__&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nv"&gt;$python_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;&amp;lt;&amp;lt;&amp;lt;'EOT'
print "Hello, Python3.4"
EOT;
&lt;/span&gt;
&lt;span class="nv"&gt;$comp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$obj&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$python_code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"python2"&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Running : "&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;implode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$comp&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Adding you own Compiler
&lt;/h2&gt;

&lt;p&gt;After installing your own compiler you need to go to &lt;code&gt;vendor/aa-ahmed-aa/dorm/src/Config.php&lt;/code&gt;&lt;br&gt;
and add your compiler to the &lt;code&gt;$compilers&lt;/code&gt; array. &lt;br&gt;&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$compilers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"__COMPILER_NAME__"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"path"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"__COMPILER_PATH__"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"file_extension"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s1"&gt;'__CODE_FILE_EXTENSION_'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"compile_func"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;__NAME_FOR_YOUR_COMPILER_FUNCTION__&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"run_func"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;__NAME_FOR_YOUR_RUN_FUNCTION__&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;path =&amp;gt; is the path of your compiler or (alias_name in sys env).&lt;br&gt;
file_extension =&amp;gt; the extensions of files this compiler uses.&lt;br&gt;
compile_func =&amp;gt; compilation function in the &lt;code&gt;vendor/aa-ahmed-aa/dorm/src/Core.php&lt;/code&gt;.&lt;br&gt;
run_func =&amp;gt; run function in the &lt;code&gt;vendor/aa-ahmed-aa/dorm/src/Core.php&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then you need to go to you &lt;code&gt;vendor/aa-ahmed-aa/dorm/src/Core.php&lt;/code&gt; and implement your compilation and running for this type of compilers after than you only need to use compile and run for any type of compilers.&lt;/p&gt;

&lt;h4&gt;
  
  
  Useful Function
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;setCompiler&lt;/li&gt;
&lt;li&gt;getCompiler&lt;/li&gt;
&lt;li&gt;setCompilationPath&lt;/li&gt;
&lt;li&gt;getCompilationPath&lt;/li&gt;
&lt;li&gt;createFolderIfNotExisted&lt;/li&gt;
&lt;li&gt;cleanCompilationFolder&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Support
&lt;/h2&gt;

&lt;p&gt;If you find any problem with this package feel free to open an issue or contact me at &lt;a href="mailto:ahmedkhaled36@hotmail.com"&gt;ahmedkhaled36@hotmail.com&lt;/a&gt;&lt;br&gt;
Github 🔥 : &lt;a href="https://github.com/aa-ahmed-aa/Dorm"&gt;https://github.com/aa-ahmed-aa/Dorm&lt;/a&gt; &lt;/p&gt;


</description>
      <category>php</category>
      <category>python</category>
      <category>java</category>
      <category>cc</category>
    </item>
    <item>
      <title>Difference between Heredoc and Nowdoc 🤔</title>
      <dc:creator>Ahmed Khaled MOhamed</dc:creator>
      <pubDate>Fri, 27 Apr 2018 12:31:16 +0000</pubDate>
      <link>https://dev.to/aaahmedaa/difference-between-heredoc-and-nowdoc--2p9e</link>
      <guid>https://dev.to/aaahmedaa/difference-between-heredoc-and-nowdoc--2p9e</guid>
      <description>

&lt;h3&gt;
  
  
  Heredoc
&lt;/h3&gt;

&lt;p&gt;heredoc will evaluate your variables and place them exactly where you placed in the string.&lt;br&gt;
Example:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
$name = "Ahmed Khaled";

$here_doc = &amp;lt;&amp;lt;&amp;lt;EOT
My name is "$name" and 
i love programming

EOT;

echo $here_doc;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;My name is "Ahmed Khaled" and 
i love programming
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Nowdoc
&lt;/h3&gt;

&lt;p&gt;nowdoc will never evaluates your variables in the string &lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
$name = "Ahmed Khaled";

$here_doc = &amp;lt;&amp;lt;&amp;lt;'EOT'
My name is "$name" and 
i love programming

EOT;

echo $here_doc;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;My name is "$name" and 
i love programming
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;




</description>
      <category>php</category>
      <category>stringparsing</category>
      <category>strings</category>
    </item>
    <item>
      <title>My Git Hot Commands</title>
      <dc:creator>Ahmed Khaled MOhamed</dc:creator>
      <pubDate>Wed, 14 Feb 2018 21:36:08 +0000</pubDate>
      <link>https://dev.to/aaahmedaa/my-git-hot-commands--49gn</link>
      <guid>https://dev.to/aaahmedaa/my-git-hot-commands--49gn</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foea99akwtqg6bgzfj4pv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foea99akwtqg6bgzfj4pv.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;1--&lt;code&gt;git log --pretty=format: --name-only --author="aa-ahmed-aa" --since="2 days ago" | sort | uniq&lt;/code&gt;&lt;br&gt;
display the files modified by specific Author users within the Since time period&lt;/p&gt;

&lt;p&gt;2--&lt;code&gt;git fetch origin&lt;/code&gt;&lt;br&gt;
3--&lt;code&gt;git reset --hard origin/master&lt;/code&gt;&lt;br&gt;
fetch the remote origin and hard reset your current with the remote (reset everything like the remote)&lt;/p&gt;

&lt;p&gt;4--&lt;code&gt;git log -p --author=aa-ahmed-aa&lt;/code&gt;&lt;br&gt;
get a very detailed information about the files edited by the Author with all the insertion and deletion files&lt;/p&gt;

&lt;p&gt;5-- &lt;code&gt;git commit -m "adding the images" *.jpg&lt;/code&gt;&lt;br&gt;
this is adding commit message to images only (add files by name if you want)&lt;br&gt;
and if you push them it will only push the commited files &lt;/p&gt;

&lt;p&gt;6-- &lt;code&gt;git stash&lt;/code&gt; to save you current working directory changes to a specific point if you want to reset to master without losing changes&lt;br&gt;
    &lt;code&gt;git stash list&lt;/code&gt; to list all of your stashed points&lt;/p&gt;

&lt;p&gt;7-- 'git clean -d -x -f ' to remove the untracked files &lt;br&gt;
be careful when using this command because it will erase all the untracked files even if this files is still used in your project&lt;br&gt;
*this list is daily updated.&lt;/p&gt;

&lt;p&gt;8-- 'git merge --abort' to revert back from the merging status&lt;/p&gt;

</description>
      <category>git</category>
      <category>gitcommands</category>
    </item>
    <item>
      <title>What is docker?</title>
      <dc:creator>Ahmed Khaled MOhamed</dc:creator>
      <pubDate>Tue, 02 Jan 2018 11:19:18 +0000</pubDate>
      <link>https://dev.to/aaahmedaa/what-is-docker--2h0k</link>
      <guid>https://dev.to/aaahmedaa/what-is-docker--2h0k</guid>
      <description></description>
      <category>docker</category>
      <category>python</category>
      <category>explainlikeimfive</category>
    </item>
    <item>
      <title>create RestAPI for your python scripts using Flask with 15 line of code 😎</title>
      <dc:creator>Ahmed Khaled MOhamed</dc:creator>
      <pubDate>Sat, 30 Dec 2017 00:45:54 +0000</pubDate>
      <link>https://dev.to/aaahmedaa/create-restapi-for-your-python-scripts-using-flask-with-15-line-of-code-10ml</link>
      <guid>https://dev.to/aaahmedaa/create-restapi-for-your-python-scripts-using-flask-with-15-line-of-code-10ml</guid>
      <description>&lt;h2&gt;
  
  
  Creating virtualenv for save working
&lt;/h2&gt;

&lt;p&gt;-if you don't have virtualenv installed do it using &lt;code&gt;pip install virtualenv&lt;/code&gt;&lt;br&gt;
-execute the following :-&lt;br&gt;
&lt;code&gt;mkdir flask-safe-env&lt;/code&gt;&lt;br&gt;
&lt;code&gt;virtualenv .&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Scripts/activate&lt;/code&gt; if you have any problem executing the activate script check this &lt;a href="https://virtualenv.pypa.io/en/stable/userguide/#admonition%20note"&gt;LINK&lt;/a&gt;&lt;br&gt;
&lt;code&gt;mkdir rest-api&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cd rest-api&lt;/code&gt;&lt;br&gt;
-install the required packages for this app by using &lt;br&gt;
&lt;code&gt;pip install flask&lt;/code&gt;&lt;br&gt;
&lt;code&gt;pip install flask-restful&lt;/code&gt;&lt;br&gt;
OR if you have the github repo run &lt;code&gt;pip install -r requirements.txt&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating the project files
&lt;/h2&gt;

&lt;p&gt;we can make all of the application in one script but for adding more reliability to the project we will create the sum function in a another script called sumTwoNumbers.py and import it in the app.py script to use it.&lt;/p&gt;
&lt;h4&gt;
  
  
  sumTwoNumbers.py
&lt;/h4&gt;

&lt;p&gt;simple enough create a function that accepts two parameters and return the sum of the two numbers&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sumTwo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  app.py
&lt;/h4&gt;

&lt;p&gt;we create instance of the flask app and the api module and then we add the route that accepts two params in the url using GET request we will call the function from the sumTwoNumbers script&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sumTwoNumbers&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;flask_restful&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Resource&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Api&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;api&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Api&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;sumNumbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Resource&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;first_number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;second_number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'data'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;sumTwoNumbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sumTwo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;first_number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;second_number&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;

&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_resource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sumNumbers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'/sumtwonumbers/&amp;lt;first_number&amp;gt;/&amp;lt;second_number&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;'__main__'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
     &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-to run the app execute the command &lt;code&gt;python app.py&lt;/code&gt;&lt;br&gt;
-go to &lt;a href="http://localhost:5000/sumtwonumbers/10/60"&gt;&lt;/a&gt;&lt;a href="http://localhost:5000/sumtwonumbers/10/60"&gt;http://localhost:5000/sumtwonumbers/10/60&lt;/a&gt; you can replace the numbers with the one you want&lt;/p&gt;

&lt;p&gt;you can find the project files here : &lt;a href="https://github.com/aa-ahmed-aa/Flask-RESTAPI"&gt;Sweet-github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python3</category>
      <category>flask</category>
      <category>restapi</category>
      <category>python</category>
    </item>
    <item>
      <title>Install Python Modules from *.whl file</title>
      <dc:creator>Ahmed Khaled MOhamed</dc:creator>
      <pubDate>Fri, 08 Dec 2017 09:22:27 +0000</pubDate>
      <link>https://dev.to/aaahmedaa/install-python-modules-from-whl-file-930</link>
      <guid>https://dev.to/aaahmedaa/install-python-modules-from-whl-file-930</guid>
      <description>&lt;p&gt;1- go to this &lt;a href="http://www.lfd.uci.edu/%7Egohlke/pythonlibs/"&gt;link&lt;/a&gt;&lt;br&gt;
2-download your module keep in mind you will choose the file you download according to your system 32x ,64x and the python version you have 3.4 or 2.7.&lt;br&gt;
3-go to the path where you download the file with the extention *.whl &lt;br&gt;
4-open the command and run &lt;code&gt;pip install &amp;lt;file_name_u_just_dowload&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Note
&lt;/h4&gt;

&lt;p&gt;make sure your are adding pip and python to your sys environment variable to be apple to use the pip command&lt;/p&gt;

&lt;h6&gt;
  
  
  Reference &lt;a href="http://stackoverflow.com/questions/32446146/import-pyhook-failed"&gt;Stack&lt;/a&gt;
&lt;/h6&gt;

</description>
      <category>python</category>
      <category>pip</category>
      <category>packages</category>
    </item>
  </channel>
</rss>
