Saturday, April 27, 2013

Install LogMeIn Hamachi with GUI On Ubuntu


LogMeIn Hamachi is a free VPN creator. Hamachi is normally used for playing (multiplayer) games like minecraft. You can install Hamachi on Ubuntu normally but the problem is that you have to use the terminal to work with Hamachi  (i.e there is no GUI). This problem can be tackled with the help of Haguichi. Haguichi gives Hamachi a user interface on Ubuntu. So here is how you install Hamachi with GUI on Ubuntu.

Installing Hamachi:

First we shall install Hamachi the normal way and then add a GUI to it. To install, download .deb install file for Hamachi:
Open .deb after you download it. When you open the file you downloaded, the Ubuntu software center will open with the Hamachi page. Just click on install and Hamachi installation will start. After that is done, we need to install Haguichi. continue to the next step to install Haguichi.

Installing Haguichi:

To install Haguichi in Ubuntu open the terminal and execute the following commands
sudo add-apt-repository ppa:webupd8team/haguichi
sudo apt-get update
sudo apt-get install haguichi
That is all now you have installed Haguichi. After installing Haguichi, you need to configure Hamachi through the terminal and you can use the Hamachi with GUI. That is all. You have successfully installed Hamachi with GUI on Ubuntu .

Thursday, April 18, 2013

Passing a string from c++ to Python function

Passing a string from c++ to Python function and vice-versa:


Initialize all required variables first.
Py_Initialize();
object  main_module = import("__main__");//boost::python objects
object  dictionary = main_module.attr("__dict__");
Run a code to create a variable and set an initial value and print it inside python.
boost::python::exec("resultStr = 'oldvalue'", dictionary);
PyRun_SimpleString("print resultStr");//new value will reflect in python
read the same variable from c++.
boost::python::object resultStr = dictionary["resultStr"];//read value from python to c++
std::string &processedScript = extract<std::string>(resultStr);
Above dictionary object is like a shared map. you can set a variable from c++. Then check the new value from python.
dictionary["resultStr"] = "new value";//set the variable value
PyRun_SimpleString("print resultStr");//new value will reflect in python
Have fun coding. Thanks.