Skip to content

Instantly share code, notes, and snippets.

@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 / link-ssl-ca.sh
Created March 11, 2017 17:57
Find the right issuing CA certificate for the given certificate (based on the subject) and symlink it to the specific target file.
@Programie
Programie / require.sh
Last active March 8, 2022 18:04
A simple function for Bash to require specific commands
#! /bin/bash
set -e
# This is a simply function to require a specific command
# The script will print an error message "Command x not found!" and exit if the command does not exist
function require()
{
which $1 > /dev/null 2>&1 || (echo "Command '$1' not found!"; exit 1)
}
@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 / 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 / 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 / samp-initd.sh
Last active August 16, 2021 19:39
Init.d Script for SA-MP server
#! /bin/bash
# This is a simple daemon script for Linux to start you SAMP servers as daemons.
# So it is possible to auto start the SAMP servers if you restart you Linux server.
# It will also prevent you from multiple launchings of the same SAMP server.
#
# Login to you Linux server using SSH or whatever you want to use to get a terminal of you server.
# Create a directory "/opt/samp/port-of/your/samp-server".
# Download the SAMP server for Linux from the SAMP website (http://www.sa-mp.com) using wget (Example: "wget http://files.sa-mp.com/samp03bsvr_R2.tar.gz").
# Extract the archive using "tar -xf samp03bsvr_R2.tar.gz".
@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 / 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 / reorganise-music.sh
Created August 25, 2014 00:00
Reorganise music from ID3 tags
#! /bin/bash
BASEPATH="/data/music" # Replace with your music directory
for FILE in $BASEPATH/*.mp3; do
ID3_INFO="`id3info \"$FILE\" | grep -i \"===\"`"
TITLE=$(echo "$ID3_INFO" | grep -i TIT2)
ARTIST=$(echo "$ID3_INFO" | grep -i TPE1)
ALBUM=$(echo "$ID3_INFO" | grep -i TALB)