Categories
All

Video Generator

Video Generator is a python tool that allows converting a collection of photos from local and online sources to video.

Preview


Reflection

While I was working on some computer vision task related to extracting some information from public surveillance cameras streams, in some stage I wanted to record some videos from a collection of photos URLs so I decided to create this simple script to help with this stage and share it in public as well.

Usage

Install
pip install -r requirements.txt

set source in main.py file

Sources:
- online photos urls        ex. 'http://78.186.19.184:81/record/current.jpg'
- local photos directory    ex. 'local_samples/'

videoGenerator = VideoGenerator(SOURCE_HERE)

Run

python main.py

on GitHub: https://github.com/khaledalam/video-generator

Categories
All

Firebase Logger

Firebase Logger is a simple firebase PHP logger package to monitor and save the users activities.

Installation

Use composer to install firebase-logger:
composer require khaledalam/firebase-logger

Preview

Usage

example.php

<?php
// PHP 7.1^
//error_reporting(0);

include_once './FirebaseLogger.php';

$serviceFile = __DIR__ . '/serviceAccountKey.json';
$databaseUri = 'https://{EDIT_THIS}.firebaseio.com';

$firebaseLogger = new FirebaseLogger([
    'service_account_key_json' => $serviceFile,
    'database_uri' => $databaseUri,
    'database_realtime_name' => 'Logger',
]);

if ($_POST['search'])
{
    echo "<h2>Log saved!</h2>";
    $data = [
        'action' => 'search action',
        'value' => $_POST['search'],
    ];
    $firebaseLogger->log($data);
}
?>

<center>
    <form action="./example.php" method="post">
        <input type="text" placeholder="search text" name="search">
        <input type="submit" value="search">
    </form>
</center>

Check the config section in README file and files on GitHub: https://github.com/khaledalam/firebase-logger

Packagist: https://packagist.org/packages/khaledalam/firebase-logger

Categories
All

API Multiprocessing

Motivation

In this article, I am going to show you how we can improve the computing power of simple API script from total overall (6 minutes and 17 seconds) to (1 minute 14 seconds)

The Idea

I will share with you one of my simple favourite technique that I prefer to use especially when I work on data science tasks such as data visualization, data analysis, code optimization, and big data processing.

Processing a task in a sequential way may take a long time especially when we are talking about a huge amount of data(eg. big inputs)

This technique takes advantage of parallelization capabilities in order to reduce the processing time.

The idea is to divide the data into chunks so that each engine takes care of classifying the entries in their corresponding chunks. Once performed, each engine reads, writes and processes its chunks, each chunk be processed in the same amount of time.

Example

The example I choose to use for this article is Genderize names that consist of 2 alphabetic characters.

Output Analysis Chart

Explanation

Clone GitHub Repo and follow instructions in Usage section.

Let’s generate all alphabet names that consist of 2 characters(to make the testing process easy)

we can use some Linux Kali penetration testing tool[1] such as crunch
$ crunch 2 2 > names.txt
so we generate all possible alphabet names with length 2 (676 lines)

then let’s create directories which are needed for splitting process
$ mkdir subs/ subs/inputs subs/outputs subs/outputs/parts subs/outputs/all

now we can split out input data, there are many ways to do that but I prefer to use Unix split command [2]
$ split -l 100 -d names.txt ./subs/inputs/
so we split names.txt file into small files, each file consists of 100 lines

now let’s run all processes: ./init.bash
after finish use merger.py script to merge all outputs.
merging process separated to avoid conflicts behaviours and sorting-save.


The Project on GitHub:
https://github.com/khaledalam/api-multiprocessing

An application uses this technique:
Hiring-Related Email(https://github.com/khaledalam/amazon-jobs)

Interesting related ideas:
Parallelizing using GPUs
– MapReduce (https://en.wikipedia.org/wiki/MapReduce)

[1] https://tools.kali.org/password-attacks/crunch
[2] https://en.wikipedia.org/wiki/Split_(Unix)

Categories
All

Amazon Job Hiring Related Email

Amazon-Jobs

Amazon Jobs Apps that help the user to check if some email relates to any AMAZONIAN hrs, recruiters, interviewees, interviewers, talents, candidates and so on..

  • – check hiring-related emails,
  • – get job post recruiter details,
  • – get more statistics about job posts,
  • – search jobs globally with more deep filters

Preview:




Mobile App:


Web App:
https://khaledalam.net/amazon

GitHub:



Screens:


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
'''