Skip to content

Instantly share code, notes, and snippets.

View aozimkov's full-sized avatar
❄️
Happy coding!

Aleksey Ozimkov aozimkov

❄️
Happy coding!
View GitHub Profile
@aozimkov
aozimkov / scrape-sitemap.sh
Created October 11, 2019 16:30 — forked from pix0r/scrape-sitemap.sh
Use wget to scrape all URLs from a sitemap.xml Usage: scrape-sitemap.sh http://domain.com/sitemap.xml
#!/bin/sh
SITEMAP=$1
if [ "$SITEMAP" = "" ]; then
echo "Usage: $0 http://domain.com/sitemap.xml"
exit 1
fi
XML=`wget -O - --quiet $SITEMAP`
@aozimkov
aozimkov / gist:280e5223809c39f32b9252928d7382f0
Created August 19, 2019 11:11
Easy bash script check url status code from file
#!/bin/bash
checker(){
URL=$1
STATUS=`curl -s -o /dev/null -w "%{http_code}" $URL`
if [ $STATUS -eq 200 ]
then
@aozimkov
aozimkov / watermark.sh
Created June 24, 2019 06:24
Add text watermark with imagemagic (example)
#!/bin/bash
mkdir img-with-watermark
WATERMARK='Some text here'
for FILE in *.jpg; do
W=`identify -verbose "$FILE" | grep -oe "Geometry:.*" | sed -e 's/.*: //' | sed -e 's/x.*//'`
H=`identify -verbose "$FILE" | grep -oe "Geometry:.*" | sed -e 's/.*x//' | sed -e 's/+.*//'`
convert -background '#0000' -fill '#0004' -gravity center -size "$W"x"$(($H / 6))" caption:"$WATERMARK" ./"$FILE" +swap -gravity center -composite ./img-with-watermark/"$FILE"
done
#!/bin/bash
for FILE in $(ls *.jpg)
do
W=`identify -verbose "$FILE" | grep -oe "Geometry:.*" | sed -e 's/.*: //' | sed -e 's/x.*//'`
H=`identify -verbose "$FILE" | grep -oe "Geometry:.*" | sed -e 's/.*x//' | sed -e 's/+.*//'`
if [ "$W" -gt "$H" ]
then
mogrify "$FILE" -extent "$W"x"$W" -gravity center -quality 100 jpeg:"$FILE"
fi
if [ "$H" -gt "$W" ]
@aozimkov
aozimkov / script.sh
Last active June 18, 2018 11:33
Simple bash script checks http 200 response code for urls from file
#!/bin/bash
## This script simply gets a line (with url) from
## the file setted as parameter and checks its url
## response code
##
## example: ./script.sh urls.txt
##
## https://github.com/aozimkov
##
@aozimkov
aozimkov / optimg
Created March 1, 2018 01:10
Images optimization script
#!/bin/bash
touch optipng.log
touch jpegoptim.log
echo `date` >> optipng.log
find . -iname '*.png' -print0 | xargs -0 optipng -o7 -log optipng.log -preserve
echo `date` >> jpegoptim.log
find . -iname '*.jpg' -print0 | xargs -0 jpegoptim --max=90 --preserve --totals >> jpegoptim.log