Wednesday, April 27, 2022

Add watermark using imagemagick

 Link1: 

https://amytabb.com/til/photography/2021/01/23/image-magick-watermark/


Link2: 

https://www.the-art-of-web.com/system/imagemagick-watermark/

Tuesday, January 28, 2020

Change log in prompt



$ open -e .bash_profile
If this is the first time you’re editing this file, it should be empty. Add this line to the file and save.
$ export PS1="\u$ "

Options for customising the prompt

Here are a few common flags you can use to customize your Terminal prompt:
  • \d – Current date
  • \t – Current time
  • \h – Host name
  • \# – Command number
  • \u – User name
  • \W – Current working directory (ie: Desktop/)
  • \w – Current working directory with full path (ie: /Users/Admin/Desktop/)

https://medium.com/@ajaykarwal/edit-the-terminal-prompt-name-on-macos-4d80163be6a1


Add colors:https://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/

Add bold font: Bold is set by 01 so you need to add 01; before each color specification:

Tuesday, August 13, 2019

IDL resolve_routine

http://www.idlcoyote.com/tips/compile.html

nohup:


 nohup idl < bhistory.pro > out.txt &

Tuesday, April 10, 2018

Linux stuff

Change bash prompt

https://wiki.centos.org/TipsAndTricks/CustomizeBash
http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
https://superuser.com/questions/60555/show-only-current-directory-name-not-full-path-on-bash-prompt



bash newline:

printf "hi \n there \n"

echo $'hi \nthere'
Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard.


Check if directory exists (or not)
https://stackoverflow.com/questions/59838/check-if-a-directory-exists-in-a-shell-script


if [ ! -d "$DIRECTORY" ]; then
  # Control will enter here if $DIRECTORY doesn't exist.
fi

If symbolic links are present:

if [ -d "$LINK_OR_DIR" ]; then 
  if [ -L "$LINK_OR_DIR" ]; then
    # It is a symlink!
    # Symbolic link specific commands go here.
    rm "$LINK_OR_DIR"
  else
    # It's a directory!
    # Directory command goes here.
    rmdir "$LINK_OR_DIR"
  fi
fi



Sunday, April 1, 2018

Passless ssh

First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:
a@A:~> ssh-keygen -t rsa


Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last 
time:
a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password: 
From now on you can log into B as b from A as a without password.

http://www.linuxproblem.org/art_9.html


Friday, March 2, 2018

VIM commands and tidbits


Stop auto-indenting dammit!
http://vim.wikia.com/wiki/How_to_stop_auto_indenting


Search it
http://vim.wikia.com/wiki/Search_and_replace


change font size
:set guifont=Menlo:h12

Install amsmath support for vim
https://tex.stackexchange.com/questions/416030/how-do-i-make-vim-highlight-math-properly-in-the-align-environment


search and replace:
s/foo/bar/g
Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'.
:%s/foo/bar/gc
Change each 'foo' to 'bar', but ask for confirmation first.
https://vim.fandom.com/wiki/Search_and_replace





Tuesday, May 9, 2017

Python links

http://sthurlow.com/python/lesson08/

http://mathesaurus.sourceforge.net/idl-numpy.html

https://docs.python.org/2/tutorial/


Wednesday, March 22, 2017

Wednesday, March 15, 2017

IDL column width in output

Extend IDL's default column limit in output:

   OpenW, lun, 'myfile.txt', /Get_LUN, WIDTH=250
   PrintF, lun, mydata, FORMAT='(25(F9.2,x))'
   Free_LUN, lun


http://www.idlcoyote.com/fileio_tips/width.html


Monday, November 2, 2015

Formatted print in for loop in bash

for ((i=000; i<010; i++)) do echo "$(printf '%04d' $i)"; done

for FILE in *.pdf; do pdfcrop $FILE; done



To work with arrays in a list
file=(hah1 hah2 hah3)
for list in "${file[@]}"; do echo $list; done


for ((i=28; i<243; i++)) do ((var= $i-$ii)); mv pv_"$(printf '%04d' $i)".jpg pv_"$(printf '%04d' $var)".jpg; done 

http://mywiki.wooledge.org/BashGuide/Arrays


Call list using loop variable


dirlist=(p45 p46 p46_highGam sigma0.01)
numlist=(0036 0033 0021 0060)
for i in "${!dirlist[@]}"; do 
dir=${dirlist[$i]}
num=${numlist[$i]}
echo $dir $num
cd $dir/postprocess_20May2021
mv phi045deg045deg45deposit_2keV.$num.flt phi045deg0deposit_2keV.$num.flt
mv phi045deg045deg45deposit_2keV.$num.flt.StQ.flt phi045deg045deposit_2keV.$num.flt.StQ.flt
mv phi045deg045deg45deposit_2keV.$num.flt.StU.flt phi045deg045deposit_2keV.$num.flt.StU.flt
cd ../../
done

Wednesday, August 26, 2015

Monday, February 23, 2015

Check endianity

echo -n I | od -to2 | awk '{ print substr($2,6,1); exit}'
or 
echo -n I | hexdump -o | awk '{ print substr($2,6,1); exit}'

will give 1 for little endian

http://serverfault.com/questions/163487/linux-how-to-tell-if-system-is-big-endian-or-little-endian

Saturday, July 19, 2014

Check WPA settings

http://techchannel.radioshack.com/wpa-key-wireless-network-1503.html

Monday, January 6, 2014

IDL codes

http://www.astro.washington.edu/users/yoachim/code.php

Saturday, March 2, 2013

guvciew

install guvcview
open a terminal type dmesg click enter
after it stops type lsusb click enter
try the cam in guvcview

Saturday, August 25, 2012

Plot 3D in IDL

http://www.idlcoyote.com/tip_examples/plots3d.pro

http://idlastro.gsfc.nasa.gov/idl_html_help/PLOTS.html

Wednesday, July 4, 2012

ps2pdf with bounding box

To convert ps file to pdf using non-standard file size (default is A4) first read off the bounding box from the ps file :
%%BoundingBox: 0 0 1275 236

Then :
ps2pdf -dDEVICEWIDTHPOINTS=1275 -dDEVICEHEIGHTPOINTS=236 file.ps file.pdf


For ps files with offset or in general easier method:

ps2pdf file1.ps file2.pdf (give device width and height with added space if needed)
pdfcrop file2.pdf file3.pdf


For color images, default setting is to resort to lossy JPEG compression. To set to lossless compression for better images set options:
 -dAutoFilterColorImages=false  -dColorImageFilter=/FlateEncode

Expanded options list:
ps2pdf -sPAPERSIZE=a4  -dCompatibilityLevel=1.3  \
 -dEmbedAllFonts=true  -dSubsetFonts=true  -dMaxSubsetPct=100  \
 -dAutoFilterColorImages=false  -dColorImageFilter=/FlateEncode  \
 -dAutoFilterGrayImages=false  -dGrayImageFilter=/FlateEncode  \
 -dAutoFilterMonoImages=false  -dMonoImageFilter=/CCITTFaxEncode  \
 document.ps  document.pdf

The important thing for the image quality is AutoFilter...Images=false and ...ImageFilter=/FlateEncode. The first disables the automatic determination by Ghostscript of the "best" compression format, which tends to favour /DCTEncode, lossy JPEG encoding. The second set of options manually set the compression method to the lossless (de)flate encoding for colour and greyscale images and to CCITT encoding for monochrome images.



Tuesday, May 22, 2012

FFT

FFT in IDL vs Fortran

http://www.ssec.wisc.edu/~paulv/fft/fft_comparison.html