This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# author Andrej Vitez | |
# This script is used as a cronjob on Ubuntu 16 on Intel NUC / Compute Stick connected to TV | |
# as a media center. The idea is to periodically kill firefox or chromium processes in order to prevent device | |
# overheat or overuse of NUC resources (memory). In case if someone is watching a long movie script | |
# will show a GUI timeout dialog so the user can abort. Similar to when a TV goes to sleep. | |
# | |
# IMPORTANT! | |
# run the script by dbus-launch to configure dbus session needed by script | |
# EXAMPLE: $ dbus-launch --sh-syntax --exit-with-session SCRIPT_PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Script that returns client IP address back to the client. | |
*/ | |
// this password should be used in original script that calls this one via HTTP request. | |
$configPassword = 'PASSWORD_TO_USE_THIS_SCRIPT'; | |
// check credentials | |
if (empty($_POST['passwd']) || $_POST['passwd'] != $configPassword) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# output unique ip addresses banned by fail2log | |
grep "Ban " /var/log/fail2ban.log \ | |
| grep `date -d "1 day ago" +%Y-%m-%d` \ | |
| awk '{print $NF " ("$NF") "$6""}' \ | |
| sort \ | |
| uniq -c \ | |
| awk '{print $2" "$3" "$4" "$1}' \ | |
| logresolve \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author Andrej Vitez | |
# Utility script for printing very simple Apache and PHP process statistics based on netstat and ps output | |
function usage() { | |
echo -e "usage: $0 toolname\n | |
Available options: | |
proc - count apache processes | |
php - count php processes | |
port80 - Connections to port 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author Andrej Vitez <[email protected]> | |
* @licence MIT | |
*/ | |
declare(strict_types=1); | |
namespace Acme\ApiPlatform\Extension; | |
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\ContextAwareQueryCollectionExtensionInterface; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bash prompt for GIT and Symfony support | |
# | |
# Author: Andrej Vitez <[email protected]> | |
# | |
# Add this file to your homedir .bash_profile file or create a new one under | |
# /etc/profile.d/git-symfony.sh | |
# This script will add current git branch to your Bash prompt. Also it will try to extract | |
# Symfony APP_ENV environment variable and add it to Bash prompt. | |
# | |
# If no GIT or Symfony data is available in current directory context a default Bash prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bash prompt for LXC prompty detection | |
# | |
# Author: Andrej Vitez <[email protected]> | |
# | |
# Add this file to your homedir .bash_profile file or create a new one under | |
# /etc/profile.d/lxc.sh | |
# | |
# This script will add LXC tag to your PS prompt to hint user that is using lxc container. | |
# Skip all for noninteractive shells. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* CSV reader class that supports mapping columns with custom names. | |
* | |
* @author Andrej Vitez <[email protected]> | |
*/ | |
class CsvReader implements Iterator { | |
private string $filePath; | |
private array $columns = []; |