Viruses et al : Natures own AI bots!

Yes,

I stumbled upon this understanding a while back!

Lets look at AI bots first:

  1. They have all logic programmed in them for a particular situation.
  2. They have stimulus response, partially developed.
  3. They need to be activated somehow (OK Google, Hey Siri, Hey Cortana, Yo! Alexa etc)
  4. They partially replicate human senses.
  5. Can wreck hovac!

Now lets see viruses in comparison:

  1. They have all the mechanism in place for replicating and doing their unique thing.
  2. Some are capable of stimulus response
  3. They need a living host body to grow, develop, survive , activate , replicate, spread.
  4. Most of them replicate cell functions that harm the body.
  5. They have caused lot of destruction!

Nature via evolution, creates these complex particles(A virus, that has not yet contacted the host body is called virion, which is made up of nucleic acid(RNA or DNA) and/or an outer shell of protein.).

Once created/come into existence, they need a host system to act, and that happens to be a living cell in a living body.

So the virus cannot operate without cell, similarly the AI bots cannot operate if they run out of battery(cell’s), You see?!

There you go, we are entering a world of human created viruses, as if nature’s contribution was not enough already!!

PS: The word android means : A robot/automaton with a human appearance!

 

Rant : Covid-19 vs Me(The software developer)

Long time, no See folks!

Writing after a long time, a discussion with @SoftwareGod, triggered this blog post!

(I am in self induced inertia!)

So the discussion was about we(s/w devs) contributing to the drug discovery hackathon for Covid-19.

Why I choose not to join:

1/Hackathon is open sourced, everything else is IPR‘ed.

2/No “Getting started with biological virus” guide I could find?

3/What are our R&D scientists doing in virus labs?

4/IMO, get a super computer in place for running simulations, although the mobiles and laptops are a lot powerful today, I am sure super computers run on petaBytes/milliseconds speeds!

So, that done, I recalled, hey! I had once developed an anti-virus programme, in Visual Basic(I had super-less love for M$ at that time).

Going back in that time….

I was forced to learn VB, and I was making faces inside of me, like why??

Coincidentally during that time, my system was hit by HTML RedLof.A virus, it was the era of floppy exchanges, usb drives were not so common.

So, this novel idea sprung up in me, why not cure poison with poison (Hu Ha Ha Ha…. Hu Ha Ha Ha….) 😀

So my next task was writing a cure for the virus(not vaccine) in my least liked languages M$ VB.

Looking back, this was the algo, which may/maynot be mapped to biological virus.

1/The first thing, I noticed in my system was , the free hard disc space started reducing.

{identify unique or distinguishing symptoms}

2/I could not understand the reason first why. but on closer analysis, I saw my recently modified files being htm,html where the size increased by a fixed amount.

{check inflammatory markers, or the first response body gives when attacked by virus}

3/On opening those files, at the end of the source code, I saw alien code of the virus and its replication.

{Once infected area found, extract and analyze; this is very domain specific}

4/The virus was replicating and affecting html,htm files, other infected extensions were: jsp and vbs.

{understand how virus entered the system, stop that first}

So most probably an infected html or vbs file kept in an already-infected floppy, affected my system.

5/Now that the pattern was identified, I simply wrote VB program, to

a)Scan whole computer for defined extensions files

{in covid-19: various proteins}

b)For each such file, reg-ex the starting of the alien code and end

{find a way to delink the alien protein}

c)Delete that piece of the code

{Kill Kill Kill}

d)Save the file.

{replenish that part, shower with newer safe proteins}

I confirmed the same via anti-virus programmes as:

1/Ran the 3rd party anti-virus : Infection NOT found

2/Infected my system with the virus

3/Ran the 3rd party anti-virus : Infection found

4/Executed my VB program

5/Ran the 3rd party anti-virus : Infection NOT found

This ways my system got rid of the virus completely.

Coming back to biological viruses, I think we can take help from Symantec,F-Secure and such “anti-virus” software making companies, because they have studied so much more patterns of viruses, and that can be employed to faster Drug Discovery!

Thanks for reading! 🙂

Things everyone should know about responsive images and srcset

The aim of responsive images is to deliver the same image in mobile and desktop view without disturbing the viewport size that is the image should look alike in every device .

Therefore this problem of responsive images can be solved by using srcset attribute in image tag or using media queries.

Both are suitable to deal with this situation but prefer to use srcset instead of media queries because media queries will take time to write but srcset does the same thing in small time and space .
The information below will explain all about srcset .

srcset
The srcset attribute is listing different resolutions of the same image from which the browser chooses the best fitting image source before loading it.
Example: srcset="ninja-1000w.jpg 1000w, ninja-500w.jpg 500w, ..."
To calculate this, the browser assumes the image fills up the full viewport width (100vw) by default, which means it uses the full width of the browser.

In short, Srcset is a new attribute which allows you to specify different kind of images for different screen-sizes/orientation/display-types.
The usage is really simple, you just provide a lot of different images separating them with a comma like this:

<img src="image.jpg" alt="image" srcset="<img> <descriptor>, ..., <img_n> <descriptor_n>">.

Here is an example:

srcset="image.jpg 160w, image2.jpg 320w, image3.jpg 2x"

Descriptors are just a way to show what kind of image is coming from the resource. There are various kinds of descriptors:

  1. density descriptor–> srcset=”image.jpg, image-2X.jpg 2x” The display density values—the 1x, 2x, etc. are referred to as display density descriptors. If a display density descriptor isn’t provided, it is assumed to be 1x.
  2. width descriptor –> srcset=”image-240.jpg 240w, image-640.jpg 640w”.
    When using the w-descriptor we have to specify the default explicitly by adding a second srcset image option, with its own w-descriptor, and separating them with a comma.
  3. size descriptor–> It only makes sense if you use width descriptor.
    srcset=”image-160.jpg 160w, image-320.jpg 320w, image-640.jpg 640w, image-1280.jpg 1280w” sizes=”(max-width: 480px) 100vw, (max-width: 900px) 33vw, 254px”>.
    The instructions for the browser would look like this: (max-width: 480px) 100vw — if the viewport is 480 pixels wide or smaller, the image will be 100% of the viewport width.So it is like using media queries in html which looks a lot easier as compared to media queries written in css .

Pros–>
1.much easier than media query
2.saves time

Cons–>
1.Browser should be updated to see the effect
2.Not all browsers support this.
At present, Edge, Safari, and iOS Safari only support a subset of the srcset specification. Firefox, Chrome, Opera, Android Browser, and the forthcoming versions of Safari and iOS Safari fully support it.

Demo can be seen on my github link

pershantgoel.github.io/imgsrcset

Test Driven Development with SpringBoot+Junit

 

Test-driven development(TDD) in the Spring framework.

TDD  helps me speed up my software release cycles, and ensure that I end up with a high-quality product. Spring makes Java enterprise development much easy.  Spring Boot, which we will use in this blog, is a project that does this task with excellence.

Follows are the steps to configure your spring boot framework with the Junit and Maven.

Step-1)Set up Spring boot with J-Unit testing Approach

After Set your maven dependencies , for spring-boot add following dependency for testing Approach.

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>

Step-2)Create test Package and in that ,create DemoApplicationTests Class.

Step-3)Inject controller using @InjectMocks, Inject repository using @Mock Annotations.

Let us take some J-Unit Annotations used in java class :

@Before:@Before annotation are executed before each test.

@After:It executes after each test.

@BeforeClass: It executes common operation before each test,So it executes  only once before running all tests.

@AfterClass: It executes common operation after each test, So it executes only once after running all tests.

@Test:The Test annotation tells JUnit that the public void method to which it is attached can be run as a test case.

In JUnit 5, the tags @BeforeEach and @BeforeAll are the equivalents of @Before and @BeforeClass in JUnit 4.

Configure Java File and Select Run as Junit and Test the file.

 

Congratulations!!!you are done with your TDD approach.

Eclipse not auto-configuring/auto-importing a Git mavenized project

I was trying to setup a maven project in eclipse via GIT. I had hoped, it will auto import the project into eclipse, but for some reason that did not happen.

 

This is what was done as a workaround:

Step:1 Checkout your repository in your system

File->import->Git->Project from Git->Clone URI->Enter Git Repository Details

Select Destination where you wanted to store your Git Repository

Step:2 Import your Project into Eclipse

File->import->maven->install or deploy an artifact to a Maven Repository

Once these steps are done, The project is browsable in eclipse!

Some Helpful Git Commands for the commandline:

git init — Initialize your directory with git.

git add FILE and git checkout — FILE To stage/unstage a file

git commit— To save your changes. This commit will be local

git stash and git stash pop — Stashes are back

git reset HEAD –hard Revert all your local changes

git log— Access all the history in the repository

git rebase –You can squash all the commits! (one should be carefull with this one)

git branch –You can create local branches,But keep the history linear

Hope this workaround and the commands are useful to a new user.

New Active members!

In the coming few weeks you might be seeing lots of activity on the blog!

Credit to : Margi(margi_train) and Pershant(pershant_foodie)!

(Please give them a warm welcome!)

Look forward to their contributions on various technology topics!

Creating a new git project on xp-dev.com with IntelliJ!

Meta Steps, YMMV…

1/Select what you need from Spring INITIALIZR :: https://start.spring.io/
2/Download/Extract the zip && cd into it.
3/Create a git repo on xp-dev.com
4/Initialize Git repo:
a)git init
b)git add .
c)create .gitignore
d)git commit .
e)git remote add origin https://xp-dev.com/git/
f)git push -u origin master
5/Open IntelliJ
a) checkout https://xp-dev.com/git/
b) Goto Maven Projects and add the pom.xml(if not picked automagically by IntelliJ
c)Do deploy, I got a failing unit test, as I added spring-tests.

The IoT AI Manifesto

With the recent sloppiness in implementation of software & hardware and synergizing them into so called the being called IoT  The time is appropriate that a defacto manifesto be brought in place for the artificial species called IoT.

I assume most of us are aware of the Three Laws by Isaac Asimov.

What I propose is build for the interacting robotics with lesser-minded-human-kind!

  1. An equipment if called IoT should abide by:
    1. It should be considered a legal offspring of the last hand-off human entity.
    2. It should have an IDENTU  mode that should let it spill out its purpose/identity/owners.
    3. It should have safe mode where any voice may command it to stop the current action.(something like a STATUE/RESUME mode)

Pretty simple! Very much make-possible!

Thoughts?

What Elon Musk can learn from Java App/Cloud Deployments!

I had an unproductive day yesterday!

I did nothing, but slept through most of the day. And then late night this next challenge of deploying the hush-hush java app over the cloud started to bother me.(afterall it was not a totally unproductive day, thinking wise!)

And then, flash back to a few days, where comparisons were made, what I am doing (javascript ehew!) and what one of the current top living inspiration in the current world Elon Musk is doing, and then I went into sad slumber!

Then yesterday happened, and then it clicked:: we Java devs(web ones, not hard core jdk ones) are orchestrating everything in lifecycle of what Elon Musk is trying to do!

Here is the analogy(it can be extended wonderfully!):

  1. The WAR(Web ARchieve)(sorry, I am old fashioned) is like the unmanned space ship.
  2. The dev JVM is like simulated Mars environment.
  3. The cloud is the SPACE where the bits travel to-and-fro in form of data/packets.
  4. The machine IP Address is like the lat/long of where you want to deploy.

So my current app is in its final integraton phase(hush-hush…) and I am trying to accomplish Slide Driven Development.(nice term!).

Slice Driven Development :: A development approach where a feature/flow is shipped to staging environment as soon as it becomes usable.

Currently I(with @explorer) are trying to integrate all features/flow of the hush-hush app, While I am totally unsure/unaware how it will behave when deployed on staging/production environment. Therefore, I had come up with this approach :: The momemt a feature becomes bug-discoverable, it ought be shipped so that:

  1. Move to the next flow..
  2. Bugs can be quashed..
  3. (most imp)Our path of going from dev–>staging–>production for any feature should be seamless and smooth like  skating on butter!

And then, a Eureka moment happened!! And this blog post came about!

Your Takeaway: If you are on a team working with Elon Musk(or anyone trying to transport stuff from place X to place Y, in an unsure environment), you can leverage from the experience of thousand if not millions of deployments of web java developers trying to deploy WAR file formats from local dev JVM to production JVM.

We know the nuances of this lifecycle!

It might save you some time! 🙂

ReverseLogic ~ Making Ends Meet!