Skip to content

Instantly share code, notes, and snippets.

View hadl's full-sized avatar

Andreas von Bibow hadl

View GitHub Profile
@hadl
hadl / Default Logrotation
Created January 21, 2014 10:07
Default Logrotation
# place in /etc/logrotate.d/
{DIR}*.log {
daily
rotate 7
compress
delaycompress
notifempty
}
@hadl
hadl / file delete older than x days
Last active January 12, 2018 09:08
Delete PNGs older than 30 days
# more info: http://www.vionblog.com/linux-delete-files-older-than-x-days/
find . -type f -name '*.png' -mtime +30 -exec rm {} \;
# better use delete flag :)
find . -type f -name '*.png' -mtime +30 -delete;
# use -mmin instead of -mtime for minutes
@hadl
hadl / imagemagick extend image canvas
Last active January 2, 2016 11:49
Extend Icon-Files to 20x20px and preserve colors
mogrify -background transparent -gravity center -extent 20x20 -format png -colorspace sRGB -define png:color-type=6 -path resized *.png
@hadl
hadl / microtime_diff.php
Last active March 5, 2021 04:05
PHP Microtime Diff -- Calculate a precise time difference
<?php
/**
* Calculate a precise time difference.
* @param string $start result of microtime()
* @param string $end result of microtime(); if NULL/FALSE/0/'' then it's now
* @return flat difference in seconds, calculated with minimum precision loss
*/
function microtime_diff($start, $end = null)
{
if (!$end) {