Wednesday, January 2, 2013

Quick guide for basic usage of git (on bitbucket)

The procedure for routine work on git.

Step 1: Clone the repository on your local machine by running the command given on the bitbucket site.

  • git clone https://mksaini@bitbucket.org/mksaini/test.git


Step 2: At any time, before you start editing the code, update your local repo with latest commits with the following command:

  • git pull origin master


Step 3: Make your changes in the files and commit the changes

  • git commit -m "Committing changes" -a
Step 3.1: In case you have added a new file or folder to the repo, or you want to commit only particular file or folder, you need to specifically add that before running the above mentioned commit command (in that case, the commit command should be run without option "a"):
  • git add file/folder  


Step 4: Push the changes to the remote repo, i.e., reflect the commit in the remote repo:

  • git push -u origin master
The procedure for putting code in a new repo:

Step 1: Create a new repo on bitbucket (it is better to use the same name for the repo your local project folder)

Step 2: Go to you project folder and delete any previously present git files in there
  • rm -rf .git/
Step 3: Initialise git
  • git init
Step 4: Configure it for the remote repository. You can find the command to do that on bitbucket itself. To get that, select you repo, and then select "I am starting from scratch":
  • git remote add origin https://username@bitbucket.org/your_repo.git
Step 5: Add all
  • git add *
Step 6: Commit
  • git commit -m "My first commit"
Step 7: Push the changes to the remote repo (i.e. save on bitbucket)
  • git push -u origin master

Monday, July 23, 2012

Adding existing C++ Makefile project to Ecplise for editing the files!


On linux based systems we generally compile C++ projects with Makefile. The default editors for the source code are gedit or vi/vim. However, these are not so user friendly for editing complex codes.

Therefore, many a times we want to use Eclipse for editing source files and comiple it using a Makefile. It can be done by adding the project to Eclipse in the following steps:

  1. Open Eclipse with its default workspace.
  2. Go to File->New->Makefile Project with Existing Code
  3. Browse to the main folder in which you have your project files
  4. Give appropriate project name. I generally like the name to be the same as the root folder.

Friday, March 23, 2012

How to convert windows figures (generated using PowerPoint, VISIO etc.) to EPS vector file!

Many times we find it more comfortable to draw figures on Windows programs such as VISIO and PowerPoint. The problem with these programs is that they don't have any option to save the drawings as EPS. A generally opted solution by many of us is "SAVE AS .jpg" and then use GIMP to convert to EPS.

THIS IS A VERY BAD APPROACH. 

EPS figures that are generated from jpeg are as bad as jpg, because they are not actually vectored, its just a single vector which does not scale when we zoom-in the images. 

Following are the STEPS that you can take to create proper vectored EPS figure from windows programs:
  1. Choose the "Save As" option and save the drawing in either "Enhanced Metafile (*.emf)" or " "Enhanced Windows Metafile (*.emf)", whichever is available.
    • Please remove PowerPoint (or Windows) specific special effects such as shadows or gradients. They may appear as SOLID BOX in final EPS.
    • To avoid the empty space of the slide around the drawing, group all the contents of the slide, right click, and save as *.emf. This will only save the selected group/objects in the emf file. 
  2. Convert the *.emf file into EPS file using Metafile To EPS Converter"
Please check the final drawing. You may have to do some adjustments sometimes because of compatibility issues. With VISIO it works fine.

Enjoy!
-Mukesh
    

Tuesday, February 7, 2012

Loss-less conversion of the video files to mp4 (libx264) using ffmpeg


ffmpeg -i input.* -vcodec libx264 -qscale 2 -deinterlace output.mp4
*-any format

Thursday, January 19, 2012

How to rotate videos on ubuntu!

Using mencoder:

  • To rotate by 90 degree clockwise
    • mencoder -vf rotate=1 -o output.mp4 -oac pcm -ovc lavc -fps 30 -ofps 30 input.mp4
      • It is important to specify both input and output frame rate (with fps, ofps), else you will get the  error.
  • To flip horizontally
    • mencoder -vf flip -o output.mp4 -oac pcm -ovc lavc -fps 30 -ofps 30  input.mp
Using ffmpeg
  • To rotate the video by 90 degrees, we can use the following command
    • ffmpeg -i input.mp4 -vf "transpose=1" output.mp4
      • "transpose=1" => 90 degree clockwise
      • "transpose=2" => 90 degree anti-clockwise
    • You may get the following error while running the command-"No such filter: 'transpose'". In this case, you should you need to install Libavfilter.
  • To vertically flip the video 
    • ffmpeg -i input.mp4 -vf  vflip output.mp4
  • To horizontally flip the video
    • ffmpeg -i input.mp4 -vf  hflip output.mp4

Wednesday, December 21, 2011

How to combine or join a video and an audio file on Linux?

The following command will join the audioFile(audio) and videoFIle(video) into outFile.mp4:

mencoder  -ovc copy -oac copy -audiofile audioFile.mp3 videoFile.avi -o outFile.mp4

Monday, December 12, 2011

Installing printer on Ubuntu in Soc NUS: The postscript error!

Hi,

Last few days I was trying to make a Lexmark duplex printer work on my Ubuntu system. I followed the standard steps of installing printers in SoC/NUS
  • Go to Systems->Administration->Printing 
  • Click on the Add and select Network Printer
  • From the dropdown menu, select "Windows Printer via SAMBA"
  • Lets assume we want to add printer psa518-dx printer. Also, I am staff, so I will use nusstf,  and nts09, students should use nusstu and nts27 instead:

    • add the SMB printer name as "nusstf/nts09/psa518-dx"
    • Click on "Set Authentication details now" and enter username (mukesh, no domain required) and password (..., it appeared like that for me :-))
  • Click forward and choose appropriate driver. In my case it was Lexmark
  • Click forward and again select specific driver e.g. T642 and click forward
  • Enter any printer description such as Lexmark, laserjet, PSA518 etc. and click "Apply".
  • Print the test page and click OK.
If you are lucky, this will work and you would have printed test page properly. However, in most of the cases you get an error something like this:
Postscript error: %%[ Error: configurationerror; Offending Command: setpagedevice]%%

This is because you still need to configure the printer for various details. To do that, go to the printing, right click on the installed printer, and select properties:
  • Select printer Options. In that, select Page Size-A4; Media source-Default; Double sided printing-Long edge(standard); Resolution-600
  • Select Job Options. In that, click on the "+" symbol below "Pages per slide" and select  "Two-Sided (long-edge), leave others as they are.
  • Save the settings and print the test page again!
Bingo!!! you can print now :-)