Posts

Taking notes

Over the last 100 days, my learning curve has been extremely steep. Taking notes has been my habit ever since the 1st year of my college. I always love to write down things that I have learned. Jotting down notes gives me the final confidence about the things that I have learned. It also helps me in quickly ramping up the concepts again when required.  I have written over 50 notebooks containing notes related to my profession, i.e. Computer Science and several more on other areas of interest. I have kept them very carefully and carry each one of them wherever I relocate to (mostly in the hope that I will get a chance to go through them one day). When I look back now, I see that my notes suffer from some serious problem: Outdated information:  Since, computer science is an ever-changing domain, most of my notes are now outdated. A few notes like those related to C++, Java, Algorithms and Design Patterns are still good enough. Other notes like that on Hyperledger (a blockchain framework)

The switch-case fall through

So, I am a Software Engineer at a reputed firm and still fell for the trap of fall-through feature of the switch-case statement. Rule of thumb: Starting from the matched case, all statements are executed, unless a break statement is reached. After the break statement, the control is transferred to the statement next to the switch-case block.  Here are some examples to test your understanding of switch-case: The output of the example is AB . This is because there is no break statement and so all the statements are executed after the first match of case 0. The output of the example is BCD . This is because there is no break statement and so all the statements are executed after the first match of case 1. The output of the example is AB . This is because there is a break statement at the end of case 1 so, after the first match at case 0, all the statements are executed till the break statement. The output of the example is AB . This is because there is a break stateme

Constructor of a Fragment in Android

Recently, I came to a very strange issue in Android development and I wish to share a very important lesson. As an Android developer, you might be knowing that most of the crashes are related to lifecycle events of Activities and Fragments. Moreover, most phone manufacturers patch the original Android system to come up with their own versions. Such versions might have a hostile kernel which may kill Activities more frequently to claim more free space and faster performance for foreground apps. This makes Android development difficult as you have to check for each of the edge cases that may occur. One of the best ways to debug such crashes is to use the " Don't Keep Activities " feature of the development mode. This kills the Activities and the fragments as soon as the app goes to the background. Enable this mode and start your app and navigate through all your Activities and Fragments. If you get no faulty behaviour, then your app is of quality-at-par. Let's

Rendering Performance Evaluation - Android SDK vs React Native

Image
UI rendering speed has always been a key for evaluating a new technology. The lesser is the rendering time, the more preferable is the technology. In the recent times, React native has become very popular for developing native apps. Such apps are truly native and way different from similar other technologies like Xamarin and Cordava. I got some time to evaluate how React Native compares to Android SDK. TLDR: As you might expect, Android SDK outperforms React Native by a huge margin. But React native technology is slowly catching up (most of the credits goes to the amazing diff rendering technology which forms the core of React). React native is efficient enough for apps with small number of UI components which could be rendered within reasonable time. Performance comparison Emulator used for evaluation Model - Google Pixel 2 API Level - 24 Resolution - 1080 x 1920 (420 dpi) CPU - x86 Target - Android 7.0 RAM - 1536 MB Evaluation criteria We will be creating a large

Calling C++ native code from Java

Recently, I faced a lot of troubles in finding a good article that completely explains the process of calling a C++ native function from Java. I did some experiments and I finally succeeded. I will be sharing the instructions step-by-step. In this article, I will be taking a very basic example of taking an array of numbers as input in Java, computing their sum using a native C++ code and then printing the output back to the console using Java. I would be keeping the article concise and would encourage you to explore the official documentation in case you run into some issues. Also, I will be using Windows and GCC compilers. A 32-bit C++ compiler is compatible with 32-bit Java compiler and a 64-bit C++ compiler is compatible with 64-bit Java compiler. MinGW doesn't publish x64 versions of GCC compilers for Windows (it is only available for Linux). So, in case you are using Windows make sure that you install 32-bit Java version. I am also assuming that you are using JDK 8 or some

Popular ethical hacking tricks on LAN

Birla Institute of Technology, Mesra has a large Local Area Network. Several computers are connected through hundreds of routers and switches. The local network has served several purposes whether it is file sharing through DC or organizing an online event. Such interconnection has made it vulnerable to attacks. The LAN is based on old ethernet technology. It is a good playground to practice ethical hacking. I am going to list you some working techniques that can be easily tried. I won't be telling you complete steps on how to do it. Please use it for learning purpose only. 1. Brute-force to any local website Everyone has to login to Cyberoam before they can access the fast Internet available on the ethernet. There are several automated scripts written in various languages to login to Cyberoam. Since Cyberoam is available on a local network, it is much faster to get the response for login credentials. Once the path is resolved, it takes a maximum of 5 hops for the packet to re

Setting up DC Hub on Raspberry Pi

Aditya Pal came to my room to check out a Raspberry Pi that I recently got as a gift. I told him, it a small credit card size computer. It powers on as soon as you plug in and boots up fast. I was already using it as a server for other purposes (hosting BitZoom). Our hostel at college had a strange network issue. The intra-hostel network worked smoothly. But, we had to face a lot of issues outside of the hostel (especially at Hostel 7 when it was disconnected from the external network for a month). The college's official DC was on the external network and it was inaccessible for quite a long time whenever we faced network issues. Aditya suggested me the idea of setting up DC on Raspberry Pi for the students of the hostel. We worked together for a few days to finally set up DC on Raspberry Pi named Raspbian . It remained active for over a year unless the college administration finally decided to shut it down due to network congestion. There were already 4 active hubs drawing traffi