2016年5月20日 星期五

Installing VMWare Player in Ubuntu 32 bit

Struggled in VMWare player installed in Ubuntu 14.04 32 bit, the below solution helps.

Basically, the error message is related to vmnet module, like the following

Using 2.6.x kernel build system.
make: Entering directory `/tmp/modconfig-c7FgGQ/vmmon-only'
/usr/bin/make -C /lib/modules/3.16.0-71-generic/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
 MODULEBUILDDIR= modules
make[1]: Entering directory `/usr/src/linux-headers-3.16.0-71-generic'
  CC [M]  /tmp/modconfig-c7FgGQ/vmmon-only/linux/driver.o
  CC [M]  /tmp/modconfig-c7FgGQ/vmmon-only/linux/driverLog.o
  CC [M]  /tmp/modconfig-c7FgGQ/vmmon-only/linux/hostif.o
  CC [M]  /tmp/modconfig-c7FgGQ/vmmon-only/common/apic.o
  CC [M]  /tmp/modconfig-c7FgGQ/vmmon-only/common/comport.o
In file included from /tmp/modconfig-c7FgGQ/vmmon-only/linux/driverLog.h:33:0,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/linux/driverLog.c:31:
/tmp/modconfig-c7FgGQ/vmmon-only/./include/vm_assert.h:259:0: warning: "DEPRECATED" redefined [enabled by default]
    #define DEPRECATED(_fix) do {} while (0)
 ^
In file included from include/linux/kernel.h:13:0,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/./include/compat_kernel.h:23,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/linux/driverLog.c:27:
include/linux/printk.h:106:0: note: this is the location of the previous definition
 #define DEPRECATED "[Deprecated]: "
 ^
  CC [M]  /tmp/modconfig-c7FgGQ/vmmon-only/common/cpuid.o
In file included from /tmp/modconfig-c7FgGQ/vmmon-only/./include/vmware.h:39:0,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/linux/driver.c:46:
/tmp/modconfig-c7FgGQ/vmmon-only/./include/vm_assert.h:259:0: warning: "DEPRECATED" redefined [enabled by default]
    #define DEPRECATED(_fix) do {} while (0)
 ^
In file included from include/linux/kernel.h:13:0,
                 from ./arch/x86/include/asm/percpu.h:44,
                 from ./arch/x86/include/asm/preempt.h:5,
                 from include/linux/preempt.h:18,
                 from include/linux/spinlock.h:50,
                 from include/linux/wait.h:8,
                 from include/linux/fs.h:6,
                 from include/linux/highmem.h:4,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/linux/driver.c:25:
include/linux/printk.h:106:0: note: this is the location of the previous definition
 #define DEPRECATED "[Deprecated]: "
 ^
In file included from /tmp/modconfig-c7FgGQ/vmmon-only/./include/vmware.h:39:0,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/linux/hostif.c:82:
/tmp/modconfig-c7FgGQ/vmmon-only/./include/vm_assert.h:259:0: warning: "DEPRECATED" redefined [enabled by default]
    #define DEPRECATED(_fix) do {} while (0)
 ^
In file included from include/linux/kernel.h:13:0,
                 from include/asm-generic/bug.h:13,
                 from ./arch/x86/include/asm/bug.h:35,
                 from include/linux/bug.h:4,
                 from include/linux/mmdebug.h:4,
                 from include/linux/mm.h:8,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/./include/compat_page.h:23,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/linux/hostif.c:32:
include/linux/printk.h:106:0: note: this is the location of the previous definition
 #define DEPRECATED "[Deprecated]: "
 ^
  CC [M]  /tmp/modconfig-c7FgGQ/vmmon-only/common/hashFunc.o
/tmp/modconfig-c7FgGQ/vmmon-only/linux/driver.c:1342:1: warning: always_inline function might not be inlinable [-Wattributes]
 LinuxDriverSyncReadTSCs(uint64 *delta) // OUT: TSC max - TSC min
 ^
  CC [M]  /tmp/modconfig-c7FgGQ/vmmon-only/common/memtrack.o
  CC [M]  /tmp/modconfig-c7FgGQ/vmmon-only/common/phystrack.o
  CC [M]  /tmp/modconfig-c7FgGQ/vmmon-only/common/task.o
  CC [M]  /tmp/modconfig-c7FgGQ/vmmon-only/common/vmx86.o
In file included from /tmp/modconfig-c7FgGQ/vmmon-only/./include/vmware.h:39:0,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/common/vmx86.c:40:
/tmp/modconfig-c7FgGQ/vmmon-only/./include/vm_assert.h:259:0: warning: "DEPRECATED" redefined [enabled by default]
    #define DEPRECATED(_fix) do {} while (0)
 ^
In file included from include/linux/kernel.h:13:0,
                 from include/linux/sched.h:17,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/common/vmx86.c:31:
include/linux/printk.h:106:0: note: this is the location of the previous definition
 #define DEPRECATED "[Deprecated]: "
 ^
  CC [M]  /tmp/modconfig-c7FgGQ/vmmon-only/vmcore/moduleloop.o
In file included from /tmp/modconfig-c7FgGQ/vmmon-only/./include/vmware.h:39:0,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/linux/driver.c:46:
/tmp/modconfig-c7FgGQ/vmmon-only/./include/vm_assert.h:259:0: warning: "DEPRECATED" redefined [enabled by default]
    #define DEPRECATED(_fix) do {} while (0)
 ^
In file included from include/linux/kernel.h:13:0,
                 from ./arch/x86/include/asm/percpu.h:44,
                 from ./arch/x86/include/asm/preempt.h:5,
                 from include/linux/preempt.h:18,
                 from include/linux/spinlock.h:50,
                 from include/linux/wait.h:8,
                 from include/linux/fs.h:6,
                 from include/linux/highmem.h:4,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/linux/driver.c:25:
include/linux/printk.h:106:0: note: this is the location of the previous definition
 #define DEPRECATED "[Deprecated]: "
 ^
In file included from /tmp/modconfig-c7FgGQ/vmmon-only/./include/vmware.h:39:0,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/vmcore/moduleloop.c:33:
/tmp/modconfig-c7FgGQ/vmmon-only/./include/vm_assert.h:259:0: warning: "DEPRECATED" redefined [enabled by default]
    #define DEPRECATED(_fix) do {} while (0)
 ^
In file included from include/linux/kernel.h:13:0,
                 from /tmp/modconfig-c7FgGQ/vmmon-only/vmcore/moduleloop.c:30:
include/linux/printk.h:106:0: note: this is the location of the previous definition
 #define DEPRECATED "[Deprecated]: "
 ^
  LD [M]  /tmp/modconfig-c7FgGQ/vmmon-only/vmmon.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /tmp/modconfig-c7FgGQ/vmmon-only/vmmon.mod.o
  LD [M]  /tmp/modconfig-c7FgGQ/vmmon-only/vmmon.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.16.0-71-generic'
/usr/bin/make -C $PWD SRCROOT=$PWD/. \
 MODULEBUILDDIR= postbuild
make[1]: Entering directory `/tmp/modconfig-c7FgGQ/vmmon-only'
make[1]: `postbuild' is up to date.
make[1]: Leaving directory `/tmp/modconfig-c7FgGQ/vmmon-only'
cp -f vmmon.ko ./../vmmon.o
make: Leaving directory `/tmp/modconfig-c7FgGQ/vmmon-only'
Using 2.6.x kernel build system.
make: Entering directory `/tmp/modconfig-c7FgGQ/vmnet-only'
/usr/bin/make -C /lib/modules/3.16.0-71-generic/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
 MODULEBUILDDIR= modules
make[1]: Entering directory `/usr/src/linux-headers-3.16.0-71-generic'
  CC [M]  /tmp/modconfig-c7FgGQ/vmnet-only/driver.o
  CC [M]  /tmp/modconfig-c7FgGQ/vmnet-only/hub.o
  CC [M]  /tmp/modconfig-c7FgGQ/vmnet-only/userif.o
  CC [M]  /tmp/modconfig-c7FgGQ/vmnet-only/netif.o
In file included from /tmp/modconfig-c7FgGQ/vmnet-only/monitorAction_exported.h:31:0,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/vnet.h:29,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/vnetInt.h:24,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/hub.c:43:
/tmp/modconfig-c7FgGQ/vmnet-only/vm_assert.h:259:0: warning: "DEPRECATED" redefined [enabled by default]
    #define DEPRECATED(_fix) do {} while (0)
 ^
In file included from include/linux/kernel.h:13:0,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/hub.c:23:
include/linux/printk.h:106:0: note: this is the location of the previous definition
 #define DEPRECATED "[Deprecated]: "
 ^
In file included from /tmp/modconfig-c7FgGQ/vmnet-only/monitorAction_exported.h:31:0,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/vnet.h:29,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/vnetInt.h:24,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/userif.c:45:
/tmp/modconfig-c7FgGQ/vmnet-only/vm_assert.h:259:0: warning: "DEPRECATED" redefined [enabled by default]
    #define DEPRECATED(_fix) do {} while (0)
 ^
In file included from include/linux/kernel.h:13:0,
                 from ./arch/x86/include/asm/percpu.h:44,
                 from ./arch/x86/include/asm/preempt.h:5,
                 from include/linux/preempt.h:18,
                 from include/linux/spinlock.h:50,
                 from include/linux/wait.h:8,
                 from include/linux/fs.h:6,
                 from include/linux/highmem.h:4,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/userif.c:26:
include/linux/printk.h:106:0: note: this is the location of the previous definition
 #define DEPRECATED "[Deprecated]: "
 ^
/tmp/modconfig-c7FgGQ/vmnet-only/hub.c: In function ‘VNetHubFindHubByID’:
/tmp/modconfig-c7FgGQ/vmnet-only/hub.c:132:49: warning: argument to ‘sizeof’ in ‘__builtin_memcmp’ call is the same expression as the first source; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess]
         memcmp(idNum, currHub->id.pvnID, sizeof idNum))) {
                                                 ^
In file included from ./arch/x86/include/asm/string.h:2:0,
                 from include/linux/string.h:17,
                 from ./arch/x86/include/asm/page_32.h:34,
                 from ./arch/x86/include/asm/page.h:13,
                 from ./arch/x86/include/asm/thread_info.h:11,
                 from include/linux/thread_info.h:54,
                 from ./arch/x86/include/asm/preempt.h:6,
                 from include/linux/preempt.h:18,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:35,
                 from include/linux/time.h:5,
                 from include/uapi/linux/timex.h:56,
                 from include/linux/timex.h:56,
                 from include/linux/sched.h:19,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/hub.c:25:
/tmp/modconfig-c7FgGQ/vmnet-only/hub.c: In function ‘VNetHubAlloc’:
/tmp/modconfig-c7FgGQ/vmnet-only/hub.c:315:36: warning: argument to ‘sizeof’ in ‘__builtin_memcpy’ call is the same pointer type ‘uint8 *’ as the destination; expected ‘uint8’ or an explicit length [-Wsizeof-pointer-memaccess]
   memcpy(hub->id.pvnID, id, sizeof id);
                                    ^
./arch/x86/include/asm/string_32.h:182:48: note: in definition of macro ‘memcpy’
 #define memcpy(t, f, n) __builtin_memcpy(t, f, n)
                                                ^
In file included from /tmp/modconfig-c7FgGQ/vmnet-only/monitorAction_exported.h:31:0,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/vnet.h:29,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/vnetInt.h:24,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/netif.c:42:
/tmp/modconfig-c7FgGQ/vmnet-only/vm_assert.h:259:0: warning: "DEPRECATED" redefined [enabled by default]
    #define DEPRECATED(_fix) do {} while (0)
 ^
In file included from include/linux/kernel.h:13:0,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/netif.c:23:
include/linux/printk.h:106:0: note: this is the location of the previous definition
 #define DEPRECATED "[Deprecated]: "
 ^
/tmp/modconfig-c7FgGQ/vmnet-only/netif.c: In function ‘VNetNetIf_Create’:
/tmp/modconfig-c7FgGQ/vmnet-only/netif.c:151:79: error: macro "alloc_netdev" passed 4 arguments, but takes just 3
    dev = alloc_netdev(sizeof *netIf, deviceName, NET_NAME_USER, VNetNetIfSetup);
                                                                               ^
/tmp/modconfig-c7FgGQ/vmnet-only/netif.c:151:10: error: ‘alloc_netdev’ undeclared (first use in this function)
    dev = alloc_netdev(sizeof *netIf, deviceName, NET_NAME_USER, VNetNetIfSetup);
          ^
/tmp/modconfig-c7FgGQ/vmnet-only/netif.c:151:10: note: each undeclared identifier is reported only once for each function it appears in
/tmp/modconfig-c7FgGQ/vmnet-only/netif.c: At top level:
/tmp/modconfig-c7FgGQ/vmnet-only/netif.c:85:1: warning: ‘VNetNetIfSetup’ defined but not used [-Wunused-function]
 VNetNetIfSetup(struct net_device *dev)  // IN:
 ^
make[2]: *** [/tmp/modconfig-c7FgGQ/vmnet-only/netif.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /tmp/modconfig-c7FgGQ/vmnet-only/monitorAction_exported.h:31:0,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/vnet.h:29,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/vnetInt.h:24,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/driver.c:51:
/tmp/modconfig-c7FgGQ/vmnet-only/vm_assert.h:259:0: warning: "DEPRECATED" redefined [enabled by default]
    #define DEPRECATED(_fix) do {} while (0)
 ^
In file included from include/linux/kernel.h:13:0,
                 from /tmp/modconfig-c7FgGQ/vmnet-only/driver.c:23:
include/linux/printk.h:106:0: note: this is the location of the previous definition
 #define DEPRECATED "[Deprecated]: "
 ^
make[1]: *** [_module_/tmp/modconfig-c7FgGQ/vmnet-only] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.16.0-71-generic'
make: *** [vmnet.ko] Error 2
make: Leaving directory `/tmp/modconfig-c7FgGQ/vmnet-only'
Unable to install all modules.  See log for details.

Seems that vmware is not able to compile the network module under kernel 3.16, so we need to apply this patch

http://askubuntu.com/questions/449629/error-installing-vmware-workstation-on-ubuntu/449630#449630?newreg=0be708f4a9c0411d973eb3035b176d69

 Details of the patch will be analyzed later

After patching the vmware, just start the vmware player as usual and install the module

2016年4月23日 星期六

Backup and Restore of MongoDB

In MySQL world, we can backup and restore our database pretty easy via phpmyadmin or mysqldump etc. But in mongoDB, it is even easier! Just running 2 commands in total, one for backup and one for restore, and you can seamlessly transfer your mongoDB data to the new machine.


In my case, I try to transfer the DB data from my old raspberry gen1 to my new raspberry pi 3, of course, it works on all sorts of Linux platform and Windows also.


First, to backup your DB, run

mongodump --db myDB --out destPath

This is the simplest backup method, of course, mongodump provides many options for customization, but in most situation, this would be enough. If you want to backup all the databases, do not specify --db.

Then you just copy the dumped mongoDB file to the desired location and run
mongorestore --db myDB --drop /data/db

/data/db is my designated path, you can have it yourself, after that, all the data will be restored! Easy right? Remember --drop parameter is important as changes in the database will not be restored if not specified.


Update: 19-6-2016
Remember, the restore path is always the relative path of the current directory, i.e. Say
mongorestore --drop -d db abc/

"abc" is a RELATIVE directory of the current shell

Reference:

  1. http://stackoverflow.com/questions/3884418/mongorestore-of-a-db-causing-me-trouble
  2. https://docs.mongodb.org/manual/reference/program/mongodump/#bin.mongodump
  3. https://docs.mongodb.org/manual/reference/program/mongorestore/ 

2015年5月25日 星期一

Setup VCS Using Redmine + Git

We all know that Git is a very good VCS, with redmine, like Bugzilla, we have even better control and graphical view on our repository, and this is undoubtedly aid development. The following is how to make the whole VCS system happens.

What we need
1) Git (of course!)
2) Redmine
3) Apache Server

Procedure
1) Install all the necessary components respectively
sudo apt-get install apache2
sudo apt-get install mysql-server
sudo apt-get install redmine-mysql
sudo apt-get install libapache2-mod-passenger
sudo apt-get install redmine
sudo apt-get install git-core

2) Set up soft link from redmine source to the Apache source
sudo ln -s /usr/share/redmine/public /var/www/redmine

3) mod passenger needs www-data to execute, add the following to /etc/apache2/mods-available/passenger.conf
vi /etc/apache2/mods-available/passenger.conf
PassengerDefaultUser www-data

 4) Add redmine's web directory to Apache2's sites-available/default

                RailsBaseURI /redmine
                PassengerAppRoot /usr/share/redmine
                RailsEnv production
                PassengerResolveSymlinksInDocumentRoot on
5) Setup plugin linkage
 ln -s /var/cache/redmine/default/plugin_assets /usr/share/redmine/public/

6) Create new repository (server side), note that the directory should be with owner "www-data"
cd /var/www
mkdir test-repo.git
cd test-repo.git
git --bare init
git update-server-info
chown -R www-data.www-data .

 7) Enable webDAV
a2enmod dav_fs
a2enmod dav

If high security is required, carry on, if not, restart apache and all services will be done

8) Create the following file
/etc/apache2/conf.d/git.conf

9) Configure the repository path for authentication
        DAV on
        AuthType Basic
        AuthName "Git"
        AuthUserFile /etc/apache2/passwd.git
        Require valid-user

10) Create user which can access the repository
 htpasswd -c /etc/apache2/passwd.git

11) Restart Apache service
/etc/init.d/apache2 restart

Done! You have made a git VCS with redmine geared!

Almost forgot, modifying the config file in .git directory is necessary for authentication when pushing
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = http://username:password@git.repository.url/repo.git

References:
- Linking git remote server to Apache
http://blog.bobbyallen.me/2012/07/23/installing-a-git-server-using-apache-webdav-on-ubuntu-server-12-04/

- Installing Apache + Git + Redmine
http://blog.chiichen.com/2014/05/raspberry-pi-redmine.html

- Git config fix on http/https authentication
http://stackoverflow.com/questions/5264949/cannot-push-git-to-remote-repository-with-http-https

- Others
https://randomthoughtsgr.wordpress.com/2011/10/17/redmine-sub-uri-and-apache-configuration/

2015年5月12日 星期二

cxfreeze Python program (Linux) - Wrapping the Python Program to Single Executable

I would like to note down here because Googling results frustrating with

  • Large amount of Windows environment Python application wrapping
  • Misleading and lack of example of cxfreeze API

But thanks for Stackoverflow, I finally get the solution despite various failure on different problems during the wrapping of my wxPython application.


Here is my situation
    I have written a wxpython program, and the program consist of not only .py files but with images and xml files, I want to 

  1. Wrap all these stuffs to one executable program in Ubuntu
  2. Deploy this program with deb installer

Solutions
  1. Download and install cxfreeze
  2. Please let me know but I cannot find relative commands on how to include external files, therefore I use the officially provided py script
    http://cx-freeze.readthedocs.org/en/latest/script.html
  3. Follow the below official guide and write the setup script to build the program
    http://cx-freeze.readthedocs.org/en/latest/distutils.html
  4. Run python setup.py build and your program will be built
  5. Follow the file structure to build the deb

  • mpstoolbox is the app name, name your own one
  • DEBIAN/control, DEBIAN/postinst is files to configure the deb package
  • usr/bin/..., this is the installed path, you should make your own path, all the files installed will follow this path structure
  • Finally, cd back to the folder (your app name), use dpkg -b yourAppName
  • A deb package will be generated
  • Use dpkg -i to install

Here comes the MOST important part, my problem

    It seems simple to follow the above to build the program, but indeed it doesn't, the guide does not teach you clearly on how to include the required modules to let you bring your program to other Linux machine to run, you need to follow the followings


  • binpathincludes parameter is important, please include all system library like /usr/lib, /usr/local/lib, or you may encounter this error libwx_gtk2u import error, ImportError: libwx_gtk2u_adv-2.8 etc. This is deal to the missing of wxPython library, you therefore need to include all required system library when building the app
  • About the setup.py, the api is not very clear in cxfreeze, follow stackoverflow's guide, thanks to the bro there, he also suffered from the lack of clearance of the api
    http://stackoverflow.com/questions/15486292/cx-freeze-doesnt-find-all-dependencies

    One thing here to pay attention to, the "include_files" attribute should be a list of tuples instead of single name only!! Your external files and other required images should also put it here.

2015年2月1日 星期日

[VLC] Solving Gibberish Subtitles when Using VLC


  1. Make sure the sub file is in utf-8 or unicode

  2. Navigate to VLC>Tools>Reference>Subtitle/OSD

  3. Change the "Default Encoding" to uft-8 and the font to "Microsoft Yahei"

  4. Enjoy the nice sub!

2015年1月23日 星期五

Dual/Multiple OS Installation

We often need to install multiple OS in one system, for example
  1. Windows 8 & Ubuntu 12
  2. Ubuntu 12 & Ubuntu 14
  3. Windows 8 & Ubuntu 12 & Ubuntu 14...
We often follow the below instructions to achieve (assuming you have ONE Windows pre-installed and ONE Ubuntu pre-installed and you want to install the third OS, also Ubuntu)

  1. Navigate to the BIOS, set the USB Ubuntu stick as the booting machine
  2. Turn off the security boot to prevent the laptop not loading the USB (subjected to change on different BIOS)
  3. Turn off the EUFI boot specifically for Windows 8 to avoid always booting to Windows instead of Ubuntu
  4. Boot overriding the USB drive (subjected to change on different BIOS), if no boot overriding exists, just follow the old school boot priority function
  5. Make a new partition for your Ubuntu, remember if you lack disk space, you will need to do partition resizing and  be-careful not to override the Windows partition or you may not be able to boot into Windows again!! Before installing the new OS, make sure you which partition which OS refers to.
  6. After adding/resizing the partition, format it with ext4
  7. You will need to provide the mounting point (I usually pick "/") and create a very small bootloader partition called "Reserved BIOS Boot Area" for GRUB's code, this is VERY IMPORTANT, grub provides a boot menu for you to navigate to different OS, we need to provide it with some space (normally as small as 1MB), after creating both partitions, you are okay to proceed to the installation processes.
  8. Follow the Ubuntu install guide to finish the installation. 
  9. In the final step, Ubuntu will ask you to restart the machine, just do so.
  10. Luckily you will find a Linux boot menu listing all the partitions included (e.g. /dev/sda1,sda2.... etc.) but we will miss our newly installed OS partition, we need to update the grub file to reflect the changes (OS addition)
  11. Boot into the pre-installed Ubuntu (the one before our third OS installation), navigate to /etc/default/grub and use text editior to edit it.
  12. We only interest in GRUB_DEFAULT, this controls which OS the default OS should boot in, choose the one you want and save the setting
  13. Remember after updating the file, you will need to UPDATE by sudo update-grub , if not the newly installed OS will not appear in the grub menu
  14. Reboot the machine and you will see the newly installed OS appeared.
Reference:
  1. http://askubuntu.com/questions/16042/how-to-get-to-the-grub-menu-at-boot-time
  2. http://askubuntu.com/questions/343268/how-to-use-manual-partitioning-during-installation 
 

2015年1月16日 星期五

[requireJS] define VS require

Difference between define and require

We often see define and require in requireJS, but what's their difference? I try to elaborate as below.

require
  1. When you want to load some stuff, you need to use require, like jquery, bootstrap etc.
  2. It has NO return statement
e.g.:
require(["jquery", "bootstrap", "bootstrap_select"], function() {
 //requirejs sugar function
 var angular = require('angular');
});


define
  1. As the name implies, it helps you define module that will be depend by other modules or applications
  2. It has return statement for inclusion by other modules
e.g.:
define(["angular", "angular-route", "angular-animate"],function(angular){
 var insiderApp = angular.module("insiderApp",["ngRoute", "ngAnimate"]);
 //routing
 insiderApp.config(['$routeProvider','$locationProvider',function($scope,$routeProvider,$locationProvider){
  
 }]);
 
 return insiderApp;
});

This is official explanation
 /**
     * The function that handles definitions of modules. Differs from
     * require() in that a string for the module should be the first argument,
     * and the function to execute after dependencies are loaded should
     * return a value to define the module corresponding to the first argument's
     * name.
     */