0

Jane Street interview questions

Posted by Derek Jing on 7:28 AM in
Pre-Interview
(Ten minutes)

  1. Mental Math: One million minus one hundred eleven.
  2. Mental Math: Fifty-four percent of one hundred ten.
  3. Game: With one die, suppose in a round, you earn the amount of dollars equal to the value of the upwards face of the die. (eg. you earn $6 if you roll a six.) Now also suppose after your first roll, you are given the opportunity to cancel your first and roll again, taking that value as the final value. What should your strategy be?
  4. What's the closest integer to the square root of 1420.
  5. You and a roommate are hosting a party. You invite 10 other pairs of roommates. During the party you poll everyone at the party (excluding yourself) and ask how many hands each person shook. Two conditions:
  6. Each person did not shake his roommate's hand.
  7. Each person shook a different number of hands.
  8. Question: How many hands did you roommate shake?
  9. You roll a die, and are given an amount in dollar equal to the number on the die. What would you pay to play this game if you played it a lot of times?
  10. now say that when you roll the die, you're allowed to either take the money that you'd get with the roll, or roll a second time; if you roll a second time, you're obligated to take the number of dollars that you get with the second roll. Now what is the worth of the game?
  11. Same thing as above, except you have an option to play the game a third time.

Interview
(Thirty minutes)

  1. Suppose you are given the opportunity to bid for a treasure chest, which you know with 100% confidence to be priced anywhere between $0-$1000. If you bid equal to or above the price, you win the treasure chest (at the cost of your bid). If you bid below the price, you do not earn the treasure chest. Now, also suppose you have a friend who is willing to buy the treasure chest from you for one and a half times the price of the treasure chest (should you obtain the chest). What should your bid be?
  2. In Baseball, the batting average is the number of hits over the number of at bats. Player A has a greater batting average than Player B in the first half of the season and the second half of the season. Is it possible that Player B would have a higher batting average for the entire season?
  3. How much calories does a Big Mac have? Would you bet $1 on it? How about $10?
  4. How many tons does the ocean weigh?
  5. How much would you be willing to bet on it being within 25% of that at even odds?
  6. A company has a value V which is uniformly distributed between 0 and 1. you are planning to place a bid B for the company. If B is smaller than V, then your bid loses and you get nothing; if B is larger than V, you get to purchase the company at price B, and the company will end up being worth 1.5 * V. What price B should you bid to maximize your profit?
  7. On a sheet of paper, you have 100 statements written down. the first says, "at most 0 of these 100 statements are true." the second says, "at most 1 of these 100 statements are true." ... the nth says, "at most (n-1) of these 100 statements are true. ... the 100th says, "at most 99 of these statements are true." how many of the statements are true?
  8. You have two decks of cards: one has 13 reds and 13 blacks, and the other has 26 reds and 26 blacks. We play a game in which you select one of the two decks, and pick two cards from it; you win the game if you select two black cards. Which deck should you select to maximize your chances of winning? Try to do this problem in your head, without writing any calculations down.
  9. You have a deck of 52 cards, and you keep taking pairs of cards out of the deck. if a pair of cards are both red, then you win that pair; if a pair of cards are both black, then I win that pair; if a pair of cards has one red and one black, then it's discarded. If, after going through the whole deck, you have more pairs than I do, then you win $1, and if I have more pairs than you do, I win $1. What is the value of this game in the long run?

0

Beamer: structure for recurrent slides

Posted by Derek Jing on 11:19 AM

One may wish to have a certain slide show up repeatedly within the presentation. One common example of this is a highlighted outline:

A popular way of organizing a slide presentation is to have an outline slide, which will appear repeatedly at various times during the presentation. The slide consists of an outline of the talk, listing the major topics. Each time the slide appears, it highlights the title of the section of the presentation which will next be shown. This way the audience can see the "forest" instead of the "trees," i.e. understand how the parts of the talk fit together.

Beamer allows us to automate this process.

One creates the groundwork for an outline in Beamer by using ordinary LaTeX \section, \subsection etc. These will be used to tell Beamer the points in the presentation at which to insert the outline or other kind of recurrent slide. We arrange this as follows, in the outline case:

\AtBeginSection[]
{
\begin{frame}
\frametitle{Outline}
\tableofcontents[currentsection]
\end{frame}
}

This tells Beamer, "At each point which we've marked with a LaTeX \section command, insert a Beamer frame whose title at the top edge of the slide is `Outline' and which consists of our LaTeX table of contents with the current section being highlighted." (Note: Remember that you may have to run pdflatex more than once in order to get the table of contents.)

If we need to do this instead at the subsection level, we would have

\AtBeginSubsection[]
{
\begin{frame}
\frametitle{Outline}
\tableofcontents[currentsection,currentsubsection]
\end{frame}
}

Of course, we can set whatever frame title we wish, not just `Outline'. And it's clear that we have can recurrent slides other than outlines, by simply replacing the \tableofcontents command with other text, say a joke we want to keep repeating until people get sick of it. :-)


0

Tips for Matlab plot

Posted by Derek Jing on 1:14 PM in
Control font size (both axis and legend)
set(gca,'FontSize',13)

Control axis tick display
set(gca,'xtick',[0:1200:5400])
set(gca,'ytick',0:0.2:1.0)

0

How to define a counter style for numbered lists

Posted by Derek Jing on 9:42 PM in
\usepackage{enumerate}
\begin{enumerate}[X]
\item
\item
\item
\end{enumerate}

----- X -----
A ==> uppercase letters (as produced by \Alph)
a ==> lowercase letters (as produced by \alph)
I ==> uppercase roman numerals (as produced by \Roman)
i ==> lowercase roman numerals (as produced by \roman)
1 ==> arabic numbers (as produced by \arabic)

0

Setting PATH environment for ABAQUS

Posted by Derek Jing on 10:41 PM in
Sometimes ABAQUS does not run after installation due to PATH environment problem. So, need to set PATH environment variable by appending following folder:

C:\SIMULIA\Abaqus\Commands

0

Cool software that I ever tested

Posted by Derek Jing on 9:54 AM in
Under Windows:

Arwizard: audio record
Ext2FSD: Access to Linux EXT partition from within Windows NTFS
FeedDemon: Rss feeder synchronized to Google reader
Gadwim: Snapshot on screen

Under Linux:

0

Optimization template in Matlab

Posted by Derek Jing on 10:18 PM in ,
x0=[1e-5,1e-5]; % Initial guess
lb=[0,0];
ub=[1,1];
options = optimset('Algorithm','interior-point'...
,'LargeScale','on'...
,'Display','iter'...
,'OutputFcn',{@monitorXvalues,@optimplotfval}...
,'PlotFcns',{@optimplotx,@optimplotfval}...
,'MaxFunEvals',500....
,'MaxIter',250....
,'TolFun',1e-6...
,'TolX',1e-6);
fobject=@(x)optimfunc(x,YieldCurveUSD,T,S,Price);
[x,fval]=fmincon(fobject,x0,[],[],[],[],lb,ub,[],options)

0

Fancy page number in Latex

Posted by Derek Jing on 4:04 PM in
In the preambule:

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.0pt}
\fancyhead{}
\fancyfoot[CF]{\thesection - \thepage}

Then reset page number to `1' for each new section:

\newpage
\section{Introduction}
\pagenumbering{arabic}

0

Prevent splitting a word at the end of a line

Posted by Derek Jing on 5:22 AM in
Use \hbox{} or \mbox{}.

0

Convert images between two different formats

Posted by Derek Jing on 8:12 PM in ,
Choice #1: Use Linux ImageMagick tool

Use the convert command (a member of the ImageMagick suite of tools) to convert between image formats as well as
=> Resize an image
=> Blur an image
=> Crop an image
=> Despeckle an image
=> Dither an image
=> Draw on an image
=> Flip an image
=> Join an image
=> Re-sample, and much more.

Examples:

$ convert input.jpg output.png

$ convert -resize 50% input.jpg output.png

$ convert -size 360x85 xc:transparent -font Bookman-DemiItalic -pointsize 72 -draw "text 25,60 'nixCraft'" -channel RGBA -gaussian 0x6 -fill YellowGreen -stroke RosyBrown -draw "text 20,55 'nixCraft'" nixCraft.png

Choice #2: Use ps2pdf command

Sometimes we export image to high quality 'ps' format, then we can use `ps2pdf' command to convert it to high quality PDF format.

$ ps2pdf file.ps file.pdf

0

Fast calculate square root

Posted by Derek Jing on 4:44 PM in
Calculate sqrt(37) and tell me estimate of the error.

----------------------------
I did in this way:



Therefore, I say the answer is 6.08, and the error is within 0.08. In other word, sqrt{37}=6.09~6.16. Indeed, calculator shows the answer is 6.083.

0

Make loops using 50 strings

Posted by Derek Jing on 4:38 PM in
Another brain teaser question the Goldman Sachs interviewer asked me today.

Give you 50 strings, you randomly connect them end-by-end. What's the expectation of the number of loops that you may form?

0

Collection of quant interview questions

Posted by Derek Jing on 4:34 PM in ,
  1. cZCsa

  2. saddsa

0

Study PhD in USA

Posted by Derek Jing on 4:43 PM in







0

Plot 3-D surface for (X,Y,Z) data

Posted by Derek Jing on 8:28 PM in
XX=min(X):(max(X)-min(X))/100:max(X);
YY=min(Y):(max(Y)-min(Y))/100:max(Y);

[XI,YI] = meshgrid(XX,YY);
ZI=griddata(X,Y,Z,'cubic');

surf(XI,YI,ZI);

xlabel('X')
ylabel('Y')
zlabel('Z')

0

Input absolute and norm in latex

Posted by Derek Jing on 5:56 AM in
Define commands in the document preamble:

\providecommand{\abs}[1]{\lvert#1\rvert}
\providecommand{\norm}[1]{\lVert#1\rVert}

Then, we can use \abs{a} and \norm{a}.

0

Enlarge line spacing in latex

Posted by Derek Jing on 6:56 PM in
\usepackage{setspace}
\singlespacing
\onehalfspacing
\doublespacing

0

Rotate texts in photoshop

Posted by Derek Jing on 1:17 PM in
(1) Activate the layer of the texts
(2) Ctrl + T ==> a selection box appears
(3) Rotate the selection box with mouse

0

Separate landscape figure page in Latex

Posted by Derek Jing on 10:17 PM in
\uspackage{rotating}

================================================
Paragraph 1 of texts

\begin{sidewaysfigure}
\centering
\includegraphics[scale=0.8]{filename.png}
\caption{blahblah}
\label{fig:figurename}
\end{sidewaysfigure}

Paragraph 2 of texts
================================================

Note: If use 'lscape' package, it is not easy to avoid page break, i.e., the problem that bia area of white space below paragraph 1 and before the figure.

Using rotating package, the separate landscape figure will not break between paragraph1 and paragraph2.

0

Blueman - GTK+ Bluetooth Manager

Posted by Derek Jing on 1:36 PM in
Blueman is a GTK+ Bluetooth Manager

Blueman is designed to be simple and intuitive for everyday bluetooth tasks such as:

* Connecting to 3G/EDGE/GPRS via DUN profile.
* Connecting to/Creating bluetooth networks
* Connecting to input devices
* Connecting to audio devices
* Sending/Receiving/Browsing files via OBEX
* Pairing

URL: http://blueman-project.org/

Install Blueman in Ubuntu
Go to System>>Administration>>Software>>Sources.
Now click on Third-Party Software tab
Click on add one of the following sourcelist which is suitable for you

For Ubuntu Jaunty (9.04) Users

deb http://ppa.launchpad.net/blueman/ppa/ubuntu jaunty main

0

Customize intermediate outputs for optimization in Matlab

Posted by Derek Jing on 10:43 AM in
% Calibration by optimization
x0=[1e-5,1e-5]; % Initial guess
lb=[0,0];
ub=[1,1];
options = optimset('Algorithm','interior-point'...
,'LargeScale','on'...
,'Display','iter'...
,'OutputFcn',{@monitorXvalues,@optimplotfval}...
,'PlotFcns',{@optimplotx,@optimplotfval}...
,'MaxFunEvals',500....
,'MaxIter',250....
,'TolFun',1e-6...
,'TolX',1e-6);
fobject=@(x)optimfunc(x,YieldCurveUSD,T,S,Price);
[x,fval]=fmincon(fobject,x0,[],[],[],[],lb,ub,[],options);

%-------------------------------
function stop = monitorXvalues(x,optimValues,state)
stop = false;
fprintf('sigma*=%10.7f, delta*=%12.8f\n',x(1),x(2));
fprintf('Stepsize of estimate=%12.8f\n',optimValues.stepsize);
fprintf('Value of object function=%12.8f\n\n',optimValues.fval);

0

Higher vertical separation line in Latex

Posted by Derek Jing on 3:24 PM in
There are maybe some other better ways to do this, but I only can figure out following method:

\[f'(y)=\dfrac{\partial f(x)}{\partial x}\Bigl\lvert_x=y\]
\[\Bigl\lvert\frac{a}{b}\Bigr\rvert\]


0

Setting bold Greek letters in LaTeX

Posted by Derek Jing on 9:56 PM in
The issue here is complicated by the fact that \mathbf (the command for setting bold text in TeX maths) affects a select few mathematical symbols (the uppercase Greek letters). However lower-case Greek letters behave differently from upper-case Greek letters (due to Knuth’s esoteric font encoding decisions). However, \mathbf can’t be used even for upper-case Greek letters in the AMSLaTeX amsmath package, which disables this font-switching and you must use one of the techniques outlined below.

The Plain TeX solution does work, in a limited way:

{\boldmath$\theta$}

but \boldmath may not be used in maths mode, so this ‘solution’ requires arcana such as:

$... \mbox{\boldmath$\theta$} ...$

which then causes problems in superscripts, etc.

These problems may be addressed by using a bold mathematics package.

* The bm package, which is part of the LaTeX tools distribution, defines a command \bm which may be used anywhere in maths mode.
* The amsbsy package (which is part of AMSLaTeX) defines a command \boldsymbol, which (though slightly less comprehensive than \bm) covers almost all common cases.

All these solutions cover all mathematical symbols, not merely Greek letters.

0

Set customized application icon in Ubuntu

Posted by Derek Jing on 12:20 PM in ,
Put the icon image file into folder
/usr/share/pixmaps

Since you need permission to write to this folder, you can do this by putting the icon image file to desktop, then
$ cd ~/Desktop
$ sudo mv icon.png /usr/share/pixmaps

Then this icon is ready for your selection when you customize the shortcut for that application.

0

Flash ROM for CDMA Sprint Touch Pro

Posted by Derek Jing on 11:40 AM in , ,
These steps only apply if you have a CDMA Touch Pro. These instructions WILL NOT WORK with a GSM Touch Pro.

Also, if you to return your phone for any reason, you will have to flash back to the stock ROM and relock the phone.
  1. Preparation
    Backup your personal information, also make sure the phone has at least a 50% charge.

  2. Unlock the phone
    Follow this guide. Make sure to use Raphael_CDMA_HSPL_037.zip for Sprint Touch Pro. If you have a Verizon Touch Pro, use Verizon_HSPL_Package.zip.

  3. Choose and download custom ROM
    Here is the list of popular custom ROMs.
    I am using the MightyROM by Mighty Mike. Note, the 'Herman' edition is for Touch Pro.
    Extract the ROM file to a desktop folder, which shall include two files:
    - RUU_signed.nbh
    - ROMUpdateUtility.exe

  4. Power off the phone
    Holding the power button down until you get this message:

    “Power will be turned off, and you may lose data if you have not saved them. Do you want to continue?”

    Choose “Yes” and the phone will shut off.

  5. Enter the bootloader mode
    Hold the down power and volume down button at the same time until you see the tri-color bootloader screen as below

  6. Connect the phone to PC by USB cable
    You may see error message (failure connection) from ActiveSync, ignore this. As long as the display of connection method changes from 'Serial' to 'USB' (as in above figure), your phone is ready for flashing ROM.

  7. Flash custom ROM
    Once you’ve got everything hooked up correctly, run the 'ROMUpdateUtility.exe' program inside of the ROM Utility Update folder. Follow the onscreen instructions to flash the custom ROM to your phone.
    Reboot your phone at the end and you’re finished.
    Enjoy the new custom ROM!

0

Managing storage devices in Ubuntu

Posted by Derek Jing on 6:14 PM in ,
Display available storge devices:
$ sudo fdisk -l

Manage partitions:
$ sudo apt-get install gparted

Manage mounting points for partitions:
$ sudo apt-get install pysdm

0

Use PartImage to backup and restore Ubuntu system

Posted by Derek Jing on 5:48 PM in ,
This summary is based on this article.
  1. This tutorial assumes that you have a Ubuntu live CD and somewhere you can save the partition (an external hard drive or another partition).
  2. boot up Ubuntu with the live CD.
  3. List available partitions
    $ sudo fdisk -l
  4. Make sure the source partition (for example: /dev/sda1) is not mounted, and the destination partition (for example: /dev/sda5) is mounted.
  5. If necessary, can use software 'pysdm' to mount/unmount a partition.
    $ sudo apt-get install pysdm
    For example, with pysdm, we can mount '/dev/sda5' to '/media/sda5'
  6. Install PartImage
    $ sudo apt-get update
    $ sudo apt-get install partimage
  7. Run PartImage



    Select '/dev/sda1' ==>partition to save/restore
    Type '/media/sda5/foldername/filename' ==>Image file to create/use
    Then follow the window to proceed until done.
    Note: Keep in mind, though, that the backup will save only the used space on the partition
    Note: ' F5' for next step, 'F6' for exit, 'Space' for changing value, 'Arrows' for navigation.

0

Install RPM under Ubuntu

Posted by Derek Jing on 8:13 AM in ,
To install the rpms you'll need to install alien as root:
$ apt-get install alien

To install rpms
$ alien -i /path_to_rpms/*.rpm


0

Install R under Ubuntu Jaunty (v9.04)

Posted by Derek Jing on 12:33 PM in , , ,
If installing from Ubuntu 'official' repository, search with 'CRAN' in Synaptic Package manager, and install components that you want.

Below guide is for installing R from 'third party' repository, which may gives newer release of R.
  1. Add pubkey
    $ gpg --keyserver keyserver.ubuntu.com --recv D67FC6EAE2A11821
    $ gpg --export --armor D67FC6EAE2A11821 | sudo apt-key add -

  2. Add repositories
    • Method 1:
      System >> Administration >> Software Sources
      Fill in 'deb http:///bin/linux/ubuntu jaunty/'
      where can be such as 'http://cran.opensourceresources.org/ '

    • Method 2:
      $ sudo gedit /etc/apt/sources.list
      add 'deb http:///bin/linux/ubuntu jaunty/'

  3. Install complete R system
    $ sudo apt-get update
    $ sudo apt-get install r-base

    Users who need to compile R packages from source [e.g. package maintainers, or anyone installing packages with install.packages()] should also install the r-base-dev package:
    $ sudo apt-get install r-base-dev

0

Install Matlab under Ubuntu

Posted by Derek Jing on 6:33 PM in ,
  1. Mount the ISO file to a temporary folder 'tmp'
    Copy the installation ISO file, matlab2008b-linux.iso to desktop.

    $ cd Desktop
    $ mkdir tmp
    $ sudo mount -o loop matlab208b-linux.iso tmp
    $ cd tmp

  2. Install Matlab

    $ sudo ./install

    Choose installation folder to be '/usr/local/matlabR2008b'
    Input the serial number, and then follow the coming instructions......
    During installation, if you are lucky that being asked to create 'Symbolic Links', do it. If not, you bad luck, and need to do additional post-install step.

  3. Unmount ISO file and delete temporary folder 'tmp'.

    $ cd ~/Desktop
    $ sudo umount tmp
    $ rm -fr tmp

  4. Start Matlab
    • If you are lucky to be asked to create 'Symbolic Link' during installation, you can directly Matlab by

      $ matlab

    • If you are not lucky, start Matlab by

      $ /usr/local/matlabR2008b/bin/matlab

  5. User permission
    After Matlab is started, if you get warning message that 'The desktop configuration was not saved successfully', then do following

    $ sudo chmod a+w -R /home/yourname/.matlab/R2008b


0

Install TexLive 2008 and Texmaker under Ubuntu

Posted by Derek Jing on 6:43 AM in , ,
This article describes how to install latest TexLive from TexLive official website. However, it was found that even though you can taste the lastest version, there are some imcompatibility with Ubuntu. Unless you are a Ubuntu guru, you may not be able to fix these problems.

So, it is recommended for you to install TexLive from Ubuntu repository, which may be one-year lags behind the most recent release. However, this difference is trivial.
The easiest way is to use synaptic package manager.


If you are brave enough to taste the latest version, then following below steps:
  1. In order to use TexLive GUI installation, do following first
    $ sudo apt-get install perl-tk
  2. Download network installer (install-tl-unix.tar.gz) from TexLive official site, and extract it to desktop, getting a folder 'install-tl'. Do not use TexLive distribution form Ubuntu repository, since some components are missing.
  3. Start GUI installer
    $ cd ~/Desktop/install-tl
    $ sudo perl install-tl -gui (or just '$ sudo ./install-tl -gui')
  4. As the installing GUI comes out
    Customize installation components and options. Make sure to check 'create symlink in system directories', and also may check 'using letter instead of A4'. Keep the default installation location.
  5. The installation takes really really long time ........go for coffee.
  6. Install Latex editor (IDE)
    Personally I think TEXMAKER is the best one under GNOME. Again, do not download Texmaker from Ubuntu repository, since it will grab old Telive 2007 files from the repository and overwrite what you just installed. Download it from here. This is a .deb file and you can use Gdebi package installer to install it directly.

0

To-do-lists after fresh installation of Ubuntu

Posted by Derek Jing on 11:21 PM in ,
  1. Install Cisco VPN

  2. $ sudo apt-get install vpnc
    $ sudo su
    $ cd /etc/vpnc
    $ cp example.conf umcampus.conf
    $ gedit umcampus.conf

    ------------
    IPSec gateway: 141.211.255.196
    IPSec ID: UM-on-campus-wireless
    IPSec secret: W...........TB.....d!
    Xauth interactive
    ------------
    Connect: $ sudo vpnc umcampus
    Disconnect: $ sudo vpnc-disconnect

    Note: If the profile file 'default.conf' reside in /etc/vpnc, then it will be automatically called in using following command

    $ sudo vpnc-connect

  1. Setup PDF printer

  2. $ sudo apt-get install cups-pdf
    Create folder '/home/username/PDF'.

  3. Check GCC installation

  4. Find GCC location: $ which gcc
    Check GCC version: $ gcc -v
    Update GCC: $ sudo apt-get install build-essential

  5. Several nice GNOME C++ IDEs

  6. $ sudo apt-get install anjuta
    $ sudo apt-get install codeblocks
    $ sudo apt-get install eclipse eclipse-cdt
    $ sudo apt-get install geany

  7. 设置中文输入

  8. Step 1: System >> Administration >> Language Support >> Install/Remove Languages >> Check 'Chinese'
    check 'Use input method engines (IME) to enter complex characters'
    Step 2: System >> Preferences >> SCIM Input Method Setup >> Enable your preferred input method

  9. Install other cool softwares

  10. Flowchart:
    $ sudo apt-get install dia
    Support chm format document:
    $ sudo apt-get install gnochm (for GNOME)
    $ sudo apt-get install kchmviewer (for KDE)
    Support rar:
    $ sudo apt-get install unrar
    MSN messenger client:
    $ sudo apt-get install amsn
    $ sudo apt-get install emesene
    $ sudo apt-get install empathy
    File/folder synchronization:
    $ sudo apt-get install grsync
    $ sudo apt-get install unison-gtk
    A very nice referece manager:
    $ sudo apt-get install referencer
    A lightweight bandwidth monitor:
    $ sudo apt-get install bwm-ng (need to mannually create menu item)
    A nice rss feeder under Ubuntu:
    $ sudo apt-get install liferea
    A vector graph/image editor (similar as Photoshop):
    $ sudo apt-get install inkscape

0

Embed Windows XP Inside Ubuntu Using Virtual Box

Posted by Derek Jing on 6:15 PM in ,
Compared with Ubuntu+XP dual-boot system, this method makes it easy to switch to the other OS from current OS and share files freely.


  1. Prepare the system

  2. First you need to install the following package.Dynamic Kernel Module Support Framework.This package contains the framework for the Dynamic Kernel Module Support (DKMS) method for installing and updating kernel modules.
    $ sudo apt-get install dkms

  3. Install Compiz Fusion in Ubuntu

  4. This step is not necessary, just for beautifying desktop

    $ sudo apt-get install compizconfig-settings-manager

  5. Download and install Virtualbox

  6. Download it from the official website. Do not use Synaptic to install OSE package.
    $ sudo dpkg -i VirtualBox_3.0.0_Ubuntu_edgy.deb

  7. Add appropriate user profile to the vboxusrs group so that Virtualbox will work

  8. The group 'vboxusers' will be created during installation. Note that a user who is going to run VirtualBox must be member of that group.
    $ sudo usermod -a -G vboxusers username
    or
    $ sudo adduser username vboxusers

  9. Check building kernel module

  10. If no warning comes during installing procedure, ignore this step.

    The installer will also search for a VirtualBox kernel module suitable for your kernel. The package includes pre-compiled modules for the most common kernel configurations. If no suitable kernel module is found, the installation script tries to build a module itself. If the build process is not successful you will be shown a warning and the package will be left unconfigured. Please have a look at '/var/log/vbox-install.log' to find out why the compilation failed. You may have to install the appropriate Linux kernel headers.After correcting any problems, do
    $ sudo /etc/init.d/vboxdrv setup
    This will start a second attempt to build the module

  11. Enable USB support in Virtualbox

  12. In order to use VirtualBox's USB support, the user account under which you intend to run VirtualBox must have read and write access to the USB filesystem (usbfs).

    For 'Jaunty' you need to add a line to your /etc/fstab file:
    $ sudo gedit /etc/fstab
    Add following line to the end of the opened file:
    none /proc/bus/usb usbfs devgid=46,devmode=664 0 0
    then run
    $ sudo mount -a

  13. Start VirtualBox

  14. Applications – System Tools – Sun xVM VirtualBox
    Create a Windows virtual machine (follow the “New” Wizzard).

  15. Basic Virtualbox configurations

  16. To be able to get your virtual machine booting from an XP install cd, we need to mount the CD/DVD drive. Click the settings button and you will see this window – click the CD/DVD-ROM tab.


  17. Start virtual machine (VM) and install Windows XP using boot XP disk




  18. Install the guest additions

  19. Once XP is completely installed, install the guest additions ISO, which will enable a full screen resolution and a lot of compatibility between Ubuntu and XP (such as folder sharing).
    To mount the Additions ISO file: Virtual machine's menu bar >> Devices >> Install guest additions ==> This will automatically bring up the Additions in your VM window.
    Note: For 'Direct 3D support' in Windows to work, the Guest Additions must be installed in Windows "safe mode". Press F8 when the Windows guest is booting and select "Safe mode", then install the Guest Additions. Otherwise Windows' file protection mechanism will interfere with the replacement DLLs installed by VirtualBox and keep restoring the original Windows system DLLs.
    Running the installer: Open windows explorer in XP, you will see the mounted ISO. Double click it to begin installation.


  20. Setup folder sharing between host and guest systems

  21. Shared folders allow you to access files of your host system from within the guest system, much like ordinary shares on Windows networks would -- except that shared folders do not need require networking. Shared folders must physically reside on the host and are then shared with the guest; sharing is accomplished using a special service on the host and a file system driver for the guest, both of which are provided by VirtualBox.
    Assign folder for sharing: Virtualbox menu >> Devices >> Shared folders. Add a folder under 'Machine folder' (this shared folder can be the host ubuntu home folder)
    Mount the shared folder from inside XP: My Networking Places >> Map a network drive >> select the shared host folder, and assign a drive letter (such as 'B') for it. Done!

0

Collection of cool URLs

Posted by Derek Jing on 6:33 PM in
FeedCry Full Text RSS
Very cool collection of full text RSS feeds from top business websites.

An alternative CHM viewer under windows: UltraCHM.

A nice free software for converting to ISO image: AnyToISO.

0

Compiling C++ codes by GCC

Posted by Derek Jing on 12:36 PM in
Compiling a single C++ program

Suppose we have a C++ source code 'hello.cpp', then we can use following command to compile it:

$g++ -Wall -c hello.cpp
  • This command compiles hello.cpp and outouts an object file hello.o.
  • The option -Wall displays complier warnings.
Then we can link the object file

$g++ hello.o -o hello.out

  • This command links the object file hello.o into an executable file hello.out;
  • It is not necessary to use .out as the extension for the executable file. It is also ok to give an executable filename without extension;
  • If the option '-o filename' is omitted, then the output executable will be a.out.
Alternatively, above two steps can be combined together as following

$ g++ -Wall hello.cpp -o hello.out

where an executable hello.out is output directly without generating intermediate object file hello.o.

Compiling multiple C++ codes simultaneously

Suppose we have three C++ codes
  • myclass.h: a header file, including the class interface;
  • myclass.cpp: the class implementation file, having #include "myclass.h";
  • main.cpp: the main file using the class, having #include "myclass.h"
Then we can compile the two CPP files simultaneously
$g++ -Wall main.cpp myclass.cpp -o myrun.out


Compiling multiple C++ codes independently

The benefit is independent compilation is that if one CPP file is edited, we just need to compile this file, saving time for compiling all other CPP files.
$g++ -Wall -c myclass.cpp ==> generate myclass.o
$g++ -Wall -c main.cpp ==> generate main.o
$g++ main.o myclass.o -o myrun ==> generate executable myrun.out

0

Breaking up long equations in Latex

Posted by Derek Jing on 11:50 PM in
Let us first see an example of a long equation. (Note, when you view the example document for this topic, you will see that this equation is in fact wider than the text width. It's not as obvious on this webpage!)

Latex doesn't break long equations to make them fit within the margins as it does with normal text. It is therefore up to you to format the equation appropriately (if they overrun the margin.) This typically requires some creative use of an eqnarray to get elements shifted to a new line and to align nicely. E.g.,


\begin{eqnarray*}
\left(1+x\right)^n & = & 1 + nx + \frac{n\left(n-1\right)}{2!}x^2 \\
& & + \frac{n\left(n-1\right)\left(n-2\right)}{3!}x^3 \\
& & + \frac{n\left(n-1\right)\left(n-2\right)\left(n-3\right)}{4!}x^4 \\
& & + \ldots
\end{eqnarray*}

0

Customize equation numbers in Latex

Posted by Derek Jing on 10:05 PM in
By default, LaTeX will number equations consecutively, as (1), (2), etc., assuming you use the automatic equation numbering mechanism. If the paper is very short, or if there are only a few numbered equations, this is fine, but once the numbers get into the twenties and higher, a scheme that numbers equations by section, as in (1.1), (1.2), ..., (2.1), etc., is preferable. In fact, for the vast majority of journal articles, the latter is probably the best numbering scheme. To get equations numbered by section, just put the following into the preamble: " \numberwithin{equation}{section} ". For books, theses, or very long papers, an equation numbering scheme that is three levels deep (with numbers like (4.1.1), etc.) may be appropriate. To get this, just replace "section" above by "subsection", or the corresponding innermost level. The same mechanism works for other counters, e.g., theorem counters, instead of "equation".

Source: click here.

Copyright © 2009 Derek's Technical Notes All rights reserved.