MySQL 5.5 亂碼問題的解決

亂碼問題大家衆所周知皆由編碼引起,所要解決之道就是使用一致的、可顯示的編碼方式。

 

創建數據庫時:

CREATE DATABASE [Database Name] CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';

 

創建表格時:

CREATE TABLE OpenCourses (
    semester CHAR(255) NOT NULL,
    course_id CHAR(8) NOT NULL,
    teacher_id CHAR(4) NOT NULL,
    time CHAR(255),
    PRIMARY KEY(semester, course_id, teacher_id),
    FOREIGN KEY(course_id) REFERENCES Courses(id),
    FOREIGN KEY(teacher_id) REFERENCES Teachers(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
這樣在INSERT的時候就無大礙了。
 
(注意:顯示的時候也需要使用UTF-8解碼,比如CMD使用的是ANSI或是GBK,這樣是不行的)
 

ROS Package Update Problem

I was facing a problem when I updated ROS groovy package on Oct.2, 2013.
When sourcing the workspace's setup.zsh, I'm getting this problem:
 
Problem Description:
/opt/ros/groovy/etc/catkin/profile.d/15.rosbash.zsh:.:3: no such file or directory: /share/rosbash/roszsh
[rospack] Warning: ROS_ROOT=/share/ros is not a directory
 
(It'll show up if you use bash as well)
 
How to Solve:
Under your workspace, do a catkin_make.
>> catkin_make
 
Why:
Because the update changed the directory structrue of ROS and the old `devel` information would not work any more.

Qt 5.1.0 on Ubuntu Linux, MySQL database connection problem, driver not loaded problem

Qt 5.1.0 on Ubuntu Linux, MySQL database connection problem, driver not loaded problem


Problem description

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
false

Read more

Ubuntu 12.04 Install Gazebo ROS Package (gazebo_ros_pkgs) 1.9 From source

Ubuntu 12.04 Install Gazebo ROS Package (gazebo_ros_pkgs) 1.9 From source

Read more

使用boost python的hello tutorial

安裝BOOST: http://www.boost.org/doc/libs/1_54_0/more/getting_started/index.html

增加C++的include directory使之能找到pyconfig.h等文件。

>> export CPLUS_INCLUDE_PATH=/usr/include/python2.7/:$CPLUS_INCLUDE_PAYH

寫一個簡單的測試程序:

>> cat hello.cpp

#include <iostream>

using namespace std;

void say_hello(const char* name) {
    cout << "Hello " <<  name << "!\n";
}

int main(){return 0;}

#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
using namespace boost::python;

BOOST_PYTHON_MODULE(hello)
{
    def("say_hello", say_hello);
}

編譯:
>> g++ hello.cpp -lboost_python -lpython2.7 -shared -fPIC -o hello.so
>> ls
出現有hello.so
python中的用法:

>> python
Python 2.7.3 (default, Apr 10 2013, 06:20:15)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hello
>>> hello.say_hello('Bill')
Hello Bill!
>>>