Posts

Add javascript and css file with spring mvc

  https://mkyong.com/spring-mvc/spring-mvc-how-to-include-js-or-css-files-in-a-jsp-page/ < mvc :resources mapping ="/resources/**" location ="/resources/" /> < mvc :annotation-driven /> This should be together otherwise resouce mapping will not function. it should be in spring-servlet.xml file

code 400, message Bad request syntax in ec2

 This is because of using https instead of http

flask_mysqldb error in aws

It is because the dependency is not fulfilled in elastic bean. So using ec2, i created my own ubuntu and install the dependency below:    sudo apt-get install python-dev default-libmysqlclient-dev libssl-dev then: pip install --user flask-mysqldb

Installing package with python env commandline

  python3 -m pip install --user virtualenv create virtual env: python3 -m venv env activate the env: source env/bin/activate check: which python install from requirements file pip install -r requirements.txt

Grant all priviledge to new user

enter into database with: sudo mysql -u root and type:   GRANT ALL PRIVILEGES ON *.* TO 'puri'@'%';

undefined reference to `vtable for Game'

 The problem to this is that, all the virtual for the table should be define. when the pointer reach the vtable, it ll search for all the references for the virtual function in the class. if it couldnot find it then the error "undefined reference to "vtable for Game" is given. The solution is to implement all the virtual function presented in the class and its sub classes as well. Stack overflow example. https://stackoverflow.com/questions/9406580/c-undefined-reference-to-vtable-and-inheritance

Smart Pointer

When ever you create a object of class, deconstructor will be called automatically, but when you make pointer of that class, the deconstructor won't be automatically  called. So you have to use smart pointer to de-allocate the memory. MyInt my_int ( 10 );  // This will call the destructor MyInt *my_int = new MyInt(10); // this won't automatically call the destructor Unique Pointer:  #include <memory> class MyInt { private : int x ; public : MyInt ( int p ) { x = p ; } ~MyInt () { std :: cout << " deconstructor " << std :: endl ; } int getData () { return x ; } }; int main() { // MyInt my_int(10); // std::cout << "My Int " << my_int.getData() << std::endl; std::unique_ptr<MyInt> p( new MyInt( 10 )); // Here the p will be created on stack not on heap std::cout << p->getData(); /...