Skip to content

Instantly share code, notes, and snippets.

@Cybso
Cybso / sort-access-log
Last active April 11, 2024 11:10
Sort apache access logs and convert 'common' into 'combined'. The output of this script can be used as input for awffull or webalizer.
#!/bin/bash
###
# Sorts the rows of one or multiple apache access_log files
# by date (ascending) and converts them from 'common' log format
# into 'combined' (if you switched the log file format meanwhile).
#
# This is useful when you want to merge multiple log files, e.g. when
# you have different files for HTTP and HTTPS.
#
# Usage:
@Cybso
Cybso / stylebot-noz.css
Last active February 1, 2024 15:50
Stylebot-CSS für noz.de als Listenanzeige
/**
* Quick-and-dirty CSS-Anweisungen für Stylebot, um das
* neue mehrspaltige Layout der NOZ (noz.de) in eine Listenanzeige
* umzuformen.
*
* Chrome: https://chrome.google.com/webstore/detail/stylebot/
* Firefox: https://addons.mozilla.org/de/firefox/addon/stylebot-web/
*/
.grid {
@Cybso
Cybso / stamp-last-page.sh
Created April 3, 2017 14:40
Put a stamp on the last page of a PDF document using PDFTK
#!/bin/bash
if [ "$1" == "" -o "$2" == "" -o "$3" == "" -o "$4" != "" -o "$1" == "-h" -o "$1" == "--help" ]; then
echo "Puts a stamp (as PDF file) onto the last page of the input" >&2
echo "file using PDFTK". >&2
echo "" >&2
echo "Usage: $0 INPUT.pdf STAMP.pdf OUTPUT.pdf" >&2
exit 1
fi
#!/usr/bin/env python
# syncldap.py - Sync user accounts from an LDAP or Active Directory to Redmine
#
# Usage: syncldap.py <database.yml> [environment]
#
# Where database.yml is the database configuration file for a redmine instance,
# and environment is the rails environment that should be used (defaults to
# 'production').
#
# Author:
@Cybso
Cybso / adblock.sh
Last active September 3, 2021 18:07 — forked from teffalump/README.md
#!/bin/sh
#Put in /etc/adblock.sh
#Script to grab and sort a list of adservers and malware
#Check proper DHCP config and, if necessary, update it
uci get dhcp.@dnsmasq[0].addnhosts > /dev/null 2>&1 || uci add_list dhcp.@dnsmasq[0].addnhosts=/etc/block.hosts && uci commit
#Leave crontab alone, or add to it
grep -q "/etc/adblock.sh" /etc/crontabs/root || echo "0 4 * * 0,3 sh /etc/adblock.sh" >> /etc/crontabs/root
#!/usr/bin/env python3
"""
Exports group addresses from ETS Inside project. Usage:
python3 inside-export-ga.py path/to/project
"""
import sys
import json
import xml.etree.ElementTree as ET
@Cybso
Cybso / verify_ssha_passwd.py
Last active May 23, 2020 10:38
PAM helper script in python to allow migration of user accounts stored in LDAP (with SSHA hashed passwords) to regular unix system users. This script will be executed is pam_unix failed and will try to verify the user password stored in /etc/shadow using SSHA algorithm.
#!/usr/bin/env python
###
# Takes a username from environment variable PAM_USER, a password from STDIN
# and tries to verify the shadow's password using LDAP's SSHA algorithm:
#
# {SSHA}...base64encodedString...
#
# If used within PAM auth this provides a compatibility layer that allows
# to migrate LDAP user into Unix user accounts. When the user's password
@Cybso
Cybso / suspend-on-idle.service
Last active March 4, 2017 20:23
Suspend system on inactivity
# /etc/systemd/system/suspend-on-idle.service
# call "systemctl daemon-reload" after creation / modification
# call "systemctl status suspend-on-idle.service" to see last log line
# call "journalctl -b0 -u suspend-on-idle" to see all log line
[Unit]
Description=Suspend on idle
Wants=network-online.target
After=network.target network-online.target
[Service]