Pages

Wednesday, December 30, 2020

Speed test of various dart outputs

Recently, I was playing around with dart and got to know that it supports output of various types. So curiosity arises that which one would be fastest.

So to find out that I used basic hello-world sample

After that, I wrote the bash script


Test Result

On execution of this shell script, I got this

% sh build.sh


Raw

Hello, World!


real 0m0.285s

user 0m0.283s

sys 0m0.077s


Snapshot

Hello, World!


real 0m0.119s

user 0m0.138s

sys 0m0.027s


Executable

Generated: /.../test.exe

Hello, World!


real 0m0.118s

user 0m0.007s

sys 0m0.014s


Aot

Generated: /.../test.aot

Hello, World!


real 0m0.019s

user 0m0.007s

sys 0m0.009s



Observation

Then accumulated these data to process it as a chart that shows the speed test result


Here, 
  • Raw refers to the raw source-code
  • Snapshot refers to the platform independent intermediary code
  • Executable refers to the platform dependent native executable file
  • Aot refers to the AOT file for VM

Conclusion 

The speed in descending order would be like this,

AOT > Executable > Snapshot > Raw

So the execution speed of AOT is fastest whereas Raw is slowest.

Friday, December 18, 2020

Instead of using very + another word, find single word

Instead of using, very + another word, you can always find a single word that's more precise, descriptive and elegant.

For example,  excellent = very good

List of A to Z words with 'very' and equivalents


  • very able = proficient
  • very boring = tedious
  • very confused = baffled
  • very dirty = filthy
  • very easy = effortless
  • very funny = hilarious
  • very glad = overjoyed
  • very happy = ecstatic
  • very interesting = fascinating
  • very joyful = exuberant
  • very kind = compassionate
  • very large = huge
  • very mad = demented
  • very nasty = obnoxious
  • very old = ancient
  • very painful = excruciating
  • very quite = hushed
  • very rude = boorish
  • very shy = timid
  • very tired = exhausted
  • very ugly = hideous
  • very vicious = malicious
  • very wicked = evil
  • very xenophobic = jingoistic
  • very young = juvenile
  • very zen = meditative

Tuesday, January 21, 2020

Solved mission critical problem using reverse engineering

Here I'm sharing an incident that happened in 2017, when I had managed to solve a mission critical problem using reverse engineering and what I have learnt from it.

The incident was when I have been allocated a migration task. My whole project was migrated to webpack from system.js due to which integration build generator broke. So I got this task to migrate that integration build generator too and make it compatible to webpack within a week. I knew that I got this after another colleague failed to complete it in previous sprint. So there was a higher chance of missing the deadline because half of the time was already got consumed by previous colleague. I got this issue when it was about to be escalated in case I fail.

I thought if I'll go by the same path as my colleague then I may get the same result that he got. So I changed my strategy and look into the problem by reverse engineering it. Well, doing that gave me enough hints to solve the problem and fix the generator by having minimal impact. So after doing further analysis, I'd managed to fix the issue in 40% less time than was initially expected.

From this incident I learnt that sometimes it's good to see the problem from reverse angle instead of just front view.

How to secure Cordova based hybrid Android mobile app?

The incident I'm sharing here was happened in 2015, when we faced a complicated technical problem while working on an IoT project. 

We were having a mobile app to control smart electronic appliances that consumes our web-service. A third party group somehow managed to use our mobile app with their service. We assume that they had reverse engineered to crack the services. So we had to protect our mobile app which was Cordova based hybrid cross-platform app. 

I have been allocated to analyse this issue and propose a solution. So during my initial analysis I found that first we should secure the mobile application installer because Android's .apk installation file usually packaged together all the resource files used in the hybrid project. Crackers could reverse engineer it to get those files. I know that we can ensure protection only by increasing the level of security.

So I minified all the files, bundled together and applied obfuscation over it; which made hybrid portion bit more secure. After this I used Arxan to protect the mobile app at binary level.

The next step was to ensure the service authenticity; for which I'd used session based synchronous incremental token validation system on app level and get it implemented on a web-service layer to support it.

The outcome was that our app become much more secure & protected. It took few releases till all the users updated the app. Now the third party has stopped supporting our app as we don't see any cross origin requests in our logs.

From this incident we learned that usually we think that the project is at startup level, so they don't worry much about security and protection of the project initially. But with time project grows, it becomes more vulnerable. So we should always keep in mind the basic things like security; during the startup phases.

Now I use this app protection technique in all other enterprise level apps and try to get it implemented during the startup phase.

Monday, January 13, 2020

Why did Vedic Mathematics originated?

What do you think, why did the vedic mathematics originated?

According to the popular beliefs related to Ancient people in Indian sub-continent that since they did not had access to paper or similar material where they can carry out long calculations. So they would require to carry out whole calculations mentally because any kind of calculating machines was out of question in those times.

Well the real reason is way beyond that, which is related to our saints and maharishis of those times. By studying the scriptures of ancient maharishis, we came to know that almost all the maharishis were like scientist and were great yogis.

In ancient India, maharishis used to separate their soul out of their body but still linked to their respective bodies using advanced yoga techniques that might be related to kundalini yoga or something similar.

Similar, soul-out-of-body concept was shown in the "Dr. Strange (2016)" movie that they called astral form.

Soul neither have mass like weight nor have any dimensions like width or height. So being a soul maharishis can go anywhere even inside atom or outside earth. There will be no physical limit.

Now suppose, if you were a soul and you got inside molecule then how would you manage to measure the size of it's atom. The measurement is relative, which means to measure the size of anything, you would require to compare it with its surrounding then by applying the geometrical theorems, you would be able to measure the size of targeted object.

For your ease, you could consider the movie, "Honey, I Shrunk the Kids (1989)" where Wayne Szalinski, the inventor tries his best to get his recent invention, a shrinking machine, to work. Things go awry when he accidentally shrinks his children and throws them along with the garbage.

The plot of this movie is very much related to the scenario we are discussing about like when those children became so small that even the ant seems to be size of elephant; in that situation consider measuring the height of those ants or grass they hopped without having a scale or inchtape. Well without having any instrument to measure it would become a lot much difficult task unless you know the Mathematics, in fact Trigonometry and Coordinate Geometry to be specific.

Anyways, being a soul you can not write anywhere. So how would you carry out complex calculations like:
  • Size of the atom
  • Speed of electron
  • Mass of nucleus 

Well it would be very difficult for any human being to memorize all the steps of calculations until you get the result, but if you have read vedic mathematics then you would know that it would be relatively much simpler using vedic mathematics.

Some of you might question that why didn't they return back to write their observations somewhere and then again go back as soul to observation. It would be difficult because, even for yogis this whole process takes time. So going back and forth would be out of question.

Thus, they would have to devise mental mathematics techniques to acheive their respective goals.
Now we call that 'Vedic Mathematics', after sadguru sankaracharya first wrote it down in the form of book.

Telephone or Mobile number codes

Note: This is an archived article of Dec 4, 2009

Monday, January 6, 2020

Speed test of wasm at node vs deno vs wapm

Recently, I have created an app in Rust language for macOS then to make it cross-platform, ported it for other platforms using WebAssembly.

I have ported the app for these platforms:
  1. WAPM ⟶ Using WASI file as binary, i.e., generated via Rust
  2. Deno ⟶ Using WASM file as library, i.e., generated via Rust
  3. Node.js ⟶ Using WASM file as library, i.e., generated via Rust

Initially, I had made it on macOS where it runs very fast but on Windows it gets slowed down so much that is clearly visible.

So I tried to measure it somehow for which I took a command for the app which decodes the input parameter. Here is that command,

> ds -d 31kk ⟶ 3-1-2020

Now I need to measure the timelapse after each execution for which I'd used

> w32tm /query /status /verbose | find "Time since" && node ds -d 31kk && w32tm /query /status /verbose | find "Time since" && deno ds -d 31kk && w32tm /query /status /verbose | find "Time since" && wapm run ds -d 31kk && w32tm /query /status /verbose | find "Time since"

Where the application versions used for each platforms are
  • wapm ⟶ 0.4.1
  • node ⟶ 10.16.3
  • deno ⟶ 0.28.0

Observation

So I got the data, which after processing gave me below table after 5 iterations on each platform at Windows.

Iteration node deno wapm
1
3.2647508
3.4102478
5.6514979
2
3.3473772
3.7920618
5.5733467
3
3.3808841
3.5171131
5.5754807
4
3.1901506
3.5294571
5.6883964
5
3.412068
3.577498
5.6723193

In the above, table cell values are given in seconds.

Below is the plotted bar chart for this table.


Conclusion

As you can see in the chart the speed of node is highest while of wapm is lowest.

So the speed in order would be like this,


There is marginal difference in between node & deno which uses wasm in comparison to wapm which uses wasi.

The wapm is wasmer based package manager and wasi runtime.