Skip to content

Instantly share code, notes, and snippets.

@Programie
Programie / mcmgr.sh
Last active August 29, 2015 14:02
Minecraft Server Management Script
#! /bin/bash
SCRIPTNAME="mcmgr"
# User/Group
RUNUSER="minecraft"
RUNGROUP="minecraft"
# Minecraft paths
MINECRAFTPATH="/opt/minecraft"
@Programie
Programie / getHolidays.php
Created August 27, 2014 18:38
Get a list of holidays in the specified year
<?php
/**
* Returns the holidays of the given year
*
* @param int $year The year of which the holidays should be returned
* @return array The holidays (Each element represents a date in format Y-m-d)
*/
function getHolidays($year)
{
$easterSunday = easter_date($year);
@Programie
Programie / check-dns.sh
Last active August 29, 2015 14:07
Simple DNS check script
#! /bin/sh
# Simple DNS check script
#
# Use it to test forward and reverse DNS entries for the given IP address.
# It requires the dnsutils package which contains the dig command.
IP="$1"
if [ -z "$IP" ]; then
@Programie
Programie / formatFileSize.php
Created November 25, 2014 23:18
Format bytes into a human readable format
<?php
/**
* Format the given file size in bytes to a human readable format.
*
* @param int $size The file size to format in bytes
* @param int $precision The optional number of decimal digits to round to
* @return string The formatted file size (e.g. "4.7G")
*/
function formatFileSize($size, $precision = 1)
{
@Programie
Programie / squid-rewrite-ps3-cdn.php
Last active August 29, 2015 14:11
A simple rewrite script for PS3 Downloads which can be used as redirect_program in Squid3
#! /usr/bin/env php
<?php
/**
* This is a simple rewrite script for use with Squid3.
*
* The primary use case for this script is to fetch any PKG URL which might be downloaded from the Playstation CDN and download them somewhere different.
* This allows downloading big games on an always-on machine which takes less power than the Playstation. Or just download the file somewhere else where a fast internet connection is available.
*
* Just place any downloaded pkg-file into the directory configured in PKG_PATH and accessible via LOCAL_URL. Your Playstation will magically download the file from your own server.
*
@Programie
Programie / svn-switch.php
Created January 30, 2015 14:54
Easily switch between trunk, tags and branches in SVN
<?php
function getSvnInfo($path = "")
{
$info = array();
foreach (explode("\n", shell_exec("svn info " . $path)) as $line)
{
$line = trim($line);
if (!$line)
@Programie
Programie / remove-old-kernels.sh
Created June 1, 2017 09:28
Remove old and unused Linux Kernels on Debian
#! /bin/bash
dpkg --list | awk '{print $2}' | grep linux-image | grep -v -e linux-image-amd64 -e "linux-image-`uname -r`" -e `aptitude show linux-image-amd64 | grep '^Depends:' | cut -d : -f 2 | tr -d ' '` | xargs apt-get -y purge
@Programie
Programie / http-ping.sh
Created September 14, 2017 19:57
Request a specific URL in a loop using curl and display information of each result
#!/bin/bash
function http_code_to_text()
{
case "$1" in
100)
echo "Continue"
;;
101)
echo "Switching Protocols"
@Programie
Programie / keybase.md
Created September 18, 2017 13:17
Keybase proof

Keybase proof

I hereby claim:

  • I am programie on github.
  • I am programie (https://keybase.io/programie) on keybase.
  • I have a public key ASBmbyHLO3xvgZYCnEny3p86ytEeOvVqot0UQk3M8ZbUdwo

To claim this, I am signing this object:

@Programie
Programie / check_certs.sh
Created April 11, 2018 18:45
Certificate check for Check_MK
#! /bin/bash
shopt -s nullglob
DAYS_WARN=21
DAYS_CRIT=7
for CONF_FILE in /etc/apache2/sites-enabled/*_https.conf; do
DOMAIN_NAME=$(grep ServerName ${CONF_FILE} | awk '{print $2}')
CERT_FILE=$(grep SSLCertificateFile ${CONF_FILE} | cut -d \" -f 2)