Skip to content

Instantly share code, notes, and snippets.

View sebastian13's full-sized avatar

Sebastian Plocek sebastian13

  • Vienna, Austria
View GitHub Profile
@click0
click0 / random-ipv6-address-generator.sh
Created April 24, 2011 17:48
Random generator ipv6 addresses within your ipv6 network prefix.
#Random generator ipv6 addresses within your ipv6 network prefix.
#!/usr/local/bin/bash
# Copyright
# Vladislav V. Prodan
# universite@ukr.net
# 2011
array=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
@gionn
gionn / pfdel.perl
Created July 10, 2012 15:29
pfdel - deletes message containing specified address from Postfix queue. Matches either sender or recipient address.
#!/usr/bin/perl -w
#
# pfdel - deletes message containing specified address from
# Postfix queue. Matches either sender or recipient address.
#
# Usage: pfdel <email_address>
#
use strict;
@cosimo
cosimo / parse-options.sh
Created September 21, 2012 09:31
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
@aktau
aktau / bench.sh
Last active October 24, 2018 19:47
Benchmark which method plays best with pg_dump for rsyncability
#!/bin/bash
# look out for the speedup factors reported, my
# tests indicate that `pigz --rsyncable` wins for
# the compressed format, but that the raw uncompressed
# format is the best if you want optimal rsyncability.
#
# This makes sense of course, but for many of us it's
# not feasible to keep uncompressed copies around, as the
# database can be huge and full of compressible data.
@raramuridesign
raramuridesign / wp-sql-replace-url
Created October 29, 2014 11:34
Wordpress replace old url with new url [mysql search and replace]
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
#Random generator ipv6 addresses within your ipv6 network prefix.
#!/usr/local/bin/bash
# Copyright
# Vladislav V. Prodan
# universite@ukr.net
# 2011
array=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
@luciomartinez
luciomartinez / slash.sh
Last active May 13, 2024 08:13
Add or Remove trailing slash in bash
### Add trailing slash if needed
STR="/i/am/a/path"
length=${#STR}
last_char=${STR:length-1:1}
[[ $last_char != "/" ]] && STR="$STR/"; :
echo "$STR" # => /i/am/a/path/
@nurtext
nurtext / .htaccess
Last active May 1, 2023 19:24
Tell apache we're on HTTPS if reverse proxy is serving the site using SSL
# Let apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
# Redirect to HTTPS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IFModule>
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@edtjones
edtjones / zabbix_cleanup.sql
Created February 10, 2016 13:55
Clean up zabbix database
SET @history_interval = 7;
SET @trends_interval = 90;
DELETE FROM alerts WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60);
DELETE FROM acknowledges WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60);
DELETE FROM events WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60);
DELETE FROM history WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60);
DELETE FROM history_uint WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60);
DELETE FROM history_str WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60);