Categories
All

Flutter GitLab CI/CD DevOps

  1. Create .gitlab-ci.yml file in Project root dir
    in the same level of lib folder create file .gitlab-ci.yml
  2. Get a docker:image
    There are some flutter docker images available you can select one or even use your own Docker image

    Flutter docker images examples:
    cirrusci/flutter:stable (github)
    kattwinkel/flutter-android (github)

    Then add it in .gitlab-ci.yml file:
    image: cirrusci/flutter:stable
  3. Define your stages
    Now you need to define stages like that:
    For example:
    stages:
    - test
    - build

    Then start to define tasks that each stage should run:
    For example for stage test:


    test:
    stage: test
    script:
    - flutter packages get
    - flutter packages upgrade
    - flutter test
    interruptible: true

    For example for stage build:


    build:
    stage: build
    script:
    - flutter build apk
    artifacts:
    expire_in: 1 week
    paths:
    - build/app/outputs/apk/release/app-release.apk
    interruptible: true

    Full Example

    .gitlab-ci.yml

    image: cirrusci/flutter:stable

    stages:
    - test
    - build

    test:
    stage: test
    script:
    - flutter packages get
    - flutter packages upgrade
    - flutter test
    interruptible: true

    build:
    stage: build
    script:
    - flutter build apk
    artifacts:
    expire_in: 1 week
    paths:
    - build/app/outputs/apk/release/app-release.apk
    interruptible: true

    You can add more stages like deploy , upgrade , publish etc..

Categories
All

Machine-Learning-Image-Searcher

Motivation

A person can take a photo of his dog and write caption hashtag #Tree instead of #Dog 😀 , I thought about how can companies and we improve the searching process such that we get only the real target we want (ex. images that contain items or objects that we need).
I don’t want to search for Tree and get Cats in results instead 🙂 and vice versa.

First thing comes to my head is Object Detection and Recognition techniques which fit perfectly in such cases.

Here is a simple example of how ML can cause amazing improvements. Think from Marketing perspective. Let’s say we want to target some type of audience based on their photos on social media(perfect example here maybe Instagram) to contact with posts authors or announce about our new sales!!!

Real example: we have animals(Cats) food shop and we want to target Instagram users who have an animal(Cat). In the example below output shows how searching using:

  • Human Hashtags + ML = 20(cats)/20(total result) -> [100% correct]
  • Human Hashtags Only = 12(cats) / 20(total result) -> [60% correct]

NodeJS Module: http://npm.im/ml-image-searcher

Categories
All

2 SDE Amazon Interviews Invitations in 1 week

2 SDE Amazon interviews invitations in 1 week, a new experience!


Germany


Spain


Germany


I used to get rejections from Amazon at CV monitoring stage :’( but I never give up! I also used to feel this low energy after finish contests ex. interesting codeforces rounds, although sometimes in contests I solve problems that are much harder than multi-international companies interviews questions but I have to admit that after these 2 interviews my battery is not low as usual it literally dies instead :’)


Let’s analyze briefly:

  • Total time [1.5 : 2.5] hours
  • Total questions topics-based: DP, BT, Recursion, String Manipulation, basic math, build and sort complex ds.
  • A session for algorithms & data-structures coding questions.
  • A session for open-ended questions to discuss your solutions and complexity.
  • A session for reasoning questions(very tricky).
  • A session for code debugging ability(not hard).
  • A session for working-style questions(focused on soft skills + psychological dimensions).
  • A session for a survey.

Notes:

  • Tricky corner test cases.
  • DS coding questions are annoying and need to start with wisely choices and smart ideas from the beginning.
  • Open-ended questions have a very short time, need to think and organize your answer in your mind before the session or during the coding session.
  • Overall Div2 ~ D level can nail it.

For sure there are other hundreds of questions topics, sessions, and styles but this was my own experience!

If you are still an undergraduate, my advice: “problem-solving” & “practice”

My greetings < 3

Categories
All

Arrow Shooting Game

I made many simple games in the past, but this game is the most interesting one for me : )

Arrow Shooting 2D Game using C++, OpenGL and various Geometry Algorithms.

preview:

code: https://github.com/khaledalam/Arrow-Shooting

Arrow Shooting Mobile Game version is available now: http://arrowshooting.khaledalam.net

Categories
All

Rasmus Lerdorf – Frameworks all suck!

“Premature optimization is the root of all evil”
donald knuth –


Categories
All

Python Instagram Followers Scraper





import sys
# import instaloader
from include import *


'''
username = 'INSTAGRAM_USERNAME_HERE'
password = 'INSTAGRAM_PASSWORD_HERE'


username = ''
password = ''


L = instaloader.Instaloader()
L.login(insta_username, insta_password)

profile = instaloader.Profile.from_username(L.context, 'areyoukhaled')

print ('you have ' + str(len(profile.get_followers())))

for post in profile.get_followers():
    print(post)

# followers = set(profile.get_followers())
# print('Fetching followers of profile: {} ' + len(followers) + ' .'.format(profile.username))
#
# print(followers)

print('Storing Followers into file.')
with open( PROFILE + ' (followers).txt', 'w+') as f:
 cnt = 1
 for follower in followers:
 print(follower.username, file=f)
 sys.stdout.write("%d of %d\r" %( cnt, len(followers)) )
 sys.stdout.flush()
 cnt+=1
'''
Categories
All

Time Tracking

python working time toggl tracking

http://www.online-stopwatch.com/cash-clock/

import sys
import datetime
import keyboard 
import time

timeInSeconds = 0
tillNowTime = 0
startedTime = str(datetime.datetime.now())
rate = 1.2
eq = 0

while True:
	if keyboard.is_pressed("esc"):
		break

	tillNowTime = str(datetime.timedelta(seconds = timeInSeconds))
	eq += rate
	sys.stdout.write("Started at: %s  |  Till now: %s , %s[X]\r" %( startedTime, tillNowTime, str(eq)) )
	sys.stdout.flush()
	timeInSeconds += 1
	
	time.sleep(1)	
	
print("\n--------\nEnded at: " + str(datetime.datetime.now()) + " | Total: " + str(tillNowTime) )
Categories
All

CLIPS Diagnoser Task

main.clp

; Diagnoser | Expert System task 4cs

;
; run:
; CLIPS> (load C:\PATH_DIR\main.clp)
; CLIPS> (run)


(deffunction print-parts()
	(printout t crlf "--= Diagnoser =--" crlf crlf)
	(printout t "> eye (available)" crlf)
	(printout t "> nose (available)" crlf)
	(printout t "> ear" crlf)
	(printout t "> mouth" crlf)
	(printout t "> shoulder" crlf)
	(printout t "> neck" crlf)
	(printout t "> hand" crlf)
	(printout t "> arm" crlf)
	(printout t "> elbow" crlf)
	(printout t "> waist" crlf)
	(printout t "> stomack" crlf)
	(printout t "> leg" crlf)
	(printout t "> foot" crlf)
	(printout t "Choose part: ")
)

(defglobal  ?*sum* = 0)

; vvvvvvvvvvvvvvvvvv
(defrule START_POINT
	?f <- (initial-fact)
=>
	(load-facts "kb.clp")
	(retract ?f)
	(print-parts)
	(assert (ask-part (read)))
)

(defrule ask-part
	?f <- (ask-part ?part)
	(ask-part ?)
=>
	(printout t "-->> " ?part ":" crlf)
	(assert (ask-questions ?part))
)

(defrule ask-questions
	?f <- (ask-questions ?part)
	?f2 <- (question ?part ?perc $?text)
	(ask-questions ?)
=>
	(printout t $?text " [yes, no] ")
	(bind ?ans (read))
	(if (member$ ?ans (create$ yes) )
		then (bind ?*sum* (+ ?*sum* ?perc))
	)
	(assert (result ?part))
)

(defrule result
	?f <- (result ?part)
	(advice ?part $?text)
	(result ?)
=>
	(retract ?f)
	(if (> ?*sum* 0)
		then 
			(printout t crlf "danger percentage: " ?*sum* "%" crlf)
			(printout t $?text crlf crlf)
		else 
			(printout t crlf "you are ok!" crlf crlf)
	)
)

kb.clp

; Diagnoser | Knowledge base
;
; Expert person(ex. doctor) will add symptoms here


(question nose 50 Is there nose runny?)
(question nose 20 Is there sneezing?)
(question nose 30 is there sore throat?)
; برد - دكتور انف واذن
(advice nose Maybe it's cold go to otolaryngologist doctor)


(question eye 40 Is there friction in the eye?)
(question eye 40 Is eyes are red?)
(question eye 20 Are there tears?)
; التهاب فى العين- دكتور عيون
(advice eye Maybe it's Inflammation go to ophthalmologist doctor)

 
Categories
All

MD5 [En/De]crypter

More than 1.000.000 words in our database. 🙂

http://www.md5.epizy.com

The MD5 algorithm is a widely used hash function producing a 128-bit hash value.
Although MD5 was initially designed to be used as a cryptographic hash function,
it has been found to suffer from extensive vulnerabilities.

Categories
All

Police Traffic Control

Police Traffic Control | Arduino and ASP.NET project.
This project helps police to control traffic and catch the suspects easily.

code.ino

/*
 * Police Traffic Control | Arduino and ASP.NET project.
 * This project helps police to control traffic and catch the suspects easily.
 * 
 * author: khaled alam
 */

 
#include <Servo.h>

// pins
const int greenLed = 4;
const int redLed = 2;
const int buzzer = 5;
const int lightSensor = A0;
const int servoPin = 9;

//vars changeable
int lightValue;
int sensorValue;
int continueStopping = -1;
char incomingFromSerial;

//serial const signals
const char OPEN_GATE = '1';
const char CLOSE_GATE = '2';
const char POLICE_SAY_STOP = '3';
const char BUZZ_ON = '4';
const char BUZZ_OFF = '5';
const char GREEN_ON = '6';
const char GREEN_OFF = '7';
const char RED_ON = '8';
const char RED_OFF = '9';

Servo servo;

void setup()
{
  Serial.begin(9600);
  servo.attach(servoPin);
  pinMode(greenLed, OUTPUT);
  pinMode(redLed, OUTPUT);
  pinMode(buzzer, OUTPUT);
}

void loop()
{

  while(Serial.available() > 0)
  {
    //read serial come from ASP.NET
    incomingFromSerial = Serial.read();

    //if police ask driver to stop
    if (incomingFromSerial == POLICE_SAY_STOP)
    {
      continueStopping = 1;
      offCorrectLed();
      onWrongLed();
      openGate();
      detect(); 
    }

    // Do action based on serial signal send from ASP.NET
    // manual actions:
    if(incomingFromSerial == CLOSE_GATE)
    {
      continueStopping = -1;
      closeGate();
      offCorrectLed();
      onWrongLed();
    }
    else if (incomingFromSerial == OPEN_GATE)
    {
      continueStopping = -1;
      openGate();
      offWrongLed();
      onCorrectLed();
    }else if (incomingFromSerial == BUZZ_ON)
    {
      continueStopping = 1;
      turnOnBuzzer();
    }else if (incomingFromSerial == BUZZ_OFF)
    {
      continueStopping = -1;
      noTone(buzzer);
    }else if (incomingFromSerial == GREEN_ON)
    {
      digitalWrite(greenLed, HIGH);    
    }else if (incomingFromSerial == GREEN_OFF)
    {
      digitalWrite(greenLed, LOW);
    }else if (incomingFromSerial == RED_ON)
    {
      digitalWrite(redLed, HIGH);
    }else if (incomingFromSerial == RED_OFF)
    {
      digitalWrite(redLed, LOW);
    }
    delay(100); // wait 100 milliseconds (0.1 second)
    Serial.flush();
  }

}

/* 
 *  detect function use as a loop to check
 * if driver follow police order and stop or not 
 */
void detect()
{
  //while police ask driver to stop
  while(continueStopping == 1)
  {
    //check if driver run before police allow
    if ( pass() )
    {
      closeGate();
      turnOnBuzzer();
      Serial.println("Catch Now..");
      break;
    }
    onWrongLed();
  }
}

void onCorrectLed()
{
  digitalWrite(greenLed, HIGH);
}

void offCorrectLed()
{
  digitalWrite(greenLed, LOW);
}

void onWrongLed()
{
  digitalWrite(redLed, HIGH);
}

void offWrongLed()
{
  digitalWrite(redLed, LOW);
}

void turnOnBuzzer()
{
  while (continueStopping == 1)
  {
    //read from ASP.NET during police stop order
    incomingFromSerial = Serial.read();
    
    tone(buzzer, 1200); // << turn on buzzer
    
    // condition to stop buzzer
    if(incomingFromSerial == OPEN_GATE || 
        incomingFromSerial == CLOSE_GATE ||
        incomingFromSerial == POLICE_SAY_STOP ||
        incomingFromSerial == BUZZ_OFF)
    {
      if (incomingFromSerial != BUZZ_OFF)openGate();
      noTone(buzzer);
      continueStopping = -1;
    }
    delay(60);
  }
}

//check if any car cover light sensor or not
boolean pass()
{
  sensorValue = analogRead(lightSensor);
  lightValue = map(sensorValue, 0, 1023, 0, 255); 

  // increase 8 to increase sensitivity)
  if (lightValue <= 8)return true;
  return false;
}

void openGate()
{
  servo.write(0);
}

void closeGate()
{
  servo.write(90);
}

void debug()
{
  Serial.print("Light Value = ");
  Serial.println(lightValue);
}

Default.aspx.cs

using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Police_Traffic_Control
{
    public partial class _Default : Page
    {
        public static SerialPort sp;

        // Signals
        const string OPEN_GATE       = "1";
        const string CLOSE_GATE      = "2";
        const string POLICE_SAY_STOP = "3";
        const string BUZZ_ON         = "4";
        const string BUZZ_OFF        = "5";
        const string GREEN_ON        = "6";
        const string GREEN_OFF       = "7";
        const string RED_ON          = "8";
        const string RED_OFF         = "9";

        //Images
        const string welcomeImg = "~/imgs/welcome.png";
        const string openImg    = "~/imgs/gateO.jpg";
        const string closeImg   = "~/imgs/gateC.jpg";
        // etc...


        protected void Page_Load(object sender, EventArgs e)
        {
            sp = new SerialPort();
            sp.PortName = "COM3"; // change port name(if change usb pos.)
            sp.BaudRate = 9600;
            sp.Parity = Parity.None;
            sp.DataBits = 8;
            sp.StopBits = StopBits.One;
            sp.ReadTimeout = 1000;
            StatusImage.ImageUrl = welcomeImg; // default welcome img
        }

        // Change images action examples
        protected void changeImage1(object sender, EventArgs e)
        {
            StatusImage.ImageUrl = openImg;
        }
        protected void changeImage2(object sender, EventArgs e)
        {
            StatusImage.ImageUrl = closeImg;
        }
        protected void changeImageProp(object sender, EventArgs e)
        {
            StatusImage.Width = 250;
            StatusImage.Height = 300;
            StatusImage.ImageAlign = ImageAlign.Bottom;
            //...
        }



        protected void stopNow(object sender, EventArgs e) //send command to uno to open gate and turn on passing detection
        {
            GateStatus.Text = "<b style='background-color:yellow;'> >>> </b>Police is Asking Driver To Stop!";

            // Change image ex. :
            StatusImage.ImageUrl      =     openImg; 
            // add alertImg instead of openImg ^ for example

            if(!sp.IsOpen)sp.Open();
            sp.Write(POLICE_SAY_STOP); sp.Close();
        }


        protected void openGate(object sender, EventArgs e) //send command to uno to open gate
        {
            GateStatus.Text = "<b style='background-color:green;'> >>> </b>Gate Opened!";
            if (!sp.IsOpen)sp.Open();
            sp.Write(OPEN_GATE); sp.Close();
        }


        protected void closeGate(object sender, EventArgs e) //send command to uno to close gate
        {
            GateStatus.Text = "<b style='background-color:red;'> >>> </b> Gate Closed!";
            if (!sp.IsOpen) sp.Open();
            sp.Write(CLOSE_GATE); sp.Close();

        }

        protected void buzzOn(object sender, EventArgs e) //send command to uno to turn on buzz
        {
            GateStatus.Text = "<b style='background-color:brown;'> >>> </b> Buzz On!";
            if (!sp.IsOpen) sp.Open();
            sp.Write(BUZZ_ON); sp.Close();
        }


        protected void buzzOff(object sender, EventArgs e) //send command to uno to turn off buzz
        {
            GateStatus.Text = "<b style='background-color:gray;'> >>> </b> Buzz Off!";
            if (!sp.IsOpen) sp.Open();
            sp.Write(BUZZ_OFF); sp.Close();
        }


        protected void greenLedOn(object sender, EventArgs e) //send command to uno to turn on green led
        {
            GateStatus.Text = "<b style='background-color:green;'> >>> </b> Green Led On!";
            if (!sp.IsOpen) sp.Open();
            sp.Write(GREEN_ON); sp.Close();
        }


        protected void greenLedOff(object sender, EventArgs e) //send command to uno to turn off green led
        {
            GateStatus.Text = "<b style='background-color:green;'> >>> </b> Green Led Off!";
            if (!sp.IsOpen) sp.Open();
            sp.Write(GREEN_OFF); sp.Close();
        }


        protected void redLedOn(object sender, EventArgs e) //send command to uno to turn on red led
        {
            GateStatus.Text = "<b style='background-color:red;'> >>> </b> Red Led On!";
            if (!sp.IsOpen) sp.Open();
            sp.Write(RED_ON); sp.Close();
        }


        protected void redLedOff(object sender, EventArgs e) //send command to uno to turn off red led
        {
            GateStatus.Text = "<b style='background-color:red;'> >>> </b> Red Led Off!";
            if (!sp.IsOpen) sp.Open();
            sp.Write(RED_OFF); sp.Close();
        }

    }
}