From 689f7e7db5c51cd625e039bba5c9c4ecd2953ec8 Mon Sep 17 00:00:00 2001 From: robin48gx Date: Thu, 22 Jun 2017 11:26:32 +0100 Subject: [PATCH] scripts --- append_avidemux.sh | 8 +++++ fast_atan2/Makefile | 10 ++++++ fast_atan2/README.txt | 7 ++++ fast_atan2/f_atan2.c | 59 ++++++++++++++++++++++++++++++++++ fast_atan2/test.gpt | 4 +++ flac_to_mp3.sh | 28 ++++++++++++++++ flip_horizontal | 7 ++++ heater_model.gpt | 20 ++++++++++++ join_avi_files.sh | 4 +++ join_avi_mencoder.sh | 7 ++++ m4a_to_flac.sh | 27 ++++++++++++++++ m4a_to_mp3.sh | 28 ++++++++++++++++ m4a_to_ogg.sh | 28 ++++++++++++++++ make_pdfs_from_odt.sh | 13 ++++++++ my_diff.sh | 2 ++ resize.sh | 9 ++++++ simmning/sim.awk | 15 +++++++++ simmning/sim.gpt | 4 +++ simmning/sim.sh | 6 ++++ simmning/simmning_siffror.txt | 25 +++++++++++++++ vimrc.vimrc | 60 +++++++++++++++++++++++++++++++++++ 21 files changed, 371 insertions(+) create mode 100755 append_avidemux.sh create mode 100644 fast_atan2/Makefile create mode 100644 fast_atan2/README.txt create mode 100644 fast_atan2/f_atan2.c create mode 100644 fast_atan2/test.gpt create mode 100755 flac_to_mp3.sh create mode 100755 flip_horizontal create mode 100644 heater_model.gpt create mode 100755 join_avi_files.sh create mode 100755 join_avi_mencoder.sh create mode 100755 m4a_to_flac.sh create mode 100755 m4a_to_mp3.sh create mode 100755 m4a_to_ogg.sh create mode 100755 make_pdfs_from_odt.sh create mode 100755 my_diff.sh create mode 100755 resize.sh create mode 100644 simmning/sim.awk create mode 100644 simmning/sim.gpt create mode 100755 simmning/sim.sh create mode 100644 simmning/simmning_siffror.txt create mode 100644 vimrc.vimrc diff --git a/append_avidemux.sh b/append_avidemux.sh new file mode 100755 index 0000000..41aba22 --- /dev/null +++ b/append_avidemux.sh @@ -0,0 +1,8 @@ +DEOCODEC="Xvid" +AUDIOCODEC="MP3" +dd=`ls *.AVI` +avidemux --video-codec $VIDEOCODEC --audio-codec $AUDIOCODEC --force-alt-h264 --load "$dd" --save ${FIL%.*}.avi --quit +#for FIL in `ls *.AVI | sort` ; do +# echo $FIL +# avidemux --video-codec $VIDEOCODEC --audio-codec $AUDIOCODEC --force-alt-h264 --load "$FIL" --save ${FIL%.*}.avi --quit +#done diff --git a/fast_atan2/Makefile b/fast_atan2/Makefile new file mode 100644 index 0000000..7d80f88 --- /dev/null +++ b/fast_atan2/Makefile @@ -0,0 +1,10 @@ + + + +TEST: + gcc f_atan2.c -o test -lm + ./test > test.txt + ls -l test.txt + vi test.txt + echo " try plot 'test.txt' using 8:14 in gnuplot" + gnuplot < test.gpt diff --git a/fast_atan2/README.txt b/fast_atan2/README.txt new file mode 100644 index 0000000..0049895 --- /dev/null +++ b/fast_atan2/README.txt @@ -0,0 +1,7 @@ + +This fast arctan2 seems to be plus or minus 5 degree accuracy +for a typical magnitude range as found in the magnetic sense servo. + +Probably OK for use in a game but not when 0.1 degrees accuracy might be required + +22JUN2017 diff --git a/fast_atan2/f_atan2.c b/fast_atan2/f_atan2.c new file mode 100644 index 0000000..ca5c4ce --- /dev/null +++ b/fast_atan2/f_atan2.c @@ -0,0 +1,59 @@ +#include +#include + +#define PI 3.14159265358979323844 + +double angle; +double coeff_1 = PI/4.0; +double coeff_2 = 3.0*(PI/4.0); +double abs_y; + +//----------------------------------------------- +// Fast arctan2 +double arctan2(double y, double x) +{ + double r; + //coeff_1 = pi/4; + //coeff_2 = 3*coeff_1; + abs_y = fabs(y)+1e-10; // kludge to prevent 0/0 condition + if (x>=0) + { + r = (x - abs_y) / (x + abs_y); + angle = coeff_1 - coeff_1 * r; + } + else + { + r = (x + abs_y) / (abs_y - x); + angle = coeff_2 - coeff_1 * r; + } + if (y < 0) + return(-angle); // negate if in quad III or IV + else + return(angle); +} + + + +int main() { + double x,y,mag; + printf("#\n#\n#1 2 3 4 5 6 7 8 9 10 11 12 13 14 \n#\n"); + + for (x=-2.0;x<=2.0;x+=0.001) { + for(y=-2.0;y<=2.0;y+=0.001) { + mag = sqrt(x*x+y*y); + if ( mag < 1.6 && mag > 1.4 ) { + printf ( " x %f y %f mag %f atan2 %f arctan2 %f diff %f diffdeg %f\n", + x, + y, + sqrt(x*x+y*y), + atan2(y,x) * 360.0/(2*PI) , + arctan2(y,x) * 360.0/(2*PI) , + atan2(y,x) - arctan2(y,x), + 360.0/(2*PI) * (atan2(y,x) - arctan2(y,x) ) + ); + + } + } + } + return 0; +} diff --git a/fast_atan2/test.gpt b/fast_atan2/test.gpt new file mode 100644 index 0000000..f6932de --- /dev/null +++ b/fast_atan2/test.gpt @@ -0,0 +1,4 @@ + + +plot "test.txt" using 8:14 with lines +!sleep 2000 diff --git a/flac_to_mp3.sh b/flac_to_mp3.sh new file mode 100755 index 0000000..2e18ec2 --- /dev/null +++ b/flac_to_mp3.sh @@ -0,0 +1,28 @@ +#!/bin/bash + + +# converts ALAC M4A Apple nonsense files to mp3 and converts spaces and tabs +# to underscores in the file names. + +# people who put spaces in files names should be put in poorly supplied +# penal colonies along with pedos and terrorists. + +SAVEIFS=$IFS +IFS=$(echo -en "\n\b") +for f in *.flac +do + echo " f " $f + u=`echo $f | sed 's/[ ]/_/g'` + echo u is $u remove all those stupid spaces in filenames + cp $f $u + t=`echo $u | sed 's/flac$/mp3/'` + ls -l \'$u\' + echo dollar u: $u becomes dollar t: $t + echo "PROCESSING: " avconv -i \'$f\' -f mp3 $t + avconv -analyzeduration 20000000 -i $u -qscale:a 0 -f mp3 output.mp3 + echo -------------------------- CONVERTED $f + ls -l output.mp3 + mv output.mp3 $t + rm -rf $u +done +IFS=$SAVEIFS diff --git a/flip_horizontal b/flip_horizontal new file mode 100755 index 0000000..5ae6789 --- /dev/null +++ b/flip_horizontal @@ -0,0 +1,7 @@ +fred=`ls *.[jJ][Pp][Gg]` + +for l in $fred +do + convert $l -flop AF_$l + echo $l to AF_$l +done diff --git a/heater_model.gpt b/heater_model.gpt new file mode 100644 index 0000000..d7e2c4c --- /dev/null +++ b/heater_model.gpt @@ -0,0 +1,20 @@ +set xrange[0:4096] +set yrange[0:15] + +set xlabel "DAC demand in millivolts (inverted i.e. 4096-demand)" +set ylabel "Output voltage from LM2676 current source" + +R1 = 10000 +R2 = 2200 +R3 = 1500 + +f(x) = - (R1 * ( 1.2/R2 - ((x/1000.0)-1.2)/R3 ) + 1.2) + +plot f(x) +!sleep 20 + +set terminal png +set output "heater_lm2676_fb.png" + +plot f(x) + diff --git a/join_avi_files.sh b/join_avi_files.sh new file mode 100755 index 0000000..09e9655 --- /dev/null +++ b/join_avi_files.sh @@ -0,0 +1,4 @@ + +ff=`ls *.AVI` + +mencoder -oac copy -ovc copy -idx -o output.avi $ff diff --git a/join_avi_mencoder.sh b/join_avi_mencoder.sh new file mode 100755 index 0000000..137b2fc --- /dev/null +++ b/join_avi_mencoder.sh @@ -0,0 +1,7 @@ + + + +ff=`ls *.AVI` + + +mencoder -oac copy -ovc copy -idx -o output.avi $ff diff --git a/m4a_to_flac.sh b/m4a_to_flac.sh new file mode 100755 index 0000000..f8c9162 --- /dev/null +++ b/m4a_to_flac.sh @@ -0,0 +1,27 @@ +#!/bin/bash + + +# converts ALAC M4A Apple nonsense files to mp3 and converts spaces and tabs +# to underscores in the file names. + +# people who put spaces in files names should be put in poorly supplied +# penal colonies along with pedos and terrorists. + +SAVEIFS=$IFS +IFS=$(echo -en "\n\b") +for f in *.m4a +do + echo " dollar f is " $f + u=`echo $f | sed 's/[ ]/_/g'` + echo u is $u remove all those stupid spaces in filenames + cp $f $u + t=`echo $u | sed 's/m4a$/flac/'` + ls -l \'$u\' + echo dollar u: $u becomes dollar t: $t + echo "PROCESSING: " avconv -i \'$f\' -f mp3 $t + avconv -i $u -f flac output.flac + echo -------------------------- CONVERTED $f + mv output.flac $t + rm -rf $u +done +IFS=$SAVEIFS diff --git a/m4a_to_mp3.sh b/m4a_to_mp3.sh new file mode 100755 index 0000000..7fb0537 --- /dev/null +++ b/m4a_to_mp3.sh @@ -0,0 +1,28 @@ +#!/bin/bash + + +# converts ALAC M4A Apple nonsense files to mp3 and converts spaces and tabs +# to underscores in the file names. + +# people who put spaces in files names should be put in poorly supplied +# penal colonies along with pedos and terrorists. + +SAVEIFS=$IFS +IFS=$(echo -en "\n\b") +for f in *.m4a +do + echo " dollar f is " $f + u=`echo $f | sed 's/[ ]/_/g'` + echo u is $u remove all those stupid spaces in filenames + cp $f $u + t=`echo $u | sed 's/m4a$/mp3/'` + ls -l \'$u\' + echo dollar u: $u becomes dollar t: $t + echo "PROCESSING: " avconv -i \'$f\' -f mp3 $t + #avconv -i $u -qscale:a 0 -f mp3 output.mp3 + avconv -i $u -f mp3 output.mp3 + echo -------------------------- CONVERTED $f + mv output.mp3 $t + rm -rf $u +done +IFS=$SAVEIFS diff --git a/m4a_to_ogg.sh b/m4a_to_ogg.sh new file mode 100755 index 0000000..f4217c8 --- /dev/null +++ b/m4a_to_ogg.sh @@ -0,0 +1,28 @@ +#!/bin/bash + + +# converts ALAC M4A Apple nonsense files to mp3 and converts spaces and tabs +# to underscores in the file names. + +# people who put spaces in files names should be put in poorly supplied +# penal colonies along with pedos and terrorists. + +SAVEIFS=$IFS +IFS=$(echo -en "\n\b") +for f in *.m4a +do + echo " dollar f is " $f + u=`echo $f | sed 's/[ ]/_/g'` + echo u is $u remove all those stupid spaces in filenames + cp $f $u + t=`echo $u | sed 's/m4a$/ogg/'` + ls -l \'$u\' + echo dollar u: $u becomes dollar t: $t + echo "PROCESSING: " avconv -i \'$f\' -f mp3 $t + #avconv -i $u -qscale:a 0 -f mp3 output.mp3 + avconv -i $u -f ogg output.ogg + echo -------------------------- CONVERTED $f + mv output.ogg $t + rm -rf $u +done +IFS=$SAVEIFS diff --git a/make_pdfs_from_odt.sh b/make_pdfs_from_odt.sh new file mode 100755 index 0000000..2610aa3 --- /dev/null +++ b/make_pdfs_from_odt.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +#fred=`ls *.odt` +# +#for l in $fred +#do +#echo $l +#p=`echo $l | sed 's/.odt//'` +#ooconvert --force $p.odt $p.pdf +#done + +libreoffice --headless --convert-to pdf:writer_pdf_Export *.odt + diff --git a/my_diff.sh b/my_diff.sh new file mode 100755 index 0000000..5e9ce2f --- /dev/null +++ b/my_diff.sh @@ -0,0 +1,2 @@ +kompare "$2" "$5" + diff --git a/resize.sh b/resize.sh new file mode 100755 index 0000000..14b6c52 --- /dev/null +++ b/resize.sh @@ -0,0 +1,9 @@ + + + +fred=`ls *.[jJ][Pp][Gg]` + +for l in $fred +do + convert $l -resize 50% -quality 60 AA_$l +done diff --git a/simmning/sim.awk b/simmning/sim.awk new file mode 100644 index 0000000..30b4651 --- /dev/null +++ b/simmning/sim.awk @@ -0,0 +1,15 @@ + + + +BEGIN { FS = ":"; old_tid = 0.0; } + +{ + #print "min",$1,"sec",$2,"msec",$3 + tid = 60*($1); + tid += $2; + tid *= 1000.0; + tid += $3; + #print tid; + print NR, tid - old_tid, (tid - old_tid) / 1000.0; + old_tid = tid; +} diff --git a/simmning/sim.gpt b/simmning/sim.gpt new file mode 100644 index 0000000..2041e69 --- /dev/null +++ b/simmning/sim.gpt @@ -0,0 +1,4 @@ + + +plot "sim.dat" using 1:3 with lines +!sleep 20 diff --git a/simmning/sim.sh b/simmning/sim.sh new file mode 100755 index 0000000..925ef2c --- /dev/null +++ b/simmning/sim.sh @@ -0,0 +1,6 @@ + + + +cat simmning_siffror.txt | sed 's/,/:/' > dd.txt +cat dd.txt | awk -f sim.awk > sim.dat +gnuplot < sim.gpt diff --git a/simmning/simmning_siffror.txt b/simmning/simmning_siffror.txt new file mode 100644 index 0000000..0fe36db --- /dev/null +++ b/simmning/simmning_siffror.txt @@ -0,0 +1,25 @@ +00:58,780 +2:26,270 +3:53,340 +5:17,290 +6:40,810 +8:05,020 +9:27,180 +10:49,120 +12:05,500 +13:27,560 +14:44,270 +16:02,520 +17:22,080 +18:47,000 +20:05,000 +21:25,060 +22:42,980 +24:03,270 +25:13,940 +26:38,570 +27:59,240 +29:18,500 +30:28,600 +31:51,290 +32:58,940 diff --git a/vimrc.vimrc b/vimrc.vimrc new file mode 100644 index 0000000..46a4800 --- /dev/null +++ b/vimrc.vimrc @@ -0,0 +1,60 @@ + +" +" go back to command mode +" as soon as a curcor key is pressed +" +inoremap +inoremap +inoremap +inoremap + +set nu +set hlsearch +set incsearch + +" +" +" from vim forum http://vim.wikia.com/wiki/Show_fileencoding_and_bomb_in_the_status_line +" +if has("statusline") + set statusline=%<%f\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P +endif + +" ~/.vimrc (configuration file for vim only) +" skeletons +function! SKEL_spec() + 0r /usr/share/vim/current/skeletons/skeleton.spec + language time en_EN + if $USER != '' + let login = $USER + elseif $LOGNAME != '' + let login = $LOGNAME + else + let login = 'unknown' + endif + let newline = stridx(login, "\n") + if newline != -1 + let login = strpart(login, 0, newline) + endif + if $HOSTNAME != '' + let hostname = $HOSTNAME + else + let hostname = system('hostname -f') + if v:shell_error + let hostname = 'localhost' + endif + endif + let newline = stridx(hostname, "\n") + if newline != -1 + let hostname = strpart(hostname, 0, newline) + endif + exe "%s/specRPM_CREATION_DATE/" . strftime("%a\ %b\ %d\ %Y") . "/ge" + exe "%s/specRPM_CREATION_AUTHOR_MAIL/" . login . "@" . hostname . "/ge" + exe "%s/specRPM_CREATION_NAME/" . expand("%:t:r") . "/ge" + setf spec +endfunction +autocmd BufNewFile *.spec call SKEL_spec() +" filetypes +filetype plugin on +filetype indent on +" ~/.vimrc ends here