Skip to content

Commit

Permalink
Some my scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonid Beynenson authored and Leonid Beynenson committed Jan 28, 2015
0 parents commit 86935c4
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ddate
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo $(date +"%Y-%m-%d_%H-%M-%S")
2 changes: 2 additions & 0 deletions get_list_of_changed_files_from_git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#/bin/bash
git status | grep "^#\s*\(modified\|new\):\s\+" | sed -e "s/^#\s*\(modified\|new\):\s\+//" | sort | uniq | while read a; do li="$li $a"; echo $li; done | tail -n1
2 changes: 2 additions & 0 deletions get_list_of_noindexed_files_from_git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#/bin/bash
git status --porcelain | grep "^.[A-Z]" | sed -e "s/^.. *//" | sort | uniq | while read a; do li="$li $a"; echo $li; done | tail -n1
2 changes: 2 additions & 0 deletions get_ps_cmd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
ps -o args= $1
2 changes: 2 additions & 0 deletions get_ps_ppid.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
ps -o ppid= $1
1 change: 1 addition & 0 deletions script_for_logkeys.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tail -f -s0 $1 | sed -e 's/^[0-9-]\+ [0-9:+]\+ >//' -e 's/</\n\0/g'
10 changes: 10 additions & 0 deletions show_dirty_state_for_git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
git rev-parse --quiet --verify HEAD 2> /dev/null >/dev/null || exit 0
git diff --no-ext-diff --quiet --exit-code || w="*"
git diff-index --cached --quiet HEAD -- || i="+"
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
u="%"
fi
echo "$w$i$u"

#notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')" qqq
6 changes: 6 additions & 0 deletions videoconvertor_script1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
ffmpeg \
-i ~/_Work/ESMStitchingDatasets/esm_data-2014-06-18/NV_building/videos/VID_20000531_024907.3gp \
-r 29.76 -an \
-vcodec libx264 -b 2000000 \
output.avi
6 changes: 6 additions & 0 deletions videoconvertor_script2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
~/Downloads/ffmpeg.static.64bit.2014-07-16/ffmpeg \
-i $1 \
-r 29.76 -an \
-vcodec libx264 \
$2
2 changes: 2 additions & 0 deletions winchecklog
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
ps ax | fgrep " python ./logger.py winlog" | fgrep -v grep
48 changes: 48 additions & 0 deletions wingettotalresttime
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
FIRST_LINE=$(head -n1 $(winnamelog) )
LAST_LINE=$(tail -n1 $(winnamelog) )

FIRST_TIME=$(echo "$FIRST_LINE" | sed -e "s/^[^_]*_\([0-9]\+\)-\([0-9]\+\)-\([0-9]\+\)[^0-9-].*/\1 \2 \3/")
LAST_TIME=$(echo "$LAST_LINE" | sed -e "s/^[^_]*_\([0-9]\+\)-\([0-9]\+\)-\([0-9]\+\)[^0-9-].*/\1 \2 \3/")

echo "FIRST_TIME = $FIRST_TIME"
echo "LAST_TIME = $LAST_TIME"

FIRST_TIME_H=$(echo "$FIRST_TIME" | cut -d ' ' -f 1 | sed -e "s/^[ 0]*//")
FIRST_TIME_M=$(echo "$FIRST_TIME" | cut -d ' ' -f 2 | sed -e "s/^[ 0]*//")
echo "FIRST_TIME_H = '$FIRST_TIME_H'"
echo "FIRST_TIME_M = '$FIRST_TIME_M'"

LAST_TIME_H=$(echo "$LAST_TIME" | cut -d ' ' -f 1 | sed -e "s/^[ 0]*//")
LAST_TIME_M=$(echo "$LAST_TIME" | cut -d ' ' -f 2 | sed -e "s/^[ 0]*//")
echo "LAST_TIME_H = '$LAST_TIME_H'"
echo "LAST_TIME_M = '$LAST_TIME_M'"

TOTAL_TIME_M=$(calc -p "$LAST_TIME_H*60 + $LAST_TIME_M - $FIRST_TIME_H*60 - $FIRST_TIME_M" | sed -e "s/[^0-9.]//g")
echo "TOTAL_TIME_M = '$TOTAL_TIME_M'"

WINSUMREST=$(winsumrest2 | tail -n1 | sed -e "s/ .*//")
echo "WINSUMREST = '$WINSUMREST'"

INPUT_REST_TIME=$1
INPUT_REST_TIME_H=$(echo "$INPUT_REST_TIME" | sed -e "s/[^0-9]/ /g" | sed -e "s/^ *//" | sed -e "s/ \+/ /g" | cut -d ' ' -f 1 | sed -e "s/^[ 0]*//")
INPUT_REST_TIME_M=$(echo "$INPUT_REST_TIME" | sed -e "s/[^0-9]/ /g" | sed -e "s/^ *//" | sed -e "s/ \+/ /g" | cut -d ' ' -f 2 | sed -e "s/^[ 0]*//")
INPUT_REST_TIME_H=$(($INPUT_REST_TIME_H))
INPUT_REST_TIME_M=$(($INPUT_REST_TIME_M))
echo "INPUT-REST-TIME = $INPUT_REST_TIME_H h $INPUT_REST_TIME_M min"

TOTAL_TIME_NO_REST=$(($TOTAL_TIME_M - $WINSUMREST))
echo "TOTAL_TIME_NO_REST = '$TOTAL_TIME_NO_REST'"

TOTAL_TIME_NO_REST_AND_NO_INPUT_TIME_REST=$(($TOTAL_TIME_NO_REST - ($INPUT_REST_TIME_H*60) - $INPUT_REST_TIME_M))
echo "TOTAL_TIME_NO_REST_AND_NO_INPUT_TIME_REST = $TOTAL_TIME_NO_REST_AND_NO_INPUT_TIME_REST"

RESULT_TOTAL=$((6*60 - $TOTAL_TIME_NO_REST_AND_NO_INPUT_TIME_REST))
RESULT_H=$(($RESULT_TOTAL/60))
RESULT_M=$(($RESULT_TOTAL - ($RESULT_H*60) ))
echo "RESULT_TOTAL = $RESULT_TOTAL"
echo ""
echo "RESULT $RESULT_H h $RESULT_M min"

RESULT_IN_HOURS=$(calc -p "printf('%.2f', ($RESULT_H + ($RESULT_M/60)) )")
echo "RESULT_IN_HOURS = $RESULT_IN_HOURS"
3 changes: 3 additions & 0 deletions winnamelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

ls -1 /home/leonid/bin/linux-app-logger/winlog_* | grep "/winlog_20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]$" | tail -n1
3 changes: 3 additions & 0 deletions winopenlog
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
ps ax | fgrep "python ./logger.py winlog" | fgrep -v grep| sed -e "s/^.*\(winlog_[0-9_-]\+\) .*/\1/" | while read a; do echo "open $a"; path=/home/leonid/bin/linux-app-logger/$a; cat $path; echo "===================="; tail -f $path; done

5 changes: 5 additions & 0 deletions winstartlog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
cd /home/leonid/bin/linux-app-logger
#./logger.py winlog_`ddate` 30 stopfile 2>>2_stream.log
./logger.py winlog_`date +"%Y-%m-%d"` 15 2>>2_stream.log

2 changes: 2 additions & 0 deletions winstoplog
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
ps ax | fgrep "python ./logger.py winlog" | fgrep -v grep| sed -e "s/^ *\([0-9]\+\) .*/\1/" | while read a; do echo "killing $a"; kill -9 $a; done
3 changes: 3 additions & 0 deletions winsumrest
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

grep "\<rest\>" `winnamelog`
20 changes: 20 additions & 0 deletions winsumrest2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

echo "ALL LINES:"
winsumrest
echo ""

echo "STRANGE LINES:"
winsumrest | grep -v "^ *rest \+\([0-9]\+\) \+min"

echo ""

echo "SUMMING LINES:"
b=0
winsumrest | grep "^ *rest \+\([0-9]\+\) \+min" | sed -e "s/^.*rest \+\([0-9]\+\) \+min.*$/\1/" | while read a; do b=$(($b + $a)); echo "$b"; done

RESULT_VALUE=$(winsumrest | grep "^ *rest \+\([0-9]\+\) \+min" | sed -e "s/^.*rest \+\([0-9]\+\) \+min.*$/\1/" | while read a; do b=$(($b + $a)); echo "$b"; done | tail -n1)

echo ""
echo "RESULT"
echo "$RESULT_VALUE min"

0 comments on commit 86935c4

Please sign in to comment.