Showing posts with label remove. Show all posts
Showing posts with label remove. Show all posts

Friday, May 3, 2013

[Matlab] remove the water bodies in a m_map figure

function m_nolakes(lakeColor)
% delete the water bodies patches in figures created by m_map
%           default lakeColor is white ([1 1 1])
% usage:
%           m_nolakes(lakeColor)
%           http://scriptdemo.blogspot.com

if nargin==0
   lakeColor=[1 1 1];
elseif nargin~=1
   help m_nolakes
   return
end

gshhstypes={'c','l','i','h','f'};
for nt=1:numel(gshhstypes)
    eval(['hw=findobj(gcf,''type'',''patch'',''tag'',''m_gshhs_',gshhstypes{nt},''',''facecolor'',lakeColor);']);
    if ~isempty(hw)
       delete(hw);
    end
end
hw=findobj(gcf,'type','patch','tag','m_coast','facecolor',lakeColor);
if ~isempty(hw)
   delete(hw);
end

Thursday, July 5, 2012

[Bash] remove the temporary files generated by latex

#!/bin/bash
# to clean the "*.blg *.bbl *.aux *.spl" files
# usage:
#          cleanlatex option
#                          -l : just list those files
#                          -f : remove by force
#                      -dvi : dvi files as well
#                  -name : only those with a specifc filename
#    e.g.,
#          cleanlatex -l
#          cleanlatex -f -name pdftest -dvi
#          http://scriptdemo.blogspot.com   

[ $# -eq 0 ] && sed -n '3,11p' `which cleanlatex` && exit

isFLname=0
isForce=0
isList=0
isDvi=0
isDebug=0
fname='*'

while test -n "$1"
do
     case "$1" in
      -l|-L)
        isList=1
        shift
        ;;
      -f|-F|-force|-del|-remove)
        isForce=1
        shift
        ;;
      -dvi)
        isDvi=1
        shift
        ;;
      -name)
        fname=$2
        fname=${fname%.*}
        shift;
        shift;
        ;;
      -debug|-Debug)
        isDebug=1
        shift
        ;;
      *)
        echo "unkown option: $1"
        shift
        ;;
     esac
done

[ ${isList} -eq 1 ] && isForce=0
flist="${fname}.spl ${fname}.aux ${fname}.bbl ${fname}.blg ${fname}.log"
[ ${isDvi} -eq 1 ] && flist="${flist} ${fname}.dvi"
if [ ${isForce} -eq 0 ]; then
   if [ ${isDebug} -eq 1 ]; then
      echo "ls ${flist}"
   else
      eval "ls ${flist} 2>/dev/null"
   fi
   exit
else
   if [ ${isDebug} -eq 1 ]; then
      echo "rm -f ${flist}"
   else
      eval "rm -f ${flist} 2>/dev/null"
   fi
fi

ShowCalendar