Thursday, June 1, 2017

Reduce the size of PDF files


Reduce the size of PDF file using ghost script

https://tex.stackexchange.com/questions/73444/can-pdflatex-or-any-tex-package-automatically-rescale-included-images-which-ha


gswin64c.exe -sDEVICE=pdfwrite -dMaxSubsetPct=100 -dPDFSETTINGS=/ebook -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -sOutputFile=" Thesis.pdf" -dNOPAUSE -dBATCH "PHD_Thesis_madhu.pdf "


Ghostscript resamples to a given dpi based on dPDFSETTINGS:
prepress = 300 dpi
printer = 300 dpi
ebook = 150 dpi
screen = 72 dpi

Monday, September 26, 2016

Pattern download wget

Pattern "*1080*mov" with one level (red colour) down search 

wget -A "*1080*mov" -r -np -nc -l1 --no-check-certificate -e robots=off http://www.example.com

Tuesday, April 21, 2015

Installing Torque on debian 7

# DO the following after installation into default 

# Configure the trqauthd daemon to start automatically at system boot

cp contrib/init.d/debian.trqauthd.in /etc/init.d/trqauthd.in

# Fix the server_name in /var/spool/torque/server_name 

echo "$HOSTNAME" >/var/spool/torque/server_name 


echo '/usr/local/lib' > /etc/ld.so.conf.d/torque.conf

 ldconfig

cp contrib/init.d/debian.pbs_mom.in /etc/init.d/pbs_mom
update-rc.d pbs_mom defaults

cp contrib/init.d/debian.pbs_server.in /etc/init.d/pbs_server
update-rc.d pbs_server defaults

echo "\$pbsserver $HOSTNAME" | sudo tee /var/spool/torque/mom_priv/config

echo "$HOSTNAME np=`cat /proc/cpuinfo | grep processor | wc -l`" | sudo tee /var/spool/torque/server_priv/nodes

cp pbs_server pbs_mom pbs_sched /etc/init.d/

qterm
pbs_server
pbs_mom
pbs_sched


#  see if nodes are available:
qnodes -a

# setup database

pbs_server -t create

# create queue and set server settings in database
Code:

qmgr 
create queue batch
set queue batch queue_type = Execution
set queue batch max_running = 22
set queue batch resources_max.ncpus = 24
set queue batch resources_max.nodes = 1
set queue batch resources_default.ncpus = 1
set queue batch resources_default.neednodes = 1:ppn=24
set queue batch resources_default.walltime = 3600:00:00
set queue batch max_user_run = 6
set queue batch enabled = True
set queue batch started = True
set server default_queue = batch
set server scheduling = True

exit

# restart the server
trqauthd
qterm
pbs_server
pbs_sched  # this will give some warning about missing files
pbs_mom

#  important
sudo su   # login to root 
qterm -t quick
momctl -s  % shutdown pbs_mom
killall pbs_sched  % kill all sched
pbsnodes -a  %% all should be free

qmgr -a -c 'set node cvraman state=free' 

Rename files recursively in Linux


copy folders between linux servers

rsync -avh ssh /home/foo jerry@openbsd.nixcraft.in:/home/madhu/

#In the specified directory

find /my/directory/ -name "*.jpeg" -exec rename s/.jpeg/.jpg/ {} ;

# In all subdirectories 
# Rename '.gz%0D' extension to '.gz' 

find . -name "*.gz%0D" -exec rename s/.gz%0D/.gz/ {} \;


# Unzip recursievly  in all subdirectories


find . -name "*.gz" | xargs gunzip

# find number of file in all subdirectories

find . -type f | wc -l

# Delete files with specified extension in all subbirectories

find . -name \*.tiff -type f -delete 

Delete ZIP files in all sub folders

find . -name "*.ZIP" -print0 | xargs -0 rm -rf

Unzip files in all sub folders


find . -name "*.ZIP" -exec sh -c 'unzip -d "${1%.*}" "$1"' _ {} \;

Find all files in sub directories and copy to desired folder

find <start directory> -iname "<all my files type>" -exec cp {} <target_dir> \;

# See this

$ rename 's/search/replace/;' file1 [file2 file3...]
$ rename 's/tutorial0/mymodel/;' *

Monday, June 10, 2013

How to cut video using ffmpeg

You can cut a piece of video from a bigger video like this.


ffmpeg -ss 00:00:30 -t 00:00:05 -i source_video -vcodec copy -acodec copy newfilename 

Tuesday, May 28, 2013

skype 4.2 j on debian wheezy behind proxy

The new skype 4.2 on linux machines do not offer a configuration screen when you start it for the first time. If you are behind a proxy, you  are stuck.
 Here is the quick solution.
  Start skype. The EULA screen will come up. Accept it (at your own risk). The skype log in screen will come up.  Press Cntrol + O . The configuration screen will come up.




Skype on debian Wheezy amd 64

Here are is what I did for installing skype on debian wheezy 64 bit.

 1) Enable 32 bit repositories
  
# dpkg --add-architecture i386
# apt-get update
 
 2 Install  libpulse from i386 repository
 
   
# apt-get install libpulse0:i386
 
 
Download skype from skype.com. Choose debian wheezy package (multiartch) 


# dpkg -i skype-debian_4.2.0.11-1_i386.deb

The package will fail to configure.
 
Install the dependencies by 

 #apt-get install -f


Done :)

 

Friday, December 21, 2012

File format conversion made simple

Format Junkie is an  Graphical  application which gives you an  easy file format manipulation facility on your desktop. The home page of Format Junkie is  here . It is available in launch pad so that you can quickly install it  on Ubuntu .
Some of the  file conversion  capabilities are

a) Audio: Conversion between the audio formats: mp3, mp2, wav, ogg, wma, flac, m4r, m4a and aac
b) Video: Conversion between the video formats: avi, ogv, vob, mp4, vob, flv, 3gp, mpg, mkv, wmv
c) Image: Conversion between the image formats: jpg, png, ico, bmp, svg, tif, pcx, pdf, tga, pnm
d) Iso|Cso Create an iso with selected files, convert iso to cso and vice versa.
e) Advanced Encode subtitles to an avi file.

Format Junkie Installation:
  Add the ppa to your machine

sudo add-apt-repository ppa:format-junkie-team/release
  Install format junkiee
sudo apt-get update
sudo apt-get install formatjunkie
After successful installation, you can open up the application from the Unity 'Dash'   Here is a screen shot.

Wednesday, December 19, 2012

Command-Line Multitasking with Screen


 
 Most modern Unix like  operating systems (e.g. Linux, MacOS X, and BSD) come with ( or  can be installed )  a little console-mode utility called GNU Screen.  Even some of the power user who work exclusively on console are unaware of its existence.
What is screen ?
Screen is best described as a terminal multiplexer.  That is any number of console applications can be run concurrently with in a single terminal and you can quickly switch back and forth between these applications. If you are logged to a remote server via ssh , you can run many applications in  a single ssh session. The programs will be running even if you accidentally close the ssh connection.\

Starting  screen: launching and switching between programs
Start screen just by typing screen at your favourite command shell prompt. You'll probably be greeted by a welcome message. Dismiss this and you'll have with an empty terminal containing a shell prompt, which is pretty much what you had before you started screen.

        Every program running under screen runs in a window, and every window is identified by a unique number. Screen made a new window, numbered it 0, and started a command shell inside it.

Let us run ls command in this window or any other command so that we can recognise the window later on. 

Now make another window; this will be window 1.

To do this, type C-a c; that is, type Ctrl-a and then type c

Now that you have two windows,


. To switch between windows , type C-a C-a, which will switch you to whichever window you were using before the current one. Here are some more window  switching key sequences  if you have many windows open under screen.


  1. Use C-a n and C-a p to switch to the next or previous window in the list, by number.
  2. Use C-a N, where N is a number from 0 to 9, to switch to the corresponding window.
  3. Use C-a " to get a full-screen list of windows. You can navigate this list with the arrow keys (or vi-style, with j and k), and pick a window to activate by pressing Enter when it's highlighted. C-a w will give you a small, non-interactive list of windows.
 A window can be given a name if you type  C-a A    This name will be used in the window listing, and will help you remember what you're doing in each window when you start using a lot of windows.
Exiting the last program in a window will cause the window to disappear. You can also kill misbehaving programs with C-a K.

  Terminal decoupling and re coupling
   You can detach from  the screen session by pressing C-a d.  This means the screen session will be decoupled from the   terminal in which you started it up.  If  you close the terminal in which screen is running , the session will be automatically detached.   Detaching a screen session does not terminate any of the programs running in that screen session .
    Start up a new terminal emulator, and type screen -r  . You'll be right back where you were when you detached.
   You can detach from a screen session at work, shell into the machine from home, and reattach. 

 Copying, pasting, and the scrollback buffer

Screen remembers a configurable number of scrollback lines, and you'll need them because you won't be able to use your terminal emulator's scroll features while running screen. You can access the scrollback buffer by entering "copy mode", which is accomplished by typing C-a [. You can mark text anywhere in the scrollback buffer and paste it with C-a ]

Monitoring for silence and activity
One of the disadvantages of running a bunch of programs within screen is that you can't keep an eye on all of them at the same time, since in general you can only see one at once. ) To help mitigate this problem, Screen has features that allow you to monitor a window for silence--useful for knowing when a compile has finished, for example--or activity--useful for knowing when someone is finally talking on your favourite IRC channel, for example.
To start or stop monitoring the current window for 30 seconds of silence, type C-a _; to start or stop monitoring a window for activity, type C-a M.
Config Files
   Screen looks for a startup configuration file named .screenrc in your home directory.  Look in screen man pages for options.







Friday, December 14, 2012

Remote control your desktop with android phone


Gmote is a powerful program which allows your anddroid  phone to act as a remote control for your Linux desktop.  Gmote provides all standard remote control features such as play, pause, rewind, volume controls etc.  

Gmote can also be used as a wireless Touchpad and keyboard, allowing you to control your computer at distance.   Gmote has  the ability to stream music from your computer to your phone!
 Gmote has to be set up both on your computer and on your android phone.
Here are the steps.

Setting up the Gmote Server on PC

The Gmote Server requires the Java JVM version 1.6 or higher.
To determine your java version, go to terminal and type 'java -version'.
You can download the latest JVM from http://www.java.com/en/download/index.jsp

On the computer you wish to control, download and install the appropriate package for your Ubuntu Linux system - here, after successful installation, open the terminal and type following command:

tar -zxvf GmoteServerLinux2.0.0.tar.gz
cd GmoteServerLinux2.0.0/
./GmoteServer.sh
On starting you'll see a password prompt. This allows you to set a password so that only you can connect to the server from your phone. You'll be asked to enter this password once on the phone as well. You can change your password later by right clicking on the Gmote server icon (task bar) and selecting 'Change password'.

Finally Gmore server will get started on port 8889, make sure to adjust your firewall rules accordingly to allow connection on port 8889.

Setting up the Gmote Client:
The installation process for client is fairly simple. From your Android handset, download and install the Gmote client.
You need wifi or 3G connectivity between your phone  and PC.
 Launch Gmote from your phone, select the server to connect to, and enjoy. 


Tuesday, December 11, 2012

sudo on ubuntu

Here are  some sudo   variations I use. (Be careful :) )

    sudo command - run command as root
    sudo su – root shell open
    sudo su user – open shell as a user
    sudo -k – forget your password sudo
    gksudo command – sudo visual dialog (GNOME)
    kdesudo command – sudo visual dialog (KDE)
    sudo visudo – edit / etc / sudoers
    gksudo nautilus – root file manager (GNOME)
    kdesudo konqueror – root file manager (KDE)

How to customize the GRUB 2 in Ubuntu

GRUB 2 is the next generation of GNU GRUB. All recent versions of ubuntu come with GRUB 2. GRUB 2 cleaner, safer, more robust, more portable and more powerful.

If you're already familiar with older  GRUB,   GRUB 2 configuration file is similar in broad sense, but it varies in many finer  details. Some times it can be a bit tricky too.

  The main  config file is   /etc/default/grub .  Open it using


   $ sudo gedit /etc/default/grub
  
you will  see  some thing  very similar to the following  ....


# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=7
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_LINUX_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
 
 
Some of the important configuration options you can try changing are  

Change default Timeout:
To change the default timeout option in GRUB 2, you just need to change the GRUB_TIMEOUT parameter. The value of this parameter is in sec, change this value as per your requirement.

Change the default boot option:
To change the default boot option in GRUB 2, you just need to change the GRUB_DEFAULT parameter. 0 is the first entry, so if you want Windows to be your default boot option which is, say at, 5th position in the grub menu, then you just need to change the GRUB_DEFAULT value to 4 and save the file and close it. Save the file after making all the required changes and from the terminal run the following command
sudo update-grub