Cerca qui le cose strambe

2025-04-24

grep di stdin tenendo l'header

 

A volte puo` essere utile un grep di stdin tenendo l'header

Si definisce in bash (nel .bashrc o simile) una funzione cortissima tipo cosi` =>


hgrep () { read line; echo "$line"; grep $* ; }


ci sono rari casi in cui puo` essere  leggermente pericolosa, ma nel complesso pare accettabile


esempio d'uso:



# lsof   | hgrep  tripwire
COMMAND       PID     TID TASKCMD              USER   FD      TYPE             DEVICE    SIZE/OFF       NODE NAME
tripwire  2285668                              root  cwd       DIR              253,0       36864     524292 /root
tripwire  2285668                              root  rtd       DIR              253,0        4096          2 /
tripwire  2285668                              root  txt       REG              253,0     3140528        594 /usr/sbin/tripwire
tripwire  2285668                              root    4u      REG              253,3    51822592         36 /tmp/twtempUYqaRJ (deleted)
#
# ps aux | hgrep /usr/sbin/tripwire
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root     2285668 96.1  1.4 484084 467676 ?       R    14:45  16:33 /usr/sbin/tripwire
#  



2025-04-09

preventing rdp session from being locked with pyautogui

 
I have to work on 2 simultaneous rdp connections on two screens 
and every 5/10 minutes or so one of them got locked (you know: security policies...)

so I ended up with this workaround: a simple infinite-loop python script that 
I can launch in a local cmd shell: 
every minute it simulates a click and an Esc key in both rdp window (and this, in my specific case, cannot cause any harm, but beware: YMMV)


import pyautogui, random, sys  
from tkinter import Tk  
from time import sleep
  
pyautogui.PAUSE = 0.01  
num_times = 0  
while True:  
    num_times += 1  
    print("loop number %d" %  num_times)  
sleep(1) print(".") sleep(1) print(".")
z1, z2 = pyautogui.position() pyautogui.moveTo(-700, 300, duration=0.1) pyautogui.click() sleep((0.4 + random.random()) / 4) pyautogui.hotkey("esc") pyautogui.moveTo(z1, z2, duration=0.1) pyautogui.click() sss = 48.4 + 6.01 * random.random() print("sleeping for %d s " % int(sss)) sleep(sss) print("this statement just marks the script end, but it won't be ever executed")




mp3 not accepted by audacity

 in case you are trying to import an mp3 file with Audacity and it fails with error "incorrect filetype"




you can check it with the file command line tool in cywin/Linux/etc

$ file ./somefile.mp3

./somefile.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer III, v1, 128 kbps, 44.1 kHz, JntStereo

$

after some googling it turned out that a simple fix is using mp3validate 

https://mp3val.sourceforge.net/

(binaries available for windows/linux/etc)

for Debian/Ubuntu you should be able to use a plain

sudo apt install mp3val in case you do want to proceed with fixing the file without creating  a backup you can simply launch this command: mp3val somefile.mp3 -f -nb and then boom - Audacity will be happy in importing it.