Friday, September 30, 2016

How to install new chrome on Ubuntu 12.04

The official Google Chrome website only keeps the link to the latest Chrome which is right now 53. But 53 could not be installed on Ubuntu 12.04 because 12.04 has old g++ (4.6), while Chrome needs at least g++ 4.8.

We could only install some old version of Chrome:
http://www.slimjet.com/chrome/google-chrome-old-version.php

, e.g., Chrome 48 could work on Ubuntu 12.04.

How to migrate git repo from one server to another

Your company may have changed its git server. You need to use the new git server, but your company did not migrate your repository.

A simple way you could do is that:
(1) clone the latest copy of your repo from the old git server;
(2) change the git url in your cloned copy:
git remote set-url origin ssh://git@bitbucket.com/your-repo-name.git
(3) git push -u origin master

After the steps, you will have your master branch in the new repo.

Install Ubuntu 12.04 in VirtualBox on MAC OS



Installation environment



(1) Macbook Pro:


  • Macbook: Retina
  • CPU: Intel Core i7
  • Memory: 16GB 1600MHz DDR3
  • Video card: NVIDIA GeForce GT 650M 1024 MB
  • Host OS: OS X 10.9.5

(2) Virtual machineProvider: VirtualBox 4.2.20 or 5.0.22 (I also tried the latest one, VirtualBox 4.3, but failed to change the guest OS (Ubuntu) resolution)
Guest OS: Ubuntu 12.04.3 desktop version 64bit

Steps:


(1) Download VirtualBox 4.2.20 and install it on Macbook;
(2) Download Ubuntu 12.04 AMD 64 Desktop from its official website;
(3) Create a virtual machine in VirtualBox (Do note that you need to specify the "Type" as "Linux" and the "Version" as "Ubuntu (64 bit)") with a disk space more than 10GB;
(4) Mount the downloaded Ubuntu image to the CDROM of the created virtual machine;
(5) Start the virtual machine and install Ubuntu on the machine;
(6) After the installation is done, start virtual machine and login the Ubuntu just installed;
(7) The default screen resolution is 1024*768, which is surely too small, to fix which we click the menu "Devices -> Install Guest Additions" of VirtualBox VM; in the Ubuntu, you will find some pop-up window asking you whether to install the new package; just follow the instructions to install the guest additions; please do not install the the guest additions using apt-get in Ubuntu, which may crash the whole Ubuntu somehow;
(8) Restart the virtual machine, and now the screen size can be automatically changed to fit the window size of the virtual machine.
(9) If you need Ubuntu to display emojis correctly, you have to install some new fonts: download Symbola.ttf from http://users.teilar.gr/~g1951d/ in the Ubuntu virtual machine, and then double click the ttf file and click install to add the font to Ubuntu.


References:

http://askubuntu.com/questions/22743/how-do-i-install-guest-additions-in-a-virtualbox-vm




Thursday, September 29, 2016

How to quickly benchmark mysql with mysqlslap

MySQL client also provides a benchmarking tool called mysqlslap which could be installed on CentOS by:
sudo yum install mysql

If you just want to quickly benchmark some database with a simple query, you could try something like:
mysqlslap --user=[YourUsername] --password=[YourPassword] --host=[YourHostname] --verbose --concurrency 10 --iterations 10 --query 'SELECT * from [YourDatabaseName].lookup_en' --create-schema=[YourDatabaseName]

If you want to know more options, please refer to the Reference.


Reference:
http://dev.mysql.com/doc/refman/5.7/en/mysqlslap.html

Wednesday, September 21, 2016

How to use Eclipse with an existing sbt project

Assuming there is a sbt project, and now you want to use Eclipse to maintain the project.

(1) Install sbteclipse plugin in your sbt project to generate Eclipse project configs
You should follow the instruction on (use "sbt sbtVersion" to get your sbt version):
https://github.com/typesafehub/sbteclipse
but I did not manage to install the sbteclipse plugin globally for any sbt project, so I had to install it per project, i.e., adding
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
to PROJECT_DIR/project/plugins.sbt in your sbt project.
After sbteclipse is installed, you could run:
sudo sbt eclipse
to generate project config files for Eclipse:
    .classpath
    .project
    .settings/
(2) Import the project into Eclipse
Use menu:

File → Import → Existing Projects into Workspace

(3) How to use it
On the command line, you should run:
sudo sbt ~compile
in the root directory of your sbt project such that sbt could automatically run when you make any changes.