Skip to content

Instantly share code, notes, and snippets.

View michabbb's full-sized avatar
💯
Need help ? Call me.....

Micha(el) Bladowski michabbb

💯
Need help ? Call me.....
View GitHub Profile
@michabbb
michabbb / 0_reuse_code.js
Last active August 29, 2015 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@michabbb
michabbb / nagios_monitor_crate_db_cluster.php
Last active August 29, 2015 14:10
In case someone is interested in monitoring a crate cluster with nagios (and php) based on this thread: https://github.com/crate/crate/issues/1396#issuecomment-64418128 - i tried to do the same with php. because (right now) i am not that familar with AngularJS - i cannot ensure that everything is translated correct, so please be aware that this …
<?php
use macropage\helper\crate as crate;
/**
* Class Mode_nagios_cratedb
*/
class Mode_nagios_crate_db_cluster_status extends Mode_nagios {
public function crate_db_cluster_status() {
@michabbb
michabbb / backup_mysql.pl
Created January 14, 2015 14:55
Backup Mysql Script Perl
#!/usr/bin/perl
use strict;
use DBI;
my $rootpwd_from = '';
my $rootpwd_to = '';
my $dbh = DBI->connect('DBI:mysql:mysql;host=localhost', 'root', $rootpwd_from, { RaiseError => 1,mysql_socket=> '/var/run/mysqld/mysqld.sock' } );
@michabbb
michabbb / mysql_defrag_all_tables.bash
Created February 24, 2015 00:56
Defrag all Tables
#!/bin/bash
#echo -n "MySQL username: " ; read username
#echo -n "MySQL password: " ; stty -echo ; read password ; stty echo ; echo
mysql -NBe "SHOW DATABASES;" | grep -v 'lost+found' | while read database ; do
mysql -NBe "SHOW TABLE STATUS;" $database | while read name engine version rowformat rows avgrowlength datalength maxdatalength indexlength datafree autoincrement createtime updatetime checktime collation checksum createoptions comment ; do
if [ "$datafree" -gt 0 ] ; then
fragmentation=$(($datafree * 100 / $datalength))
echo "$database.$name is $fragmentation% fragmented."
@michabbb
michabbb / PHPConversionTest.php
Last active August 29, 2015 14:16
try to add testunbound
public function testUnbound()
{
$xml = '
<xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="packet">
<xs:complexType>
<xs:complexContent>
<xs:extension base="RequestPacketType">
<xs:sequence>
<xs:choice maxOccurs="unbounded">
@michabbb
michabbb / tolower.sh
Created May 29, 2015 19:29
rename files to lower
#!/bin/sh
x=$(find -name '*[A-Z]*');
for i in $x; do
if [ -f "$i" ]
then
LOWER=$(echo "$i"|tr [:upper:] [:lower:]);
echo "move ${i} to ${LOWER}";
mv $i $LOWER
fi
done
@michabbb
michabbb / slack_notify.sh
Last active August 29, 2015 14:27
Notify a slack channel/user if a process is no longer running -- start with: ./slack_notify.sh <something you are watching for in the process list>
#!/bin/sh
SLACK_HOSTNAME="XXX.slack.com"
SLACK_URL="https://hooks.slack.com/services/XXXXXXXXXX"
SLACK_CHANNEL="@....."
SLACK_BOTNAME="XXXXXX"
OUTPUT=$(ps ax|grep "$1"|grep -v grep|grep -v $0)
if echo "$OUTPUT" | egrep -q "$1" ; then
echo "Still running: $1!"
@michabbb
michabbb / duptool.sh
Last active December 12, 2015 22:55
duplicity backup script for docker based duplicity and amazon s3 upload
#!/bin/bash
AWS_ACCESS_KEY_ID=xxxxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxxxxx
PASSPHRASE=xxxxxxxxxxx
# directories, space separated
SOURCE="/mnt/home/"
BUCKET=s3+http://xxxxxxxxxx
BUCKETS3=s3://xxxxxxxxxxx
LOGFILE=/mnt/var/log/duplicity.log
@michabbb
michabbb / run_endless
Created October 15, 2016 22:45
a shell script that keeps looping until an exit code is given
#!/bin/bash
# a shell script that keeps looping until an exit code is given
# if it does an exit(0), restart after a second - or if it's a declared error
# if we've restarted in a planned fashion, we don't bother with any pause
# and for one particular code, exit the script entirely.
# The numbers 97, 98, 99 must match what is returned from the PHP script
php xxxxxxxx.php
@michabbb
michabbb / avm_switch_control.php
Created January 15, 2017 16:37
Control AVM DECT Switches with php
<?php
// User defined (only part where something needs to be changed)
$fritzbox_User = 'user';
$fritzbox_Password = 'pass';
//
// /* AVM Fritz!Box Dect 200 actuator set script user303 on http://www.harmony-remote-forum.de/
// Parameters used fpr request in URL http://nas:800/fritz.php?actname=Media&action=on actname = <name of the AVM DECT actor as defined in the Fritz!Box GUI> action = on | off | toggle | poll (poll checks the current state of the actuator 0=off 1=on)
// Ressources https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AHA-HTTP-Interface.pdf Commands are sent via HTTP GET Request to the following URL
// http://fritz.box/webservices/homeautoswitch.lua?ain=<ain>&switchcmd=<cmd>&sid=<sid> (!)