Monday, April 14, 2014

Creating PDF file from DVI with Embedded Fonts

These instructions are valid for Ubuntu. It may also work in Windows with ghostscript installed.

Use the following commands in order.

  1. dvips -Ppdf -G0 -tletter your_file.dvi 
  2. ps2pdf -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress your_file.ps 
In case you get a segmentation fault. Use the following steps.
  1. dvips -Ppdf -G0 -tletter your_file.dvi
  2. ps2ps your_file.ps your_new_file.ps
  3. ps2pdf -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress your_new_file.ps

Monday, March 17, 2014

Latex Tips & Tricks

Setup Page Margins

\newcommand{\CLASSINPUTinnersidemargin}{0.5in} % left side margin
\newcommand{\CLASSINPUToutersidemargin}{0.5in}% right side margin
\newcommand{\CLASSINPUTtoptextmargin}{1.0in} % top text margin
\newcommand{\CLASSINPUTbottomtextmargin}{1.0in}% bottom text margin
\documentclass {your_class}

** Change the number as necessary.

Solving italic-underline Problem

Problem definition: all the italic words are automatically underlined
Solution: Add the following line after \begin{document}

\normalem


Thursday, October 31, 2013

Matlab Reshape Matrix

Recently I faced a problem with reshaping a matrix. Here is how I solved it.

Input: x = n*1 matrix
Output: y = a*b matrix where a*b = n

Example:

       [1
        2
x =  3
       4
       5
       6 ]

      [ 1  2
y =  3  4
       5  6]

Code:

y = reshape(x, 2, 3)
y = transpose(y)
 

Tuesday, February 5, 2013

Make a Micro SIM from a Regular SIM


Recently I needed a micro SIM card for using in a Nexus 4 phone. Since AT&T wanted me to get a data plan for getting a micro SIM (which is ridiculous!), I made the micro SIM from the regular SIM card I have. Here is how to do it.

  • Download and print the following image. Use original image size while printing.

  • Use a ruler and ruler to extend the lines of micro SIM
  • Place the SIM card on the paper so that it fits in the border of Mini SIM in the image.
  • Use pencil and ruler to draw lines over the SIM card using the extended lines of micro SIM as reference.
  • Use a sharp scissor to cut the SIM.
  • Don't worry if does fit in the phone after the first try. Just trim it as necessary.
  • Make sure that the golden part is not cut in any way.

Saturday, January 19, 2013

Samsung Nexus S: Flush Jelly Bean Factory Image

I have been waiting for OTA for several months with no luck. So finally decided to flush my Samsung Nexus S with Jelly Bean 4.1.2 factory image. Here is how I did it. 
  1. (PC) Download Nexus Root Toolkit from here (don't worry. I did not root my phone, just unlocked it for flushing!). 
  2. (PC) Install the software. When prompted, choose your device. In my case, it was Samsung Nexus S, 850MHz, i9020a. Allow the software to download necessary files for your phone.
  3. (PC) Connect your phone to the PC with a USB cable. Run the 'Nexus Root Toolkit' software and click on 'Unlock'. Follow the on screen instructions to unlock your phone.
  4. (PC) Download Nexus S factory image from here
  5. (PC) Unzip the downloaded image in the installation directory of Nexus Root Toolkit. In my case the path was C:\Program Files\WugFresh Development\data
  6. (Phone) Turn off your device 
  7. (Phone) Go to Bootloader (press&hold volume up button then press&hold power button) 
  8. (PC) Go to the folder where you unzipped the factory image. Make sure that the folder contains adb.exe and fastboot.exe.
  9. (PC) Double click on flash-all.bat file. This will flush the factory image in the phone.
  10. (PC) When done, click on 'OEM Lock in the Nexus Root Toolkit to lock bootloader again.
Enjoy your Jelly Bean:)

Friday, December 14, 2012

Installing R in Ubuntu

To install R (http://cran.r-project.org) and desired packages in Ubuntu, follow the steps:
  1. sudo apt-get install r-base
  2. R (this will open R command window)
  3. To add a package, e.g., signal, run the following
    • install.packages("signal")
    • packageStatus()
    • update.packages()
 That's it!

** Adding R repository paths to package manager may be necessary.

Wednesday, August 8, 2012

Latex: Multirow Example


Recently, I found it difficult to create a table with multi-row and multi-column combination. Here is an simple example.

The latex code to create above table.

\begin{tabular}
{|c|c|c|c|}
\hline
\multirow{1}{*}{{1}} & \multirow{2}{*}{{2}} & \multirow{3}{*}{{3}} & \multirow{6}{*}{{6}} \\
\cline{1-1} \multirow{1}{*}{{1}} & & & \\
\cline{1-2} \multirow{1}{*}{{1}} & \multirow{2}{*}{{2}} & & \\
\cline{1-1} \cline{3-3} \multirow{1}{*}{{1}} & & \multirow{3}{*}{{3}}& \\
\cline{1-2} \multirow{1}{*}{{1}} & \multirow{2}{*}{{2}} & & \\
\cline{1-1} \multirow{1}{*}{{1}} & & & \\
\hline
\end{tabular}