Script

Filter
2017-04-25

sql

Sql
Group by having
select sku, count(*)
from trading_units
where sku is not null
and sku != ''
group by sku
having count(*) > 1;
2017-04-10

Kalenderinfo

Tips & tricks
Matematiska tips för kalendrar
Skottår:
Sker vart fjärde år, men en extra skottdag läggs till vart 100:e år.

"If the year is the last year of a century, eg. 1700, 1800, 1900, 2000,
then it is only a leap year if it is exactly divisible by 400.
Therefore, 1900 wasn't a leap year but 2000 was."

Veckonummer:
Vecka 1 är alltid den första veckan som innehåller minst 4 dagar,
beroende på vilken veckodag som anses som den första dagen i veckan.
2017-03-31

Setup rights

Bash
Bash script for setting up default rights
3
#!/bin/bash

## The files and folders to be changed...
FILES=()
FOLDERS=("public/files")

## Files...
for i in "${FILES[@]}"
do
    echo
    eval "chmod 666 $i"
done

## Folders...
FOLDERS=("public/files")
for i in "${FOLDERS[@]}"
do
    echo
    eval "chmod 777 $i"
done

## Executable files...
FILES=()
for i in "${FILES[@]}"
do
    echo
    eval "chmod +x $i"
done

##
## =    assigns some value to a variable (no surrounding spaces allowed)
## echo prints a new line
## @    refers to all elements in an array
## $    preceeds all variables
## 
2017-03-31

Ingnorera allt i Git

Git
En fil med detta innehåll ignorerar allt utom filen själv (med filnamnet .gitignore)
*!.gitignore
2017-03-30

Remove undefined indexes in php7

Php
Function for sanitizing old php code
function getArrayVal($key, $array, $default = '') {
    if (is_array($array) && array_key_exists($key, $array)) {
        return $array[$key];
    }
    return $default;
} 
🙂