function ShowGridLine(lon,lat,NSkip,LineC,LineS,LineM) % To show a 2d mesh-grid defined by given grid points % similar to the function mesh? % Example: % ShowGridLine(lon,lat,2,'k','-','.') % http://scriptdemo.blogspot.com % if (nargin>3) if exist('LineC','var')~=1 LineC='k'; end if exist('LineS','var')~=1 LineS='-'; end if exist('LineM','var')~=1 LineM='none'; end elseif (nargin>=2) if exist('NSkip','var')==1 if ischar(NSkip) LineC=NSkip; clear NSkip; end end if exist('NSkip','var')~=1 NSkip=5; end if exist('LineC','var')~=1 LineC='k'; end if exist('LineS','var')~=1 LineS='-'; end if exist('LineM','var')~=1 LineM='none'; end elseif (nargin==0) close all; [xx,yy]=meshgrid(1:19,1:19); ShowGridLine(xx,yy,1,'k','-'); plot(4,4,'o','markerfacecolor','k','markersize',4,'markeredgecolor','k'); plot(16,16,'o','markerfacecolor','k','markersize',4,'markeredgecolor','k'); plot(4,16,'o','markerfacecolor','k','markersize',4,'markeredgecolor','k'); plot(16,4,'o','markerfacecolor','k','markersize',4,'markeredgecolor','k'); set(gcf,'color','w'); set(gca,'xtick',2:2:18,'ytick',2:2:18,'ydir','r','xaxislocation','top') axis equal; axis tight; xlabel('Go Board','fontweight','bold','fontsize',18,'color','red'); return else help ShowGridLine return end [N1,N2]=size(lat); if ~ishold hold on; end for NL=1:NSkip:N2 hp=plot(lon(:,NL),lat(:,NL)); set(hp,'color',LineC,'linestyle',LineS,'Marker',LineM) end for NL=1:NSkip:N1 hp=plot(lon(NL,:),lat(NL,:)); set(hp,'color',LineC,'linestyle',LineS,'Marker',LineM,'tag','gridLines') end |
Friday, August 24, 2012
[Matlab] show 2d mesh grid
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 |
[Bash] mail2me: send email with attachments from terminal
This is mutt version. A "mail" version is here.
#!/bin/bash # send files to an email account as the attachment(s) # usage: # mail2me email -s 'YourSubject' YourAttachments # http://scriptdemo.blogspot.com function isEmail() { cEmail=`echo $1 | grep "^[a-zA-Z]\+\([._][a-zA-Z0-9]\+\)*@\([a-zA-Z0-9]\+\.\)\+[a-zA-Z]\{2,3\}$"` if [ ${#cEmail} -gt 0 ]; then echo "true" else echo "false" fi } function isServerOn() { myS=$1 myp=`ping -c 2 ${myS} 2>&1 | grep "% packet" | awk '{print $6*100}'` if [ ${#myp} -eq 0 ]; then echo "-1" #server: ${myS} is not valid elif [ ${myp} -eq 100 ]; then echo "0" #server: ${myS} is off else echo "1" #server: ${myS} is $(( 100 - ${myp}))% response fi } if [ $# -le 1 ]; then echo "usage: mail2me email -s Subject file1 [file2] ..." exit fi #check email targetEmail=$1 isValidEmail=`isEmail ${targetEmail}` [ ${isValidEmail} == "false" ] && echo "${targetEmail} is not a valid email address!!!" && exit #check smtp server smtpS=`echo ${targetEmail} | awk -F\@ '{print $2}'` smtpS="smtp.${smtpS}" isOnline=`isServerOn ${smtpS}` if [ ${isOnline} == "-1" ]; then echo "SMTP server: ${smtpS} is invalid. STOP" && exit elif [ ${isOnline} == "0" ]; then echo "SMTP server: ${smtpS} is offline. STOP" && exit fi #send email numF=0 nf=2 isDebug=0 shift #shift the email while [ $# -ge 1 ] do case $1 in -s|-S) mysubj=$2 shift; shift; ;; -d|-D) isDebug=1 shift ;; *) if [ -f ${tmpfn} ]; then myfile[${numF}]=$1 numF=`expr ${numF} + 1` else echo "$1 is not found!" fi shift ;; esac done if [ ${numF} -eq 1 ]; then [ ${#mysubj} -eq 0 ] && mysubj="[script] ${myfile[0]}" elif [ ${numF} -gt 1 ]; then [ ${#mysubj} -eq 0 ] && mysubj="[script] backup ${myfile[0]} etc." else echo "no file is found!!!" && exit fi if [ ${isDebug} -eq 1 ]; then echo "echo \"The attachment is ${myfile[*]} sent by `whoami` from `hostname`\" | mutt -s '${mysubj}' -a ${myfile[*]} -- ${targetEmail}" else echo "The attachment is ${myfile[*]} sent by `whoami` from `hostname` " | mutt -s "${mysubj}" -a ${myfile[*]} -- ${targetEmail} fi |
Labels:
attachment,
linux,
mail,
multiple,
mutt,
script,
send email from terminal
Subscribe to:
Posts (Atom)