Beruflich Dokumente
Kultur Dokumente
#!/usr/bin/env bash
notify-send "Battery low" --icon=battery-caution
zenity --info --text \
"<span color=\"blue\"><b>bateria baja?</b></span>\n \
<span><i>Very</i> <u>well</u>, <s>and</s> <b>you</b>?</span>\n \
<span color=\"red\">battery low</span> <span color=\"green\">color</span> <span
color=\"blue\">test</span>\n \
<span font-family=\"serif\">battery</span> \
<span font-family=\"sans\">low</span> \
<span font-family=\"mono\">///////////////////////</span>" --width=600 --height=400 & sleep 10
zenity --info --text \
"<span color=\"red\" font-family=\"sans\" font-weight=\"900\" font-size=\"xx-large\">bateria
baja</span>" --width=800 --height=600 & sleep 10
zenity --info --text \
"<span color=\"blue\" font-family=\"sans\" font-weight=\"900\" font-size=\"xx-large\">bateria
baja</span>" --width=800 --height=600 & sleep 10
zenity --question --timeout 10 --text="Backup completed. Suspend the system? \nThis dialog will
timeout in 10 seconds, after which the system will suspend."
if [[ $? -eq 1 ]] ; then
# user clicked Cancel
exit $rc
else
dbus-send --print-reply --system
\
--dest=org.freedesktop.login1
\
/org/freedesktop/login1
\
org.freedesktop.login1.Manager.Suspend boolean:true
fi
Brillo pantalla
#!/bin/bash
#xrandr --verbose | grep -i brightness | cut -f2 -d ' ' | head -n1
A=$(xrandr --verbose | grep -i brightness | cut -f2 -d ' ' | head -n1)
A=$(echo $A - 0.1 | bc)
xrandr --output eDP --brightness $A
bat baja
#!/usr/bin/env bash
notify-send "Battery low" --icon=battery-caution
zenity --info --text="bateria baja."
zenity --info --text="bateria baja"
cifrae e wav
#!/usr/bin/env python
# -*- coding: UTF-8 -*import easygui,wave
import os, random, struct
from Crypto.Cipher import AES
from Tkinter import Tk
from tkFileDialog import askopenfilename
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
#filename = askopenfilename() # show an "Open" dialog
def encrypt_file(key, in_filename, out_filename=None, chunksize=64*1024):
""" Encrypts a file using AES (CBC mode) with the
given key.
key:
The encryption key - a string that must be
either 16, 24 or 32 bytes long. Longer keys
are more secure.
in_filename:
Name of the input file
out_filename:
If None, '<in_filename>.enc' will be used.
chunksize:
Sets the size of the chunk which the function
uses to read and encrypt the file. Larger chunk
sizes can be faster for some files and machines.
chunksize must be divisible by 16.
"""
if not out_filename:
out_filename = in_filename + '.w'
iv = ''.join(chr(random.randint(0, 0xFF)) for i in range(16))
encryptor = AES.new(key, AES.MODE_CBC, iv)
filesize = os.path.getsize(in_filename)
with open(in_filename, 'rb') as infile:
with open(out_filename, 'wb') as outfile:
outfile.write(struct.pack('<Q', filesize))
outfile.write(iv)
while True:
chunk = infile.read(chunksize)
if len(chunk) == 0:
break
elif len(chunk) % 16 != 0:
chunk += ' ' * (16 - len(chunk) % 16)
outfile.write(encryptor.encrypt(chunk))
return out_filename
def decrypt_file(key, in_filename, out_filename=None, chunksize=24*1024):
""" Decrypts a file using AES (CBC mode) with the
given key. Parameters are similar to encrypt_file,
with one difference: out_filename, if not supplied
will be in_filename without its last extension
(i.e. if in_filename is 'aaa.zip.enc' then
out_filename will be 'aaa.zip')
"""
if not out_filename:
out_filename = os.path.splitext(pathFileWav)[0]
with open(in_filename, 'rb') as infile:
origsize = struct.unpack('<Q', infile.read(struct.calcsize('Q')))[0]
iv = infile.read(16)
decryptor = AES.new(key, AES.MODE_CBC, iv)
with open(out_filename, 'wb') as outfile:
while True:
chunk = infile.read(chunksize)
if len(chunk) == 0:
break
outfile.write(decryptor.decrypt(chunk))
outfile.truncate(origsize)
ke = easygui.passwordbox('contrasena para cifrar o descifrar') # clave de cifrado en caso de haberlo
activado
if len(ke) <32 :
while len(ke) < 32 :
ke = ke + "p"
elif len(ke) >32:
ke = ke[:32]
else :
ke = ke
# constantes cifrado
CIPHER_ON = 1 # cifrado activo
CIPHER_OFF = 0 # cifrado inactivo
# variables modificables a gusto
jumpsData = 10 #Espacio de muestras del framerate para la toma de datos vlidos
numFraSize = 4 # 32bits para determinar cuantos bytes ocupa el fichero oculto
header = ["S", "Y", "L", "M"] # 1 byte por cada caracter (contra menos caracteres, ms
posibilidades de error por accidente)
passphrase_cipher = ke
cipher = CIPHER_OFF
msg1 ="que hacemos?"
title1 = "eleccion"
choices = ["codificar", "descodificar"]
listTamanio.append(bytesFileAudioBase[indexSampleWav])
indexSampleWav += saltos
print "Bytes tamao fichero oculto: ", listTamanio
listTamanio.reverse()
print "Bytes tamao reordenados: ", listTamanio
desplazamiento = 0
tamanio = ""
for i in range(numFraSize):
#tamanio += bin(listTamanio[i] & 0xFF)[2:]
listTamanio[i]>>desplazamiento
tamanio += bin(listTamanio[i] & 0xFF)[2:].zfill(8)
print "byte: ", bin(listTamanio[i])[2:].zfill(8)
desplazamiento += 8
sizeFileHidden = int(tamanio, 2)
print "Bytes ocultos: ", sizeFileHidden
bytesFileOculto = []
indexDataHidden = 0
while indexDataHidden < sizeFileHidden:
bytesFileOculto.append(bytesFileAudioBase[indexSampleWav])
indexSampleWav += saltos
indexDataHidden += 1
nameFileResult = "pepe"
ficheroRecuperado = open(nameFileResult, 'wb')
newFileByteArray = bytearray(bytesFileOculto)
ficheroRecuperado.write(newFileByteArray)
ficheroRecuperado.close()
decrypt_file(ke,"pepe")
#os.remove("recuperado.cip")
easygui.textbox("hecho , archivo decodificado nombre recuperado")
os.remove("pepe")
else :
in_file= askopenfilename(title = "selecciona archivo a ocultar") # show an "Open" dialog
pathFileToHide = encrypt_file(ke,in_file)
#cantidad = float(input("Dgame una cantidad en euros (hasta con 2 decimales): "))
# DATOS DE LOS FICHEROS NECESARIOS:
#pathFileToHideCipher = pathFileToHide + ".cipher"
pathFileWav = askopenfilename(title = "selecciona archivo wav para ocultacion")
#
# COMPOSICIN DE LA TRAMA DE DATOS OCULTOS:
#
# (CABECERA)->(CIFRADO)->(TAMAO ARCHIVO)->(BYTES ARCHIVO)
#
#TRATANDO CON LOS FICHEROS:
# FICHERO BASE WAV DONDE LO VAMOS A OCULTAR
fileWav = wave.open(pathFileWav,'rb')
bytesfileWav = bytearray(fileWav.readframes(fileWav.getnframes())) # guardamos los bytes (del
muestreo) en un array de bytes
channels = fileWav.getnchannels() # canales de audio (1 mono, 2 stereo)
sampleWidth = fileWav.getsampwidth() # nmero de bytes para las muestras del samplerate
frameRate = fileWav.getframerate() # obtenemos el nmero de muestras (frames) por segundo
que realiza
numTotalFrames = fileWav.getnframes() # obtenemos el nmero total de muestras disponibles
(frames)
# calculamos el nmero total de bytes que se puede almacenar:
bytesMaximos = ((numTotalFrames / sampleWidth) / jumpsData) - len(header) - 1 # el -1 es para
evitar Bytes hurfanos
# mostramos la informacin por pantalla:
print "Nmero de canales: ",channels
print "Ancho de muestra del sample (bytes): ",sampleWidth
print "Nmero de frames totales: ", numTotalFrames
print "Capacidad mxima de almacenado: ", bytesMaximos, "Bytes (",float(bytesMaximos /
1024), "KBytes )"
indexSampleWav += jump
indexFileToHide += 1
print indexFileToHide
# GRABAMOS EL FICHERO DE AUDIO RESULTANTE:
outEstegoWAV = wave.open(pathFileWavResult, "wb")
outEstegoWAV.setnchannels(channels)
outEstegoWAV.setsampwidth(sampleWidth)
outEstegoWAV.setframerate(frameRate)
outEstegoWAV.writeframes(bytesfileWav)
outEstegoWAV.close()
easygui.textbox("hecho , archivo codificado junto al original")
fileToHide.close()
os.remove(pathFileToHide)
crear link
#!/usr/bin/env bash
file="$1"
#file=$(zenity --file-selection --title="confirme archivo a linkar")
directorio=$(zenity --file-selection --directory --title="enviar a...")
ln -sv $file $directorio
zenity --info --text="enlace creado."
diferenc 2 imagenes
#!/usr/bin/python
import cv2
#Cargamos las dos imagenes para hacer las diferencias
diff1 = cv2.imread('diff1.png')
diff2 = cv2.imread('diff2.png')
#Calculamos la diferencia absoluta de las dos imagenes
diff_total = cv2.absdiff(diff1, diff2)
#Buscamos los contornos
imagen_gris = cv2.cvtColor(diff_total, cv2.COLOR_BGR2GRAY)
contours,_ =
cv2.findContours(imagen_gris,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
#Miramos cada uno de los contornos y, si no es ruido, dibujamos su Bounding Box sobre la imagen
original
for c in contours:
if cv2.contourArea(c) >= 20:
posicion_x,posicion_y,ancho,alto = cv2.boundingRect(c) #Guardamos las dimensiones de la
Bounding Box
cv2.rectangle(diff1,(posicion_x,posicion_y),(posicion_x+ancho,posicion_y+alto),(0,0,255),2)
#Dibujamos la bounding box sobre diff1
while(1):
#Mostramos las imagenes. ESC para salir.
cv2.imshow('Imagen1', diff1)
cv2.imshow('Imagen2', diff2)
cv2.imshow('Diferencias detectadas', diff_total)
tecla = cv2.waitKey(5) & 0xFF
if tecla == 27:
break
cv2.destroyAllWindows()
encriptar
#!/usr/bin/env python
# -*- coding: UTF-8 -*import easygui
import os, random, struct
from Crypto.Cipher import AES
from Tkinter import Tk
from tkFileDialog import askopenfilename
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
def encrypt_file(key, in_filename, out_filename=None, chunksize=64*1024):
""" Encrypts a file using AES (CBC mode) with the
given key.
key:
The encryption key - a string that must be
either 16, 24 or 32 bytes long. Longer keys
are more secure.
in_filename:
Name of the input file
out_filename:
If None, '<in_filename>.enc' will be used.
chunksize:
Sets the size of the chunk which the function
uses to read and encrypt the file. Larger chunk
sizes can be faster for some files and machines.
ooo
#!/usr/bin/env bash
file="$1"
zenity --question --title="borrar_carpeta_definitivamente" --text="quieres borrar del todo este
archivo $file?"
if [ "$?" = 1 ] ; then
exit $?
else
srm "$file"
zenity --info --text="$file: archivo borrado."
fi
wine32
#!/usr/bin/env bash
file="$1"
#file=$(zenity --file-selection --title="confire archivo abrir wine32")
if env WINEPREFIX=~/.wine32 wine "$file" 2>/dev/null ; then
if [ -z "$newrez" ]
then while true
do
newrez=`zenity --entry --title="Set New Resolution" \
--text="Default Resolution: $default\n\nNew size (eg 1280x750 or
1450x1000)\n -or- \"default\""` || exit 0
case $newrez in
default|[0-9]*x[0-9]*)break ;;
esac
done
fi
case $newrez in
default)
esac
newH=`echo $newrez | cut -d'x' -f1`
newV=`echo $newrez | cut -d'x' -f2`
modeline=`cvt $newH $newV $HZ | grep Modeline`
newmode=`echo "$modeline" | sed 's/^.*"//'`
cvtrez=`echo "$modeline" | sed -e 's/_.*//' -e 's/^.*"//'`
if [ "$newrez" != "$cvtrez" ]
then newrez=$cvtrez
newH=`echo $newrez | cut -d'x' -f1`
newV=`echo $newrez | cut -d'x' -f2`
fi
scaleH=`echo -e "scale=10\n$newH / $H\nquit" | bc`
scaleV=`echo -e "scale=10\n$newV / $V\nquit" | bc`
if echo "$current" | grep -A 100 "^$tipo" | grep $newrez >/dev/null
then : already there
else xrandr --newmode "$newrez" $newmode
xrandr --addmode $tipo $newrez
fi
if xrandr --output $tipo --mode $newrez --output $tipo --fb $newrez --scale $scaleH"x"$scaleV
2>&1 | tee -a /tmp/xrandr.err
then : success
else zenity --info --title="Xrandr produced this error" --text="`cat /tmp/xrandr.err`"
The problem could be that Your video driver
does not support xrandr version 1.3
rm -f /tmp/xrandr.err
fi
resol pantalla
#!/bin/bash
# newrez
# Marc Brumlik, Tailored Software Inc, tsi-inc@comcast.net
# up to v 0.8
# use 'xrandr' to scale video output to the display
# v 0.9
# Wed Jan 2 05:23:54 CST 2013
# rewrite to handle mouse boundaries when scaled (mouse confined)
# by setting requested resolution to the unused VGA1 device
# then scaling that for display on the LVDS1 device
# v 1.1
# Fri Dec 20 08:28:08 CST 2013
# fixed issue where setting to "default" after some other resulution
# left mouse-area at prior resolution
umask 000
# resolution can optionally be specified on command line
newrez=$1
# we MUST be running xrandr 1.3 or higher
if xrandr -v | grep "RandR version 1.[012]"
then zenity --info --title="XRandR version is too old" --text="You must be running
Xrandr
version 1.3 or newer!
Time to upgrade your system :-)"
exit 0
fi
# find the currently connected devices, make a list
devices=`xrandr -q | grep connected | grep -v disconnected | cut -d"(" -f1`
# there MUST be a "connected" LVDS1 and a "disconnected" VGA1
current=`xrandr -q`
if echo "$current" | grep "LVDS1 connected" >/dev/null
then : OK
else zenity --info --title="PROBLEM" --text="Current display must be LVDS1"; exit 0
fi
if echo "$current" | grep "VGA1 disconnected" >/dev/null
then : OK
else zenity --info --title="IMPORTANT" --text="The VGA1 display resolution may be
affected by this change"
fi
esac
newH=`echo $newrez | cut -d'x' -f1`
newV=`echo $newrez | cut -d'x' -f2`
modeline=`cvt $newH $newV $HZ | grep Modeline`
newmode=`echo "$modeline" | sed 's/^.*"//'`
cvtrez=`echo "$modeline" | sed -e 's/_.*//' -e 's/^.*"//'`
if [ "$newrez" != "$cvtrez" ]
then newrez=$cvtrez
newH=`echo $newrez | cut -d'x' -f1`
newV=`echo $newrez | cut -d'x' -f2`
fi
scaleH=`echo -e "scale=10\n$newH / $H\nquit" | bc`
scaleV=`echo -e "scale=10\n$newV / $V\nquit" | bc`
if echo "$current" | grep -A 100 "^VGA1" | grep $newrez >/dev/null
then : already there
else xrandr --newmode "$newrez" $newmode
xrandr --addmode VGA1 $newrez
fi
if xrandr --output VGA1 --mode $newrez --output LVDS1 --fb $newrez --scale $scaleH"x"$scaleV
2>&1 | tee -a /tmp/xrandr.err
then : success
else zenity --info --title="Xrandr produced this error" --text="`cat /tmp/xrandr.err`"
install-depot-multisystem.sh
MultiSystem LiveUSB
fi
fi
#quelques test...
errorlist=()
testlist="apt-get sudo lsb_release tee zenity nohup xterm dpkg"
for i in ${testlist}
do
if [ ! "$(which "$i")" ]; then
errorlist=(${errorlist[@]} $i)
fi
done
#Stop si
if [ "$(echo "${errorlist[@]}")" ]; then
echo -e "\033[1;47;31m Error: ${errorlist[@]} \033[0m"
miseenforme="${errorlist[@]}"
zenity --error --text "Error: ${miseenforme}" 2>/dev/null
exit 0
fi
#si pas sudo!
if [ ! "$SUDO_USER" ]; then
msg1="L'installation de multisystem necessite les droits d'administrateur."
msg2="Installing multisystem requires administrator rights."
if [ "$(echo $LANG | grep -i "fr_FR.utf")" ]; then
zenity --info --text "<b>${msg1}</b>"
else
zenity --info --text "<b>${msg2}</b>"
fi
xterm -e "sudo "$0""
exit 0
fi
#chmod 777 /media
if [ "$(stat -c %a /media)" != "777" ]; then
chmod 777 /media
fi
#Rajouter test si deja install sortie!
if [ "$(dpkg -l | grep 'ii multisystem')" ]; then
msg1="multisystem est dj install!"
msg2="multisystem is already installed!"
if [ "$(echo $LANG | grep -i "fr_FR.utf")" ]; then
zenity --info --text "<b>${msg1}</b>"
else
zenity --info --text "<b>${msg2}</b>"
fi
exit 0
fi
#verifier que user appartiens au group disk
if [ ! "$(grep ^disk /etc/group | grep "$SUDO_USER")" ]; then
else
zenity --error --text "<b>${msg2}</b>"
fi
exit 0
fi
#Rendre executable fusermount pour bases Debian !
chmod +x "/usr/bin/fusermount" 2>/dev/null
chmod +x "/bin/fusermount" 2>/dev/null
#Modifs pour lmde!
if [ "$(stat -c "%a" $(which fusermount))" = "4754" ]; then
chmod 755 $(which fusermount)
fi
if [ "$(stat -c "%a" /media)" -lt "755" ]; then
chmod 755 /media
fi
if [ "$(stat -c "%G" "$HOME/.local")" = "root" ]; then
sudo chown $SUDO_USER:$SUDO_USER -R "$HOME"/.local
fi
#message
msg1="Dornavant pour lancer le script veuillez utiliser\nle Menu:
/Applications/Accessoires/MultiSystem."
msg2="Now to start the script please use\nthe menu: / Applications/Accessoires/MultiSystem."
if [ "$(echo $LANG | grep -i "fr_FR.utf")" ]; then
zenity --info --text "<b>${msg1}</b>"
else
zenity --info --text "<b>${msg2}</b>"
fi
#lancer gui
nohup sudo -u "$SUDO_USER" -i "/usr/local/share/multisystem/gui_multisystem.sh"&
sleep 1
exit 0
frecuencia palabras en texto
#!/usr/bin/python
# -*- coding: UTF-8 -*import easygui
from Tkinter import Tk
from tkFileDialog import askopenfilename
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
#frecuencia palabras
words= askopenfilename(title = "selecciona archivo a tratar") # show an "Open" dialog
palabras = []
frecuencias = []
'''
for i in range(6):
nuevo.append (0)
print nuevo
'''
f = open(words)
for word in f.read().split():
if word in palabras:
ind=palabras.index(word)
frecuencias[ind]=frecuencias[ind]+1
else:
palabras.append(word)
frecuencias.append(1)
print palabras
print frecuencias
mixto=zip(frecuencias, palabras)
mixto.sort()
print mixto
genera aleatorios y su frecuencia
#!/usr/bin/python
#genera digitos aleatorios y cuenta cuantos hay de cada
import random
n=int(raw_input('introduce numero mayor->'))
t=int(raw_input('introduce numero tiradas->'))
A=[] #matriz dde digitos 0 a 9
for iu in range(n+1):
A.append(0)
for i in range(t): #numero tiradas
a=int( random.randrange(n+1))
for index, item in enumerate(A, start=0): #si coincide digito con indice matriz
if index==a:
A[index]+=1
else:
continue