Daily diary

Today, I helped Abhinav Handa’s to solving his problem. Actually, he wants to create a dropdown list in a header of OSM map but OSM overlapped drop-down list. When I searched it on the internet and heard new property in the CSS i.e. z-index. After using z-index then I came to know that every page rendering on the browser has at-least one layer like we use simple div tags in an HTML page then all div is under one layer. Div tag(assume as a layer) which has greater z-index value can overwrite all other div’s.

Everywhere fundamentals are same, we just trying to understand by taking some real world example.:)

Parsing functionality of IfcOpenShell in detail

The parsing functionality is a very interesting feature of IfcOpenShell-python. It enables the user to extract information of his/her interest from a .ifc file. For eg. in the below example, we will extract NominalDiameter, CrossSectionArea etc of reinforcing bar from .ifc file using python interactive shell.

In IfcOpenShell-python there are two main functions present.

  1. by_type(<argument>): This enable the user to what type of information (i.e. IfcProject, IfcRoot, IfcSlab etc.) you want to extract from .ifc file. Arguments name is same as all the entities present in IFC2x4 (http://www.buildingsmart-tech.org). For eg. if user want to extract a information of “IfcWall” then they simple put “IfcWall” as argument.
  2. is_a(): We can use this function in two different ways. For eg. if we use is_a() without any argument then it only tell that information present is belonging to which entity or if we use is_a("IfcWall") with one argrument then it will simply check whether the argument name is same or not with entity name of data present in the form of True or False.

Note: Rest of the classes, functions and there arguments name are same as present in IFC2x4. You can understand more in the below example.

Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> # Importing ifcopenshell                                            
>>> import ifcopenshell                                                 
>>> # Openning .ifc file using open() fuction which is present in ifcopenshell library 
>>> file = ifcopenshell.open("Slab.ifc")                                
>>> # Here we use by_type() function because we want to extract information of IfcReinforcingBar from .ifc file 
>>> rebars = file.by_type("IfcReinforcingBar")                          
>>> # All the rebars present in the .ifc file is store in rebars variable in the form of array
>>> rebars                                                              
>>> [#218=IfcReinforcingBar('3jNYnJqWb9afBZKX5CCrhW',#41,'Rebar Bar:NC Rebar : Shape M_00:390027: 1',$,'Rebar Bar:NC Rebar:53673',#201,#216,'390027',$,16.,0.000201061929829747,5920.,.NOTDEFINED.,$),
 #251=IfcReinforcingBar('3jNYnJqWb9afBZKX9CCrhW',#41,'Rebar Bar:NC Rebar : Shape M_00:390027: 2',$,'Rebar Bar:NC Rebar:53673',#250,#248,'390027',$,16.,0.000201061929829747,5920.,.NOTDEFINED.,$),
 #270=IfcReinforcingBar('3jNYnJqWb9afBZKXDCCrhW',#41,'Rebar Bar:NC Rebar : Shape M_00:390027: 3',$,'Rebar Bar:NC Rebar:53673',#269,#267,'390027',$,16.,0.000201061929829747,5920.,.NOTDEFINED.,$)]
>>> rebar = rebars[0]                                                   
>>> rebar                                                               
>>> #218=IfcReinforcingBar('3jNYnJqWb9afBZKX5CCrhW',#41,'Rebar Bar:NC Rebar : Shape M_00:390027: 1',$,'Rebar Bar:NC Rebar:53673',#201,#216,'390027',$,16.,0.000201061929829747,5920.,.NOTDEFINED.,$)
>>> # Extracting actual data of rebar. Here you will find all the list of arguments present in IfcReinforcingBar (http://www.buildingsmart-tech.org/ifc/IFC2x4/alpha/html/ifcstructuralelementsdomain/lexical/ifcreinforcingbar.htm) 
>>> rebar.NominalDiameter                                               
>>> 16.0                                                                
>>> rebar.CrossSectionArea                                              
>>> 0.000201061929829747                                                
>>> rebar.BarLength                                                     
>>> 5920.0                                                              
>>> rebar.BarRole                                                       
>>> 'NOTDEFINED'                                                        
>>> rebar.BarSurface                                                    
>>> rebar.OwnerHistory                                                  
>>> #41=IfcOwnerHistory(#38,#5,$,.NOCHANGE.,$,$,$,1488377749)           
>>> hist = rebar.OwnerHistory                                           
>>> # Using is_a() function to find the data present in hist variable is belonging to which entity
>>> hist.is_a()                                                         
>>> 'IfcOwnerHistory'                                                   
>>> # Here we check whether a data is belonging to specific entities or not
>>> hist.is_a("IfcOwnerHistory")                                        
>>> True                                                                
>>> hist.is_a("IfcWall")                                                
>>> False                                                               
>>> exit()  


Unlocking Bootloader, Flashing TWRP recovery and Custom rom on Redmi Note 3

  1. Unlocking Bootloader:
    1. Official method: Go to the developer options (Setting>About phone>7 times taps MIUI version) and enable OEM unlocking and USB debugging. Send request on http://en.miui.com/unlock/ to get permission for unlocking bootloader. After 7-10 days from when you got permission, download Mi Unlock tool on Windows and connect mobile to PC/laptop and click on the unlocking button.
    2. Unofficial method: Flash miui rom from edl mode and after that go to fastboot mode and run fastboot oem unlock-go command. Also, you can check whether the bootloader is unlocked or not by run fastboot oem device-info in fastboot mode.
  2. For more detail:

  3. Flashing TWRP recovery:
    1. Backup your all internal storage data.
    2. Download the latest TWRP recovery (https://dl.twrp.me/kenzo/).
    3. Go to the fastboot mode.
    4. Check device is connected or not. (fastboot devices)
    5. Run command fastboot flash recovery <recovery_path>. This command will flash TWRP recovery on mobile.
    6. Also run fastboot format userdata. This command will actually remove all enycrpted/normal data in the internal storage which TWRP recovery cannot read it.
    7. Then run fastboot boot <recovery_path>. This command boot your device into twrp recovery.
  4. Flashing custom roms:
    1. Download LineageOS (https://download.lineageos.org/) for Redmi note 3 (kenzo) into internal storage.
    2. Boot into TWRP recovery by pressing power button and volume up simultaneously.
    3. Then go to wipe>advanced wipe>select Dalvik/ART Cache, Data and Cache>then Swipe to Wipe.
    4. After that go to Install>select custom rom.zip>then click on Install Image.
    5. Last again Wipe only Dalvik cache and then go to reboot>system reboot.
    6. Done

Stack vs Heap

In C and C++, the memory assigned to a program in typical architecture is divided into four parts:

  1. Code(Text): set of program instructions.
  2. Global/Static: For global variables and static variables.
  3. Stack: Information of function calls and local variables are stored in this part. Memory assigned to the stack depends on the compiler design.Example with code
    #include <iostream>
    using namespace std;
    int sum(int a,int b){
    return a+b;
    int main()
    int x = 5, y = 6;
    cout << "Sum of two numbers: " << sum(x,y) << endl;
    return 0;

    In the above example, a stack is empty before the execution of program but when program starts executing and now the top of a stack is local variables (i.e. x and y) and after that top of the stack is cout instruction which calling to the sum function and now the top of the stack is sum function. The computer only executes the top of the stack instruction and when a top of the stack instruction is finished then the control of execution of the program is transfer to the below instruction (which is now the top of the stack because instruction on the top of this instruction is finished). When the stack is empty it means a program is executed.

    Note: If our stack is going beyond the reserved memory of the stack and our program exhausted all the memory of the stack called stack overflow and in this case, our program is crashed. For eg. bad recursion and our programs goes infinite loop.

  4. Heap (free store of memory): Allocating large amount of memory then we have a heap or giving the memory of the array at run-time. The programmer can totally control to how much memory can use from the heap and the size of the heap varying according to system time.
    To use dynamic memory of heap in C++ we use new and delete operators.Code:

    #include <iostream>
    using namespace std;
    int main()
        int *p;
        // Allocating memory of size int in heap using new operator
        p = new int;
        *p = 10;
        cout << "Value of p: " << *p << endl;
        delete p;
        return 0;

Learning and challenging days

Today I made a few bash scripts which read the data from the file and then process that data in a meaningful way by using Grass software. I have also learnt stuff related to contour by Grass software.

One interesting thing happened today

When I have given my bash script to Amarjeet and he runs my bash script as sh myscript.sh and it gave an error “Unexcepted token error [[” but on my laptop was working fine. On my laptop I run my bash script as ./myscript.sh and then after some time I found the answer that why script gives an error on Amarjeet’s laptop. Actually, he runs my script in sh shell whereas I have written my script according to the bash shell and then I told to Amarjeet to run my bash script as bash myscript.sh or as ./myscript.sh.

Daily diary

Today, I tried to draw dimensions of a part by using the Draft workbench of FreeCAD. However, I can draw the dimensions of through coding but many things that I have to keep in mind like page offset and position of three vectors etc.

I also solved one program of “Roy and Profile Picture” (https://www.hackerearth.com/problem/algorithm/roy-and-profile-picture/) in C++. Here is the solution of the above problem.