Thursday, November 1, 2018

Gitlab Runner Register: x509: certificate signed by unknown authority Error

For Gitlab CI/CD, I was trying to register a runner using "gitlab-runner register" command; but I was continuously getting error " x509: certificate signed by unknown authority". After trying to fix the issue by SSL certificates path, I finally solved it using CURL. Here is the command I used.

curl --cacert <cert_name_fullchain>.crt --request POST  "https://<domain>/api/v4/runners/" --form "token=<the_token>" --form "description=test" --form "tag_list=test".

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}

Wednesday, July 25, 2012

Samsung Nexus S i9020a: OTA Update to JB 4.1.1 from 4.0.4

Several user have reported the following procedure as successful, but some failures were also reported. Try at your own risk:)

  1. Connect your charger! This is a prerequisite
  2. Go into airplane mode
  3. Under settings->apps->all (scroll the page to the left), 
      • select 'Google Services framework'
      • force stop it and 
      • then delete its data


  4. Enable wifi only (don't leave airplane mode)
  5. Settings->about->system updates->check for update.

Repeat this several times if it doesn't work at first. There is no need to remove the sim card or  reboot.

Monday, April 9, 2012

Samsung Nexus S i9020a: Update to ICS 4.0.4 from 2.3.4/2.3.6 (without rooting)

Update from 2.3.4 (GTJ61)/2.3.6 (GRK39C) to 2.3.6 (GRK39F)

  1. Download this file
  2. Rename the downloaded file to update.zip
  3. Put it update.zip you have downloaded on your sd card. 
  4. Turn off your device 
  5. Go to Bootloader (press&hold volume up button then press&hold power button) 
  6. When in Fastboot mode navigate to Recovery using volume up/down buttons 
  7. Press the power key to select Recovery 
  8. If you see a warning logo, press the power button and then press volume up button then release both to go to the Main Recovery menu
  9. From the menu, select Apply update from /sdcard, and choose update.zip from the list. 
  10. When update is finished go back and select reboot system now. 
Update from 2.3.6 (GRK39F) to 4.0.4 (IMM76D)

  1. Download this file
  2. Use the above steps again to update.
*** The same procedure should work for other devices as well but the file would be different. You will have to find the right update file.

Saturday, December 10, 2011

HowTo: Root HTC Droid Incredible || Android Phone

Follow the steps to get root access of a HTC droid incredible phone and install CyanogenMode Android OS using windows PC.

  1. Install HTC USB Drivers on your PC. Driver can be found here.
  2. Download this kit that contains adb, fastboot and other necessary scripts.
  3. Connect your phone with the PC via usb cable with USB Debugging enabled in the phone. (do not select file transfer mode for the sdcard).
  4. Download revolutionary from http://revolutionary.io/ and collect the Beta Key.
  5. Unzip the revolutionary-x.x.zip inside the folder where adb.exe is available.
  6. Run revolutionary.exe from command line.
  7. Then follow the steps from here to install CyanogenMode.

Wednesday, June 29, 2011

Creating EPS figure in Linux

Use the following steps to create eps figure in linux. 
  1. Use openoffice to draw the figure
  2. Export the file as figure.pdf
  3. Run $pdftops -eps figure.pdf. This will create a file figure.eps
  4. Run $cat figure.eps | ps2eps > MyFigure.eps. This will fix the bounding box of the eps file.

Thursday, June 23, 2011

HowTo: Build GNU RADIO with UHD


 Platform: Ubuntu Lucid 10.04/10.10

** All the following commands (in italic) are to be run at the shell.
  • CMAKE: Check if CMAKE is installed (just try to execute command cmake). If not installed then do the following.
    2. Unzip
    3. Goto the folder by $cd ~/cmake-X.X.X
    4. Run commands $./bootstrap; make; sudo make install
  • GIT: Check if GIT is installed (just try to execute command git). If not then install it from Applications->Ubuntu Software Center
  • LibUSB: If LibUSB is not installed...
    2. Unzip
    3. Goto the folder by $cd ~/libusb-X.X.X
    4. Run commands $./configure; make; sudo make install
  • GNURADIO Pre-Requisites:
    $sudo apt-get -y install libfontconfig1-dev libxrender-dev libpulse-dev swig g++ automake autoconf libtool python-dev libfftw3-dev \
    libcppunit-dev libboost-all-dev libusb-dev fort77 sdcc sdcc-libraries \ 
    libsdl1.2-dev python-wxgtk2.8 git-core guile-1.8-dev \
    libqt4-dev python-numpy ccache python-opengl libgsl0-dev \
    python-cheetah python-lxml doxygen qt4-dev-tools \
    libqwt5-qt4-dev libqwtplot3d-qt4-dev pyqt4-dev-tools python-qwt5-qt4
  • Download and Install UHD
    $git clone git://ettus.sourcerepo.com/ettus/uhd.git
    $cd ~/uhd/host/
    $mkdir build
    $cd build
    $cmake ../
    $make
    $make test
    $sudo make install
    $sudo ldconfig
  • Download and Install GNURADIO
    $git clone git://gnuradio.org/gnuradio.git
    $cd ~/gnuradio
    $git branch --track next origin/next
    $git checkout next 
    $./bootstrap
    $PKG_CONFIG_PATH=~/uhd/host/build/
    $export PKG_CONFIG_PATH
    $./configure --enable-gr-uhd
    $make
    $make check
    $sudo make install
    $sudo ldconfig
  • Configure USRP Support
    $sudo addgroup usrp
    $sudo usermod -G usrp -a <YOUR_USERNAME>
    $echo 'ACTION=="add", BUS=="usb", SYSFS{idVendor}=="fffe", SYSFS{idProduct}=="0002", GROUP:="usrp", MODE:="0660"' > tmpfile
    $sudo chown root.root tmpfile
    $sudo mv tmpfile /etc/udev/rules.d/10-usrp.rules
    $sudo udevadm control --reload-rules

Thursday, June 2, 2011

USPR2 and Boost Problem

USRP2 requires boost package for installation. As of today (2nd June, 2011) USPR2 is supposed to work with Boost 1.36 or greater but it doesn't for 1.45. After trying several versions, I got it working with Boost 1.41.

Monday, May 23, 2011

NS3: Generate Statistical Result

By default, NS3 generates exactly same result when you run a simulation. If you want to collect statistical behavior by running the simulation multiple times, you need to avoid this default setting of NS3. One way to do this is using different seed for every simulation. Just add the following line before calling the run() method.

SeedManager::SetSeed(time(0));
Here the current system time is used as the seed which ensures that seed will be different for every simulation and hence the simulation result.

Saturday, May 14, 2011

NS3: Apply a Patch to Source

Sometimes it is necessary to apply patch to update NS3 source. Use the following steps to apply patch.

  • Download desired patchFile
  • Open shell
  • Goto ns3 root directory (cd /...path to .../ns-3***)
  • run the command 'patch -p1 < /...path to ../patchFile'

Friday, May 13, 2011

Add Header, Footer, Page Numbers to a PDF File

There are many software that can add header/footer/pageNumber in a pdf files but many of the software need license. Here is a link to do it in linux for free!.

http://forums.debian.net/viewtopic.php?t=30598

Wednesday, May 11, 2011

Bangla Font Problem in Firefox

Some versions of firefox web browser has problem in showing Bangla font properly. It generally occurs after an update of firefox to the next version. Please follow the following steps if you have this problem.

  • Download UTF-8 compliant bangla font (ex., Siyam Rupali) if you already don't have
  • In the firefox menu, go to option->option ->content
  • Select the tab 'Font & Color'
  • Select the Bangla font and save.

Monday, May 9, 2011

Android: UDP Receiver

For my android app, I needed a UDP receiver which can receive broadcast packets. So I tried to create a UDP socket using the following.

mySocket = new DatagramSocket(PORT, ADDRESS);


But this socket could only receive unicast packets not the broadcast ones. I had to change it as follows to make it work for broadcast.

mySocket = new DatagramSocket(PORT);

NS3: Wireless Jamming Model

The basic implementation of NS3 does not include anything for wireless jamming but wireless jamming is interesting research topic for wireless network security. Good news is Network Security Lab, University of Washington is working on a jamming model for NS3. Use the following link for more information.

http://www.nsnam.org/wiki/index.php/NS-3_wireless_jamming_model