Conan C++ Package Manager

install conan

sudo apt install python3-pip
pip install conan

looking for library

conan search poco --remote=conancenter
poco/1.8.1
poco/1.9.3
poco/1.9.4

creating a conanfile.txt inside our project’s folder with the following content:

[requires]
 poco/1.9.4

 [generators]
 cmake

Next step: We are going to install the required dependencies and generate the information for the build system:

$ conan profile new default --detect  # Generates default profile detecting GCC and sets old ABI
$ conan profile update settings.compiler.libcxx=libstdc++11 default  # Sets libcxx to C++11 ABI
$ mkdir build && cd build  #create build folder of cmake binary
$ conan install ..           #install libraries
#or conan install .. --settings os="Linux" --settings compiler="gcc"

Now let’s create our build file. To inject the Conan information, include the generated conanbuildinfo.cmake file like this:

 cmake_minimum_required(VERSION 2.8.12)
 project(MD5Encrypter)

 add_definitions("-std=c++11")

 include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
 conan_basic_setup()

 add_executable(md5 md5.cpp)
 target_link_libraries(md5 ${CONAN_LIBS})

C Libraries

stdlib

double atof(const char *str)
Converts the string pointed to, by the argument str to a floating-point number (type double).
int atoi(const char *str)
Converts the string pointed to, by the argument str to an integer (type int).
long int atol(const char *str)
Converts the string pointed to, by the argument str to a long integer (type long int).
double strtod(const char *str, char **endptr)
Converts the string pointed to, by the argument str to a floating-point number (type double).
long int strtol(const char *str, char **endptr, int base)
Converts the string pointed to, by the argument str to a long integer (type long int).
unsigned long int strtoul(const char *str, char **endptr, int base)
Converts the string pointed to, by the argument str to an unsigned long integer (type unsigned long int).
void *calloc(size_t nitems, size_t size)
Allocates the requested memory and returns a pointer to it.
void free(void *ptr)
Deallocates the memory previously allocated by a call to calloc, malloc, or realloc.
void *malloc(size_t size)Allocates the requested memory and returns a pointer to it.
void *realloc(void *ptr, size_t size)
Attempts to resize the memory block pointed to by ptr that was previously allocated with a call to malloc or calloc.
void abort(void)
Causes an abnormal program termination.
int atexit(void (*func)(void))
Causes the specified function func to be called when the program terminates normally.
void exit(int status)
Causes the program to terminate normally.
char *getenv(const char *name)
Searches for the environment string pointed to by name and returns the associated value to the string.
int system(const char *string)
The command specified by string is passed to the host environment to be executed by the command processor.
void *bsearch(const void *key, const void *base, size_t nitems, size_t size, int (*compar)(const void *, const void *))
Performs a binary search.
void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))
Sorts an array.
int abs(int x)
Returns the absolute value of x.
div_t div(int numer, int denom)
Divides numer (numerator) by denom (denominator).
long int labs(long int x)
Returns the absolute value of x.
ldiv_t ldiv(long int numer, long int denom)
Divides numer (numerator) by denom (denominator).
int rand(void)
Returns a pseudo-random number in the range of 0 to RAND_MAX.
void srand(unsigned int seed)
This function seeds the random number generator used by the function rand.
int mblen(const char *str, size_t n)
Returns the length of a multibyte character pointed to by the argument str.
size_t mbstowcs(schar_t *pwcs, const char *str, size_t n)
Converts the string of multibyte characters pointed to by the argument str to the array pointed to by pwcs.
int mbtowc(whcar_t *pwc, const char *str, size_t n)
Examines the multibyte character pointed to by the argument str.
size_t wcstombs(char *str, const wchar_t *pwcs, size_t n)
Converts the codes stored in the array pwcs to multibyte characters and stores them in the string str.
int wctomb(char *str, wchar_t wchar)
Examines the code which corresponds to a multibyte character given by the argument wchar.
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main () {
   int n=4;//number of elements
   int *a;
   a = (int*)calloc(n, sizeof(int));

   char *str;
   str = (char *) malloc(15);
   strcpy(str, "tutorialspoint");
   str = (char *) realloc(str, 25);
   strcat(str, ".com");//append string

   free(str);
   free( a );
   
   return(0);
}

TypeScript

install and config with npm

npm install typescript -D -g
npm link typescript
npm install -D ts-node
npm install -P @types/node

add scripts to package.json

"scripts": {
    "start": "node --inspect=5858 -r ts-node/register ./tutorial.ts",
    "build": "tsc  && copyfiles -U 1 ./**/*.env ./dist"
  }

build script convert all ts files to js and move it to ./dist folder

copyfiles is a tool to help you to move files to destination folder

npm install -D copyfiles

tsconfig.json file  in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project.

{
    "compilerOptions": {
        "module": "commonjs",
        "moduleResolution": "node",
        "pretty": true,
        "sourceMap": true,
        "target": "es6",
        "outDir": "./dist",
        "baseUrl": ".",
    },
    "include": [
        "./**/*"
    ],
    "exclude": [
        "node_modules",
        ".vscode"
    ]
}

so once you call tsc command it will build all files specified by tsconfig.json to target

let var1:string|number=44;
let var2:object={};
let var3:any;
let var4:void;//null or undefined
//===============================
let strArr:string[];//accept only array of string
let strArr2:[string,number];//tuple string,number
let strArr3:Array<string>;
//========================
let any:any;//take any value
let fun:(a: string) => void;//function type

TypeScript interface

interface Options {
  color: string;
  volume: number;
}
let options = {} as Options;
options.color = "red";
options.volume = 11;
interface User {
  name: string;
  id: number;
}
class UserAccount {
  name: string;
  id: number;
  constructor(name: string, id: number) {
    this.name = name;
    this.id = id;
  }
}
const user: User = new UserAccount("Murphy", 1);
interface  A{
    val1:string;
    val2:number;
}
class AA{
    val1:string;
    val2:number;
    val3:string;
    constructor(name:string,age:number) {
        this.val1=name;
        this.val2=age;
        this.val3=name+age;
    }
}
let val:A=new AA("hello",12);
console.log(val);

classes and abstract classes

interface IPerson {
    name: string;
    display():void;
}

interface IEmployee {
    empCode: number;
}

class Employee implements IPerson, IEmployee {
    empCode: number;
    name: string;
    
    constructor(empcode: number, name:string) {
        this.empCode = empcode;
        this.name = name;
    }
    
    display(): void {
        console.log("Name = " + this.name +  ", Employee Code = " + this.empCode);
    }
}

let per:IPerson = new Employee(100, "Bill");
per.display(); // Name = Bill, Employee Code = 100

let emp:IEmployee = new Employee(100, "Bill");
emp.display(); //Compiler Error: Property 'display' does not exist on type 'IEmployee'
class Car {
    name: string;
        
    constructor(name: string) {
        this.name = name;
    }
    
    run(speed:number = 0) {
        console.log("A " + this.name + " is moving at " + speed + " mph!");
    }
}

class Mercedes extends Car {
    
    constructor(name: string) {
        super(name);
    }
    
    run(speed = 150) {
        console.log('A Mercedes started')
        super.run(speed);
    }
}

class Honda extends Car {
    
    constructor(name: string) {
        super(name);
    }
    
    run(speed = 100) {
        console.log('A Honda started')
        super.run(speed);
    }
}

let mercObj = new Mercedes("Mercedes-Benz GLA");
let hondaObj = new Honda("Honda City")

mercObj.run();  // A Mercedes started A Mercedes-Benz GLA is moving at 150 mph!
hondaObj.run(); // A Honda started A Honda City is moving at 100 mph!
class StaticMem {  
   static num:number; 
   
   static disp():void { 
      console.log("The value of num is"+ StaticMem.num) 
   } 
} 

StaticMem.num = 12     // initialize the static variable 
StaticMem.disp()      // invoke the static method
abstract class Person {
    abstract name: string;

    display(): void{
        console.log(this.name);
    }
}

class Employee extends Person { 
    name: string;
    empCode: number;
    
    constructor(name: string, code: number) { 
        super(); // must call super()
        
        this.empCode = code;
        this.name = name;
    }
}

let emp: Person = new Employee("James", 100);
emp.display(); //James
class StaticMem {  
   static num:number; 
   
   static disp():void { 
      console.log("The value of num is"+ StaticMem.num) 
   } 
} 

StaticMem.num = 12     // initialize the static variable 
StaticMem.disp()      // invoke the static method

namespace

namespace SomeNameSpaceName { 
   export interface ISomeInterfaceName {      }  
   export class SomeClassName {      }  
} 
SomeNameSpaceName.SomeClassName;

as keyword

const myCanvas = document.getElementById("main_canvas") as HTMLCanvasElement;

type aliases

type func=(a: string) => void;
type Point = {
  x: number;
  y: number;
};
 
// Exactly the same as the earlier example
function printCoord(pt: Point) {
  console.log("The coordinate's x value is " + pt.x);
  console.log("The coordinate's y value is " + pt.y);
}
 
printCoord({ x: 100, y: 100 });

ubuntu C++ configurations

build-essential : tools and libraries that are required to compile a program. For example, if you need to work on a C/C++ compiler, you need to install essential meta-packages on your system before starting the C compiler installation. When installing the build-essential packages, some other packages such as G++, dpkg-dev, GCC and make, etc. also install on your system.

Cmake + Ninja

GDB: The GNU Project Debugger

then for Qt and vcpkg

Besides build-essential and cmake you need to install git

for vcpkg

sudo apt-get install curl zip unzip tar
sudo apt-get install pkg-config
apt install gperf
sudo apt-get install bison
sudo apt install git
sudo apt install autopoint  
sudo apt install gettext
sudo apt install libtool 

for Qt

sudo apt-get install mesa-common-dev
sudo apt install libglu1-mesa-dev -y
sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev
sudo apt install libfontconfig1-dev libfreetype6-dev libx11-dev libx11-xcb-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-util-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev

Conic Sections

Common Parts of Conic Sections

A focus is a point about which the conic section is constructed. In other words, it is a point about which rays reflected from the curve converge. A parabola has one focus about which the shape is constructed; an ellipse and hyperbola have two.

A directrix is a line used to construct and define a conic section. The distance of a directrix from a point on the conic section has a constant ratio to the distance from that point to the focus. As with the focus, a parabola has one directrix, while ellipses and hyperbolas have two.

Eccentricity

  • 0 < eccentricity < 1 we get an ellipse,
  • eccentricity = 1 a parabola, and
  • eccentricity > 1 a hyperbola.

A circle has an eccentricity of zero, so the eccentricity shows us how “un-circular” the curve is. The bigger the eccentricity, the less curved it is.

Porabolla

A parabola is a curve where any point is at an equal distance from:

  • a fixed point (the focus ), and
  • a fixed straight line (the directrix )

Ellipse

“F” is a focus, “G” is a focus,and together they are called foci (pronounced “fo-sigh”).
The total distance from F to P to G stays the same
Well f+g is equal to the length of the major axis.

Hyperbola

A hyperbola is two curves that are like infinite bows.
Looking at just one of the curves:
any point P is closer to F than to G by some constant amount
The other curve is a mirror image, and is closer to G than to F.

  • an axis of symmetry (that goes through each focus)
  • two vertices (where each curve makes its sharpest turn)
  • the distance between the vertices (2a on the diagram) is the constant difference between the lengths PF and PG
  • two asymptotes which are not part of the hyperbola but show where the curve would go if continued indefinitely in each of the four directions

Hyperbolic functions

Catenary (hanging cable)

Math Problems 1

Problem 1

what is the area of the rectangle?
the minimum area of the triangle satisfied these conditions?

part 1

so the area of a rectangle is

xy=12

part 2

Problem 2

find the radius of biggest circuit

take first two circuits
hypotenuse of both are collinear

Problem 3

a cable of 80 meters hanging from the top of two poles there are two 50 meters from the ground
what is the distance from two poles if center of cable 20 meters above the ground ?

Problem 4

find the area of the red segments