scripte in "codekasten" verschoben

This commit is contained in:
age 2006-06-07 09:13:41 +00:00
parent 8c80702462
commit 0bffe48b4b
5 changed files with 0 additions and 3279 deletions

View file

@ -1,16 +0,0 @@
#!/bin/sh
## give max disk usage in %, after that a warning will be produced
MAX=15
## looks for mounted filesystems, but not proc,sys,...
DISKS=`mount |grep -iv proc |grep -iv sysfs |awk '{print $3}'`
# retrieve the IP, as the hostname is not always unique
IP=$(/sbin/ifconfig eth0 | grep "inet addr:" | sed 's/^.*inet addr:\([0-9\.]*\).*$/\1/')
for DISK in $DISKS; do
USAGE=`df -k $DISK | tail -n 1 | awk '{print $5}' | cut -d"%" -f1`
# if no number is given as percentage, do nothing
echo "$USAGE" |grep -q [0-9] && if [ "$USAGE" -gt "$MAX" ]; then
echo "`uname -n` ($IP) $DISK is at ${USAGE}% capacity" | mail -s "[diskspace] $DISK explodiert gleich" space@admin.systemausfall.org
fi
done

View file

@ -1,12 +0,0 @@
#!/bin/bash
# die sed zeile wandelt html breaks in shell breaks um ;)
# damit das greppen klappt
while true; do
wget -q -O - http://www.fireball.de/livesuche/index.html \
| grep "Klicken Sie auf eine Anfrage" \
| sed s#\<br\ *\/\>#\\n#g \
| grep "http://suche.fireball.de/cgi-bin/pursuit?query=" \
>> fireballsuchbegriffe.txt
sleep 10
done

View file

@ -1,142 +0,0 @@
#!/usr/bin/env python
# see: http://www.amk.ca/python/code/
import sys, os, getopt
try:
from PIL import Image
except ImportError:
print >>sys.stderr, ("Unable to import PIL.Image; "
"is the Python Imaging Library installed?")
sys.exit(0)
__version__ = '1.01'
__doc__ = """%s [option] file1 file2
Options:
--help Display this usage message
--html Output HTML to stdout
--resize x y Resize specified images to x,y
--rotate x Rotate the image counter clockwise for x degrees
--size Display the image sizes
--thumbnail x y Make thumbnails of specified images, ignoring existing
thumbnails that happen to be listed among the files.
If a filename is of the form *_thumb.*, it's assumed to be a thumbnail.
""" % sys.argv[0]
def is_thumbnail (filename):
"Returns true if the filename is for a thumbnail"
root, ext = os.path.splitext(filename)
return root.endswith('_thumb')
def thumbnail_name (filename):
"""Return the thumbnail form of a filename,
converting foo.jpg to foo_thumb.jpg.
"""
assert not is_thumbnail(filename)
root, ext = os.path.splitext(filename)
return root + '_thumb' + ext
def output_html (args):
for filename in args:
if is_thumbnail(filename): continue
thumbnail = thumbnail_name(filename)
if not os.path.exists(thumbnail):
print >>sys.stderr, ("%s: thumbnail %s doesn't exist" %
(sys.argv[0], thumbnail) )
im = Image.open(thumbnail)
width, height = im.size
print ('<p><a href="%s"><img src="%s" width="%i" height="%i" '
'alt="XXX" align="XXX"></a>'
'\n\nXXX\n'
'<br clear=all><hr>\n\n'
% (filename, thumbnail, width, height) )
def make_thumbnails (args):
x, y = int(args[0]), int(args[1])
args = args[2:] ; args.sort()
for filename in args:
if is_thumbnail(filename): continue
thumbnail = thumbnail_name(filename)
print >>sys.stderr, filename
im = Image.open(filename)
im.thumbnail((x,y))
im.save(thumbnail)
def rotate_images (args):
x = int(args[0])
args = args[1:] ; args.sort()
for filename in args:
im = Image.open(filename)
im2 = im.rotate(x)
im2.save(filename)
print "rotated %s %i degrees" % (filename, x)
def resize_images (args):
x, y = int(args[0]), int(args[1])
args = args[2:] ; args.sort()
for filename in args:
im = Image.open(filename)
w,h = im.size
im2 = im.resize((x,y))
print >>sys.stderr, ('%s: was %i,%i; resizing to %i,%i'
% (filename, w,h, x,y) )
im2.save(filename)
def main ():
opts, args = getopt.getopt(sys.argv[1:],
'h',
['help',
'html',
'resize',
'size',
'thumbnail',
'rotate'])
# Remove the unused option arguments
opts = [opt for opt,arg in opts]
# Print usage message if requested
if '-h' in opts or '--help' in opts:
print >>sys.stderr, __doc__
sys.exit(0)
# Ensure that exactly one option is supplied
if len(opts) == 0:
print >> sys.stderr, ("%s: must specify one of --size, --help"
"\n --html, --resize, --thumbnail --rotate" %
sys.argv[0] )
sys.exit(0)
elif len(opts) > 1:
print >> sys.stderr, ("%s: cannot specify multiple options" %
sys.argv[0] )
sys.exit(0)
# Perform each of the possible actions
opt = opts[0]
if opt == '--html':
output_html(args)
elif opt == '--resize':
resize_images(args)
elif opt == '--rotate':
rotate_images(args)
elif opt == '--size':
for filename in args:
image = Image.open(filename)
x, y = image.size
print filename, ':', x,y
elif opt == '--thumbnail':
make_thumbnails(args)
else:
print >>sys.stderr, ("%s: unknown option" % sys.argv[0])
if __name__ == '__main__':
main()

File diff suppressed because it is too large Load diff

View file

@ -1,114 +0,0 @@
#!/usr/bin/env python
## this is a dirty, lame hack by a dirty, lame guy
## - reads a .m3u file (e.g. generated by xmms)
## - converts any audiofile to wavefiles using incredible mplayer
## - provides normalized wavefiles using transcode
## - burns an audio-cd
# !!feel free to copy, modify, redistribute and at most _use_ it!!
# AGE/02004
import os,sys
import string
#recorder = "ATAPI:0,0,0" #fuer cdrecord mit 2.6 kernel und ide brenner
recorder = "0,0,0" #fuer cdrecord mit 2.6 kernel und ide brenner
__doc__ = """usage: %s file.m3u wav-destination""" % sys.argv[0]
################
### init checks
try:
m3ufile = sys.argv[1]
wavdir = sys.argv[2]
if not os.access(wavdir,os.W_OK) :
print "%s not writeable" % wavdir
sys.exit(3)
except:
print >>sys.stderr, __doc__
sys.exit(1)
print "\nDirty, lame hack in action:\n"
################
### m3u einlesen
try:
temp = open(m3ufile,"r")
m3u = temp.read()
temp.close()
except:
print "I can't find the .m3u file"
sys.exit(2)
# M's Kommentar Schnibbler
notfound = 0
while notfound == 0:
startpos = string.find(m3u,"#")
if startpos <0:
notfound +=1
endpos = string.find(m3u,"\n",startpos)
cutme = m3u[startpos:endpos]
m3u = string.replace(m3u,cutme,"")
valuepairs = string.split(m3u,"\n")
m3u = []
for i in valuepairs:
if i != "":
m3u.append(i)
# im m3u-array stehen jetzt hoffentlich ;) nur noch pfadangaben
# checken ob's stimmt & und ob alle files existieren
abort = 0
for i in m3u:
if not os.path.exists(i):
abort = abort + 1
print "===> not found: %s " % i
m3u.remove(i)
if abort > 0:
print "\nI can't find %i audiofiles - giving up" % abort
#TODO
# abfrage ob ohne die files mit gekuertzter m3u weiter gemacht werden
# soll..
sys.exit(0)
else:
print "\nI found %i audiofiles to convert, normalize and burn:" % len(m3u)
##############
### ogg/mp3 -> wav
count = 0
for file in m3u:
count+=1
# fuehrende nullen ranballern
#if count < 10:
#count0 = "0"+str(count)
#else:
#count0 = str(count)
count0 = "%.3i" % count
command = "mplayer \""+file+"\" -vc dummy -vo null -ao pcm -aofile "+wavdir+"/"+str(count0)+".wav &> /dev/null"
print "\nexec: "+command
session = os.popen(command,"w")
session.write("")
session.flush()
session.close()
#########################
### wav -> normalized wav
wavefiles = os.listdir(wavdir)
for wave in wavefiles:
command = "transcode -J normalize -y wav -i "+wavdir+"/"+wave+" -m "+wavdir+"/"+ wave+".norm &> /dev/null"
print "\nexec: "+command
session = os.popen(command,"w")
session.write("")
session.flush()
session.close()
##################
### wav -> audiocd
command = "sudo cdrecord -v -dev="+recorder+" -pad -audio "+wavdir+"/*.wav.norm"
print "\nexec: "+command
print "\nwarning: If this fails, try to change the \"recorder\" variable!"
session = os.popen(command,"w")
session.write("")
session.flush()
session.close()
#print "\n That's it! Eine Stunde coden und dafuer jetzt den Sommer geniessen..."
print "done"