init of my scripts

master
Stephen Cochrane 4 years ago
parent 4c0f788d11
commit 258e03f0b1
  1. 2
      .gitignore
  2. 2
      README.md
  3. 10
      binary
  4. 10
      bip
  5. 21
      brightness
  6. 58
      picbin
  7. 14
      texbib

2
.gitignore vendored

@ -0,0 +1,2 @@
*.swp
local/

@ -1,2 +1,2 @@
# bin
My scripts
All of my scripts

@ -0,0 +1,10 @@
#!/bin/bash
isnum() { awk -v a="$1" 'BEGIN {print (a == a + 0)}' >/dev/null; }
toBinary(){
local n bit
for (( n=$1 ; n>0 ; n >>= 1 )); do bit="$(( n&1 ))$bit"; done
printf "%s\n" "$bit"
}
[ $(isnum $1) -eq 1 ] && toBinary $1 || exit 1

10
bip

@ -0,0 +1,10 @@
#!/bin/bash
addr1=$(echo $1 | cut -d "." -f 1)
addr2=$(echo $1 | cut -d "." -f 2)
addr3=$(echo $1 | cut -d "." -f 3)
addr4=$(echo $1 | cut -d "." -f 4)
. binary s
echo $(toBinary $addr1)"."$(toBinary $addr2)"."$(toBinary $addr3)"."$(toBinary $addr4)

@ -0,0 +1,21 @@
#!/bin/bash
usage () {
echo "brightness <value>"
echo "value must be in the change [0.5, 1]"
}
if [[ $# -eq 0 ]]
then
value=1
else
value=$1
fi
if [[ $(echo "$value < 0.5" | bc -l) -eq 1 || $(echo "$value > 1" | bc -l) -eq 1 ]]
then
usage
exit 1
fi
screen=$(xrandr -q | grep 'connected' | head -n 1 | cut -d " " -f 1)
xrandr --output $screen --brightness $value

@ -0,0 +1,58 @@
#/bin/bash
# @Auther Stephen Cochrane
set -e
usage () {
echo "<usage> picbin /path/to/picture"
exit $1
}
area=0
while getopts "hp:la" opt
do
case $opt in
h)
usage 0
;;
p)
path="$OPTARG"
;;
l)
link=1
;;
a)
area=1
;;
*)
exit 2
;;
esac
done
if [ $path ]
then
[ 0 -eq $# ] && usage 1
[[ ! -f $path ]] && usage 1
else
if [[ area -eq 0 ]]
then
gnome-screenshot -f /tmp/picbin.png
else
gnome-screenshot -a -f /tmp/picbin.png
fi
path="/tmp/picbin.png"
fi
abort() {
echo "Aborting upload of $path"
exit 0
}
zenity --question --text="Confirm upload."
[ ! $? ] && abort
echo "Uploading -> $path"
url=$(curl -F"file=@$path" https://0x0.st)
echo $url
[ $link ] && zenity --info --window-icon="info" --text="$url" || exit 0

@ -0,0 +1,14 @@
[[ -z $1 ]] && echo -e "Usage: texbib <file>\n* Example,\n * texbib file\n * Will generate "file.pdf" from file.tex and look for references in file.bib (if it exists)" && exit 1
[[ ! -f $1.tex ]] && echo "ERROR: \"$1.tex\" not found." && exit 1
pdflatex $1.tex && biber $1; pdflatex $1.tex && pdflatex $1.tex
rm -f *.aux
rm -f *.bbl
rm -f *.bcf
rm -f *.blg
rm -f *.log
rm -f *.xml
rm -f *.nav
rm -f *.out
rm -f *.snm
rm -f *.toc
[[ ! -f $1.bib ]] && echo "WARNING: no \"$1.bib\" found."
Loading…
Cancel
Save