bookmark_borderJAVA in JAVA

This photo I called it “Java in Java”.

The most interesting programming language name for me after “Brainf**K” programming language is Java!

In my childhood, the first interesting mobile I used was “LG L342i” which was released in 2005, first mobile I tried that has the ability of accessing internet but it wasn’t work with Egyptian networks operators,  I liked LG brand and I were impressed by this mobile functionalities and its games (GAMELOFT, Golf, UNO, Pool, and other few interesting puzzles games) there was a splash screen in each game that has a special Java logo intro and a wonderful loading animation which makes me interested about Java and what is this name refers to? Is Java a very big game that contains all other mobile games or is it a big mobile application?

I decided to go to internet coffee and instead of playing Command & Conquer, Max Payne, GTA and other games as usual.. I decided to search for Java, on that day I read for the first time about something called programming and knew more about Java history and the reason for naming Java with that name.. and I found that there is some real Island in another country called Java!

I wished that one day I would visit this Island and try 3 things there:
Try drinks, especially coffee.
Play Java games.
Search for Java books.

After about 14 years I managed to visit Java Island(Central and West), and tried the 3 things and remembered all my childhood memories.

Childhood dreams and wishes are not just dreams and wishes.
– Khaled Alam

—–

The Java programming language project was initiated in June 1991. Java was originally designed for interactive television.

The language was initially called Oak after an oak tree that stood outside Gosling’s office. Later the project went by the name Green and was finally renamed Java, from Java coffee, the coffee from Indonesia.

bookmark_borderCount Leading Zeros in 25!^25!

(25!) = 15511210043330985984000000 => (6 zeros)

Detecting Pattern:
(25!) ^ 1 => (15511210…85984000000) => 6 zeros
(25!) ^ 2 => (24059763…48256000000000000) => 12 zeros
(25!) ^ 3 => (37319604…43904000000000000000000) => 18 zeros
(25!) ^ 4 => (57887222…41536000000000000000000000000) => 24 zeros
(25!) ^ 5 => (89790087…31424000000000000000000000000000000) => 30 zeros
and so on..

thus:
Leading Zeros in [ (25!) ^ (25!) ] = [Number of leading zeros in (25!)] * (25!)

[Number of leading zeros in (25!)] = 6 zeros
value of (25!) = 15511210043330985984000000

leading zeros in (25!)^(25!) = 6 * 15511210043330985984000000
= 93067260259985915904000000 zeros

bookmark_borderComposer Smart Updater

Reflection:
In a big Symfony v5.0 project we wanted to upgrade composer packages (around +140 updates available includes orm, doctrine packages, fixtures, migration, api platform, etc)
after update using composer update when run the migration symfony console doctrine:migration:migrate -n migration not working fine because of conflicts and different migrations table name pattern so it can’t detect names of migrations file and because some packages needs PHP v7.4.11 (relreased this month 1st October 2020) and our env uses PHP v7.4.3 and needs Composer v2 and our env used old Composer version.


I created a Python script that reads composer.json file and loop over its required and required-dev packages and install each package individually then run migration command and check if everything is working fine or not!

composer-smart-updater.py on GitHub: https://github.com/khaledalam/composer-smart-updater

This script will helps to detect and find which exactly package that cause this conflict.

Plus I unify infrastructure cloud architecture env (AWS) and Git pipelines (BitBucket) container images to use most updated versions.

bookmark_borderIBM October 2020 – Challenge (control-flow graph)

https://www.research.ibm.com/haifa/ponderthis/challenges/October2020.html

This month’s challenge is dedicated to the memory of Frances Allen, who passed away in August. Among her many accomplishments is the invention of the control-flow graph, in her 1970 paper “Control flow analysis

My solution

with step number:

10 A = a
20 B = b
30 JMP_ZERO B 90
40 AA = A
50 BB = B
60 A = B
70 B = AA % BB
80 JMP 30
90 RETURN A


-----

without step number:

A = a
B = b
JMP_ZERO B 90
AA = A
BB = B
A = B
B = AA % BB
JMP 30
RETURN A

IBM Gadi submission result:

Thanks! This indeed computes the GCD, but the requirement on the number of paths is not fulfilled.

bookmark_borderWhat is curvature?

If you think that the curved monitor is simply made by bending the two sides of the screen inward, then you are mistaken. As mentioned earlier, the curved monitors have a bending angle. Not all curved monitors are created equal. If the curvature is not big enough, there won’t be any difference from using a regular flat monitor. But if the magnitude of bending gets too large, the image displayed will be deformed and distorted.

Curved monitors have different levels of curvature which are rated at values such as 1500R, 1800R, 3000R, or 4000R. For a better understanding of the nomenclatures values, the number refers to the curved monitor radius in millimeters and the R stands for radius (for example a 1500R monitor refers to a monitor with a radius of 1500 millimeters). The smaller the number, the greater the curvature.

So what is the optimal curvature, you may ask? Well, since the human eye has a range of about 1000R, a curvature rate that is closer to 1000R will be better. Until now, the latest curvature has reached 1500R, which is more in line with the human eye than the 1800R. For the most immersive gaming experience, we recommend a Native 1500R curved display.

copied!

bookmark_borderUsing Pipelines to Invalidate AWS CloudFront Cache that Pointing to AWS S3 bucket

Steps:

  • Add Repository Variables for Distribution IDs
  • Add Repository Variables for AWS keys as well
  • Add invalidate step in your pipeline
    e.g.
- step:
          name: ">> Invalidate AWS CloudFront (by: Khaled alam)"
          script:
          - pipe: atlassian/aws-cloudfront-invalidate:0.4.1
            variables:
              AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
              AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
              AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
              DISTRIBUTION_ID: $TEST_CLOUDFRONT_DISTRIBUTION_ID
              # PATHS: <string> # Optional
              DEBUG: "true" # Optional

Note: in case you want to invalidate specific files or paths, you should define that in PATHS: <string>

bookmark_borderQuantum Computing And Primes

Attempt to study and detect an undiscovered primes pattern!


GitHub repo for notes:
https://github.com/khaledalam/QuantumComputingAndPrimesAndOthers


Graphically

  1. pattern families:
    1. Grids
      1. [N x N] (0,0) top left : (n-1,n-1) bottom right 2×2 : 200×200
    2. Linear
      1. 2 to up N |/__ (2 up to 10000000)
      2. ..





Break 2048-bit RSA encryption in 8 hours

Quantum computer

bookmark_borderConfirm AWS Elastic Beanstalk Deployment Progress

Amazon Web Services Elastic Beanstalk

Use case:
You are using Amazon Web Service(AWS) Elastic Beanstalk to handle your deployment process via some git version control pipelines and there is a step that needs to run after your code has been deployed successfully.

There are a lot of solutions that can be used e.g CloudWatch, Lambda Function,.. etc. but I decided to invent my own solution that is easy, interesting and will cost 0$ :))



Idea:
Use a unique value on pipeline level (e.g pipeline build number) and add it to new code before upload it to server then call some endpoint or file to check this value. while this value does not equal out the new unique value in the pipeline then the deployment not finished yet and we should wait!


How to add new value to new code?
– we will create special endpoint or file in our project
– in the pipeline before upload new code to server change value of this file eg. deploy_version.txt or endpoint {api_link}/current_version
e.g: set some variable value with a new unique value. (you can do that using e.g sed Unix-like command)

ex.

we have a static endpoint that returns JSON result with the value of currentVersion variable that placed in e.g `version.js`

const currentVersion='123';

in the pipeline before upload code step:
- sed -i 2"s/currentVersion='123'/currentVersion='$BITBUCKET_BUILD_NUMBER'/g" src/version.js


How to validate deployment progress?

create a bash script that will send curl request to that endpoint to validate if current version from the endpoint(currently deployed code) is equal to new unique pipeline value or not.

how can this bash script look like? email me for more details(khaledalam.net@gmail.com)


bookmark_borderCool Profile Pic Doc

CoolProfilePic app helps users to change their social media profile pictures automatically based on settings that they will choose such as new photo category and the changing frequency!

Using:

Docker(-compose), DigitalOcean, AWS, Jinja, Linux, Crons, Flask, RabbitMQ, PHP, Python, Node, MySQL, Express, MongoDB, SQL, Social media APIs, Flask_Dance, PDO, TwitterAPI, GitHubAPI, NPM, PhpMyAdmin, Composer, Guzzle, Sockets, PIL

Demo (the queuing cycle)

Watch Demo (the whole app) => youtube video

Architecture


Email me for the source code: khaledalam.net@gmail.com

Reflection

The idea of automate changing facebook, twitter github, etc.. profile picture came to my mind few days ago, I decided to build this self project from A to Z using some new strategy and stack as a proof of concept of some things that I want to proof personally by myself.

Solved Challenges

  • Connections between containers issues
  • Deadlock issues
  • Sockets issues
  • Caching common dependencies

Current demo is version 1 of the app

Version 2 Tweeks:

  • use multi workers, publisher, queues, taskers
  • mapping DB queries by its types and priority
  • improve containerization performance
  • design IP blocker microservice
  • design mailer microservice
  • handle higher traffic and load
  • automate the deployment process and increase its speed
  • advertise (image processing -> add watermark @CoolProfilePic text on new images)

Random sketches