Skip to content

Instantly share code, notes, and snippets.

@seidler2547
seidler2547 / screen-ocr
Created November 5, 2012 10:21
Bring back the 90s - Babelfish-style on-screen OCR
#!/bin/bash
# needs:
# - bash
# - xfce4-screenshooter
# - zenity
# - ImageMagick
# - Tesseract OCR (include the languages you want)
[ "$1" ] || exec xfce4-screenshooter -r -o $0
TI=`mktemp`
@seidler2547
seidler2547 / convert.sh
Created December 29, 2012 23:51
Zionworx to Lyricue
#!/bin/sh
# you will need to get the Windows TurboDB Exchange s/w, like this:
# # wget http://dataweb.de/download/turbodbtools/tdbdataX.zip
# # unzip tdbdataX.zip
# then, copy all files from C:\Documents and Settings\All Users\...\Zionworx\2.6\Data
# into the current working dir
# Then, run this script, then you can import the lyricue.xmlz into Lyricue
# You will also need:
# - wine (because the Linux exporter of TurboDB is broken)
@seidler2547
seidler2547 / NDCMatchFilter.java
Created February 28, 2013 10:23
NDCMatchFilter for Log4J (1.2), with several modes of matching (equals, equals case insensitive, contains, regex). GPLv3
package net.teration.log4j.filter;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.Filter;
import org.apache.log4j.spi.LoggingEvent;
public class NDCMatchFilter extends Filter {
@seidler2547
seidler2547 / auto_brightness.sh
Created April 12, 2013 20:03
Automatic brightness script for use with ACPI Ambient Light sensor and xbrightness. Other sources of ambient brightness are also possible of course.
#!/bin/bash
ODB=$(xbacklight -get)
while :
do
BR=`cat /sys/class/als/acpi_als0/illuminance`
echo -n $BR
[ $BR -lt 8 ] && BR=0
DB=`echo "l($BR+1)*l($BR+1)" | bc -l`
@seidler2547
seidler2547 / amd-fx-cpufreq
Last active December 16, 2015 05:49
Plagued by the wrong CPU frequency scaling on AMD FX processors (e.g. on 3.2.0 kernel), I wrote this simple userspace governor script which will always set the two Bulldozer/Piledriver cores in the same module to the same frequency based on the current CPU usage.
for i in $(grep -Eo "cpu[0-9]+" /proc/stat); do cpufreq-set -c ${i/cpu/} -g userspace ; done
bash -c 'while :;do grep -E "cpu[0-9]+" /proc/stat;sleep 0.2;done|gawk '"'"'BEGIN{getline MINF<"/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" ;getline MAXF<"/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"}{cn=$1;sub(/cpu/,"",cn);if(cn==0)for(i in cu){ocu[i]=cu[i];cu[i]=0;oci[i]=ci[i];ci[i]=0}pg=rshift(cn,1);for(i=2;i<=NF;i++){if(i!=5)cu[pg]+=$i;ci[pg]+=$i}if(pg*2!=cn){tf=200*(cu[pg]-ocu[pg])/(ci[pg]-oci[pg]);if(tf>100)tf=100;if(tf<0)tf=0;sc=tf*(MAXF-MINF)/100+MINF-300000;sc-=sc%100000;for(j=0;j<2;j++)print sc|"cat>/sys/devices/system/cpu/cpu"(pg*2+j)"/cpufreq/scaling_setspeed"}}'"'&"
@seidler2547
seidler2547 / crontab
Created March 14, 2016 07:37
Cron entry to keep the MySQL log space at 90%
*/5 * * * * /bin/df /var/log/mysql -P | /bin/awk '/^\/dev/ { exit 100.0*$4/$2 < 10 }' || /usr/bin/mysql -u monitor -e "purge binary logs to '$(cd /var/log/mysql ; ls -1tr mysql-bin.[0-9]* | head -2 | tail -1)'"
@seidler2547
seidler2547 / flashair-download.sh
Created March 16, 2016 15:52
Script to download all pictures from a FlashAir SD card in STA mode to a specific folder on the hard drive
#!/bin/bash
IPADDR=192.168.22.120
TARGETFOLDER=/media/data/Pictures/A55
while :; do
while ! ping -c3 -w3 -q $IPADDR ; do sleep 10 ; done
echo ls | cadaver http://$IPADDR/DCIM > /tmp/listing
@seidler2547
seidler2547 / igtalk.pl
Last active September 25, 2016 15:49
Hangouts notifications for Zabbix and Icinga
#!/usr/bin/perl
use strict;
use warnings;
use Net::Jabber;
use POSIX qw(strftime);
my %vars = map { s/^ICINGA//; $_=>$ENV{"ICINGA$_"} } grep /^ICINGA.+/, keys %ENV;
my $recip = $ENV{'JABBERADDRESS'};
@seidler2547
seidler2547 / itSdark256.ini
Created November 8, 2016 12:59
Midnight Commander dark theme
# This is a 256 colors MidnightCommander color scheme
# based on the Xoria256 color scheme by Alexander Glyzov (isee@inbox.ru)
# Note you'll need mc > 4.7.5 for this scheme to work (256 colors support)
# Hint: compile from the git repository
[skin]
description=itSdark256
256colors=true
@seidler2547
seidler2547 / puppet_status.rb
Created December 16, 2016 12:53
Munin plugin to monitor/alert about the last Puppet run
#!/usr/bin/env ruby
require 'yaml'
require 'puppet'
if ARGV[0] == 'config'
puts <<END
graph_args --base 1000 -l 0 -M
graph_vlabel value
graph_title Puppet stats