Skip to content

Instantly share code, notes, and snippets.

@odadoda
odadoda / docker-compose.yml
Created Sep 29, 2017
Wordpress and mariadb docker compose
View docker-compose.yml
version: "3.1"
services:
wordpress:
image: wordpress
ports:
- 8080:80
environment:
WORDPRESS_DB_PASSWORD: password
@odadoda
odadoda / pngquant all
Created Aug 4, 2014
force replace all png with pngquant result
View pngquant all
pngquant --ext .png --force *.png
View gist:c0da930a6cb1bc714dca
pngquant --quality=70-99 input.png -o output.png
@odadoda
odadoda / awk-NR.sh
Created Mar 7, 2014
Fetching one line at a time with awk
View awk-NR.sh
current_line=$(awk "NR==$current_row" "$FILE")
View zab-loop.sh
## wait for input
read -n 1 -s INPUT
# Valid input:
#
# m: next line / slide
# n: previous slide
# q: quit presenter
while [ "$INPUT" != "q" ]; do
View check-file-input.sh
# check if param 1 is not empty and if the file exists
if [ -z $1 ] ; then
echo "Param 1 missing. Must have a file to present."
exit
else
FILE="$1"
fi
if [ ! -f $FILE ] ; then
echo "File not found."
@odadoda
odadoda / subroutine.sh
Last active Aug 29, 2015
subroutines in bash
View subroutine.sh
# declare a subrutine
kewl(){
echo "kewl!";
#access arguments in $1, $2 ... etc
echo "$1"
# declare a local variable
local LOCAL_IN = 1
}
@odadoda
odadoda / case.sh
Last active Aug 29, 2015
The case builtin in bash
View case.sh
case $VAL in
( 1 ) echo "The val is 1" ; echo "Echoing out some more text" ;;
( 2 ) echo "The val is 2" ;;
( * ) echo "The value is not 1 or 2" ;;
esac
# There is a shorter version to case aswell
case $OS in
ubuntu ) echo "Running ubuntu" ;;
centos ) echo "Running centos" ;;
View for-loops.sh
# for-each
MY_ARRAY=("one", "two", "three")
for i in MY_ARRAY ; do
echo $i
done
# extended for-loop
for (( i=0; i "-lt" 3; i++ )) ; do
echo $i
View while-syntax.sh
while command ; do
something
done