Skip to content

Instantly share code, notes, and snippets.

View odadoda's full-sized avatar

Øyvind Dahl odadoda

View GitHub Profile
@odadoda
odadoda / docker-compose.yml
Created September 29, 2017 14:05
Wordpress and mariadb docker compose
version: "3.1"
services:
wordpress:
image: wordpress
ports:
- 8080:80
environment:
WORDPRESS_DB_PASSWORD: password
@odadoda
odadoda / pngquant all
Created August 4, 2014 14:12
force replace all png with pngquant result
pngquant --ext .png --force *.png
@odadoda
odadoda / gist:c0da930a6cb1bc714dca
Last active August 29, 2015 14:01
pngquant example
pngquant --quality=70-99 input.png -o output.png
@odadoda
odadoda / awk-NR.sh
Created March 7, 2014 12:51
Fetching one line at a time with awk
current_line=$(awk "NR==$current_row" "$FILE")
@odadoda
odadoda / zab-loop.sh
Created March 7, 2014 12:50
The loop in zab
## wait for input
read -n 1 -s INPUT
# Valid input:
#
# m: next line / slide
# n: previous slide
# q: quit presenter
while [ "$INPUT" != "q" ]; do
@odadoda
odadoda / check-file-input.sh
Last active August 29, 2015 13:57
check file
# 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 August 29, 2015 13:57
subroutines in bash
# 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 August 29, 2015 13:57
The case builtin in bash
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" ;;
# 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
@odadoda
odadoda / while-syntax.sh
Created February 28, 2014 15:21
while syntax
while command ; do
something
done