2018/09/19

Eclipse PDT preventing focus stealing during test running with PHPUnit

you are writting code and at some point you press Ctrl-F11 to run the default test configuration. Thing is: both Console and PHPUnit window will steal the focus from the source editor.
theres  a bug report marked as NEW while its 4 years old and some other fixes for Mac but I ended up with the easiest solution: to do not test under Eclipse and instead use an external console. The script I made in bash is as follows:

#!/bin/bash

clear
inotifywait -m --format %w%f -q -r -e close_write $1 $2 | \
while read CUAL
do
    if [ $? == 0 ]; then
        clear
        phpunit.phar --color  $1
   fi
done

first parameter is the location of the dir containing the tests, or the test Suite. Second parameter is the directory from where inotifywait should watch for changes on filesystem.
  


2018/08/29

PHP to UML

I wanted a tool to convert PHP classes to UML, but I also wanted to be able to modify the result.

As a (maybe positive) side effect I had to separate all PHP classes in a particular directory in order to avoid the tool to get confused with other scripts used to generate Javascript code among other things.


(this post may require some revisions)

grab php2xmi from

http://tech.motion-twin.com/php_php2xmi.html

sample script to run on project directory:


php2xmi \
--no-private \
--no-protected \
--output=/home/rudy/borrame/myresult.xmi \
`find src/class -name "*.php"`

add --path= if you need to include other project files

once you get the XMI file, you can import it with ArgoUML

http://argouml-downloads.tigris.org/argouml-0.34/

it wont generate the UML on the fly


2018/08/05

Stylish for TW (updated)

When I do things like this I want to separate updated content from what is not.

This template removes pinned tweets among other things like the Moments, prompts, translate buttons and recommended followers.


@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("twitter.com") {
#above-timeline-prompt,
.user-pinned,
.SidebarCommonModules,
.moments,
.message,
.translate-button, .GalleryNav,
.js-recommended-followers
{ display:none !important }

}


2018/08/02

network bonding on slackware 14.2

perhaps a first sloppy attempt I made to make bonding work in 14.2, based on this info

https://docs.slackware.com/howtos:misc:network_interace_bonding

inside /etc/rc.d/rc.M add (before rc.local section):

if [ -x /etc/rc.d/rc.bond ]; then
  . /etc/rc.d/rc.bond
fi



/etc/rc.d/rc.bond :
modprobe bonding

ip addr add 192.168.111.3/24 dev bond0
ip link set bond0 up


ip link set eth0 master bond0
ip link set eth1 master bond0

ifconfig eth0 up
ifconfig eth1 up

ip route add default via 192.168.111.13 dev bond0
chmod +x rc.bond and reboot

2018/07/23

bash script to kill another script by pid file

the idea is to get the pid from a running script and save it to a file, so we can retrieve the id and kill the process. Also it should kill child processes

to create the file, during the script we must do (replace /home/mantener/var/run with another dir of your liking):

minombre=$(basename $0)
pidfile=/home/mantener/var/run/$minombre.pid
echo $$ >$pidfile

 
 and the script to make use of the pid file could be:

#!/bin/bash
pidfile=/home/mantener/var/run/$1.pid

if [ ! -f $pidfile ] ; then
   echo missing $pidfile !
   logger $0 missing $pidfile !
   exit -1
fi

cualpid=$(cat $pidfile)

# get child processes
resto=$(ps --ppid $cualpid -o pid --no-headers)

echo killing $1
kill -9 $cualpid

while IFS= read -r line ; do
    echo killing $line
    kill -9 $line
done <<< "$resto"

rm $pidfile

2018/07/19

script to kill a specific process by name

This one was made specifically for VLC since the stupid program sometimes hangs and there is no way to close it by normal means (Quit command, etc)

#!/bin/bash
$(echo -n kill -9 ; ps -A |grep vlc |grep -o "^ [0-9]*")
what it does is to create a command line on the fly by extracting vlc process id and then execute it.

2018/07/09

Autofill forms for Chromium and Firefox

Why/when do you need it:
  • because you use the same web page from time to time and you need to fill a form with the same data (ie: user/pass)
  • related to the above, once configured with a hotkey, logging in a site in is just a second
  • security is not an issue
  • a natural complement to Lazarus addon for Firefox
  • if you are like me, who sticks to Firefox 40-48 because many addons does not work on newer versions, you might want to use Chromium for specific web pages
Firefox version:

https://firefox.add0n.com/autofill-forms.html

for Chromium

https://add0n.com/autofillforms-e10s.html

compared with the Addon for Firefox (version 1.1.8), Chromium addon is horrible beyond belief. I feel like some software developers are treating users as if they were morons incapable of thinking for themselves so they try to spoon-feed them with fancy dialogs and buttons limiting what they can and cannot do. Proof of that is the first item on the Features list: "Easy configuration with a simple interface"

2018/06/16

stylish for stackexchange

removes annoying cookies usage notice (which I have them blocked with CookieMonster anyway):

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("stackexchange.com") {
#js-gdpr-consent-banner
  { display: none !important; }
}

2018/06/12

ffmpeg: converting m4a to mp3 script

to be able to do this, ffmpeg must be compiled with mp3 support.


#!/bin/bash
mkdir mp3
for file in *.m4a
   do ffmpeg -i "${file}" -vn -ar 44100 -ac 2 -ab 128k -f mp3 mp3/"${file/%m4a/mp3}"
done

2018/06/06

"unable to un/install on windows" error

a quick list of things to check:
MSIEXEC /UNREGISTER
MSIEXEC /REGSERVER

or

HKEY_LOCAL_MACHINE \Software\Microsoft\Windows\CurrentVersion\Installer\InProgress   

or

HKEY_LOCAL_MACHINE \System\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations


HKEY_LOCAL_MACHINE \Software\Microsoft\Windows\CurrentVersion\Installer

2018/06/05

zeroing a disk on linux using DD

WARNING: if you don't really understand what are you doing (even if you THINK you are), then start learning/reading first or asking someone who really understands linux BEFORE doing something stupid like erasing a wrong disk by mistake.

if you need to wipe the content of a hard disk (REPLACE /dev/sda with the appropiate device !):

dd if=/dev/zero of=/dev/sda bs=1M 

last parameter (block size) makes the process a lot faster

2018/05/26

inotifywait example

edit: modified parameter "-n 1" to the "head" command

for this example I'm assuming text files:
to avoid confusions long lines are splitted with \


#!/bin/bash

if [ $# -ne 2 ]
    then
    echo "$0 <src dir> <dst dir>"
    exit
fi

clear

inotifywait $1 -qmre CLOSE_WRITE \
--format='%f' | while read WHICHONE ; do  

   if [ $? != 0 ]; then exit; fi;
   LINESELECTED=$(head -n 1 $WHICHONE | \
grep CONDITION)

if[ $LINESELECTED -eq 1 ] then
   cp $1/$WHICHONE $2
fi


done

2018/05/17

bash scripts for directories based on date

#!/bin/bash

#Path YYYYMMDD
ANO=$(date +%Y)
MES=$(date +%m)
DIA=$(date +%d)
FULL=$ANO$MES$DIA

if [ "$FULL" == "" ]; then
    exit 1
fi

#generar directorio destino
DIRDESTINO=/picadora/eimpresa/fotos/$ANO$MES$DIA
mkdir -p $DIRDESTINO
chmod 777 $DIRDESTINO

mkdir -p $DIRDESTINO/tapa
chmod 777 $DIRDESTINO/tapa

# generar link simbolico a HOY
cd /picadora/eimpresa/fotos
rm hoy
ln -s $DIRDESTINO hoy
cd $DIRDESTINO

# lo que siga despues

2018/05/04

phpunit script

assuming theres a test directory inside a project where the source files are held:

#!/bin/bash

if [ $# -ne 2 ]
    then
    echo "testphp <test dir> <src dir>"
    echo "example: $ testphp test ."
    exit
fi

clear

inotifywait $2 -qmre CLOSE_WRITE --format='%f' | while read CUAL ; do  
   if [ $? != 0 ]; then exit; fi;
   clear
   phpunit.phar --log-junit /tmp/ultimo.txt --color -v $1
done

2018/04/29

geany plugins for 1.33

assuming:
  • have geany 1.33 installed
  • you want to use geany pluings for the same version
  • you have downloaded and unpacked source distribution 
  • you get an error while running ./configure under slackware64 14.2 similar linux flavor
if configure complains no "geany.pc", to solve this:


find /usr |grep "geany.pc"

take note where the "geany.pc" is located and append to PKG_CONFIG_PATH

ie if the file is located under /usr/local/lib/pkgconfig

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

then you can run ./configure again without errors

2018/04/24

new install to-do list

this post is a work in progress:

after installing slackware, things to do besides the normal setup like configuring network card:

copy ssh keys from old install
copy /etc/sshd config?
copy .bashrc from old home install or the entire home directory
user groups review? (seems like its no longer needed under Slackware 14.2)
xorgsetup ? only if needed
compat32
libreoffice ?
wine?
firefox 40 (yes I stick to this version until Firefox can fix newer versions problems).


kde: fix nasty konsole prompt, edit Shell: /bin/bash -l


Installing PHP 7 from source

this post assumes you are familiar with Slackware 14.2 and have php 5.6 installed

  1. Donwload php from sources, and extract it
  2. inside the sources, create a script with this code or copy/paste on bash:
    #!/bin/bash
    ./configure \
        --with-config-file-path=/etc \
        --with-config-file-scan-dir=/etc \
        --enable-mbstring \
        --enable-zip \
        --enable-bcmath \
        --enable-pcntl \
        --enable-ftp \
        --enable-exif \
        --enable-calendar \
        --enable-sysvmsg \
        --enable-sysvsem \
        --enable-sysvshm \
        --enable-wddx \
        --enable-intl \
        --with-curl \
        --with-iconv \
        --with-gmp \
        --with-pspell \
        --with-gd \
        --with-jpeg-dir=/usr \
        --with-png-dir=/usr \
        --with-zlib-dir=/usr \
        --with-xpm-dir=/usr \
        --with-freetype-dir=/usr \
        --enable-gd-jis-conv \
        --with-openssl \
        --with-pdo-mysql=/usr \
        --with-gettext=/usr \
        --with-zlib=/usr \
        --with-bz2 \
        --with-apxs2=/usr/bin/apxs \
        --with-mysqli=/usr/bin/mysql_config \
        --with-ldap \
      --with-libdir=lib64
    edit: the long line from above as one line:
    ./configure --with-config-file-path=/etc --with-config-file-scan-dir=/etc --enable-mbstring --enable-zip --enable-bcmath --enable-pcntl --enable-ftp --enable-exif --enable-calendar --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-intl --with-curl --with-iconv --with-gmp --with-pspell --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-freetype-dir=/usr --enable-gd-jis-conv --with-openssl --with-pdo-mysql=/usr --with-gettext=/usr --with-zlib=/usr --with-bz2 --with-apxs2=/usr/bin/apxs --with-mysqli=/usr/bin/mysql_config --with-ldap --with-libdir=lib64

  3. make
  4. make test
  5. su
  6. make install
  7. edit /etc/httpd/mod_php.ini and comment lib_php5.so line
  8. rc.httpd restart

2018/04/13

running ATEM Software Control under Slackware


while this blog has a foolproof method for ubuntu, I believe I took a shortcut and managed to make it work under wine32 because you don't really need to install it to make it work, just like old fashioned software. Besides: installing wine64 just to install ATEM and then install win32 to run it sound more like a hack than a "propper" solution.

In case you dont have it already installed wine:
http://www.slackware.com/~alien/slackbuilds/wine/

1) on a Win setup, make a copy/compressed file of ATEM Software control
2) copy/decompress it on a Slackware box

then cd to the "Blackmagic Design/Blackmagic ATEM Switchers" and do

$ regsvr32 BMDSwitcherAPI.dll 
because if you dont the software will complain for missing DLLs.

and then you can run it:
$ wine ATEM\ Software\ Control.exe

2018/03/29

2018/03/20

Stylish for TW

For this recipe to work, you will need installed Firefox version 40-48, and Stylish Addon for Firefox.

The following template allows you to right click on an image in order to view it on a new tab or to save it as file, it also removes Moments and Who to follow.

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("twitter.com") {
#above-timeline-prompt,
.moments,
.translate-button, .GalleryNav,
.js-recommended-followers
{ display:none !important }

}

Stylish for lanacion

 removes annoying header with alpha channel
@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("lanacion.com.ar") {
.anexo , #cabezal
{ display: none !important }

body header#cabezal.transparente + .storytelling::before
{ background: white; height: 0 !important }

}

2018/03/18

ffmpeg conversion from h265 to h264

some strange reason, lastest version of VLC doesn't work very well under Slackware. I got sick tired of it and decided to go back to 2.0.7. But a problem arise when I want to watch a video encoded with h265. So I ended up converting them to h264 using a simple command line.

#!/bin/bash

for file in *.mkv
        do ffmpeg  -n -i "${file}" -map 0 -c:a aac -c:s copy -c:v libx264 264/"${file}"
done



2018/01/22

Global Stylish for Firefox

Specially imporant when you have a dark theme as desktop in KDE and when Firefox or a web page does not handle all colors properly
@namespace url(http://www.w3.org/1999/xhtml);

input
{ background: white ; color: black !important }
select
{ background: white ; color: black !important }
Funny thing about this is: under Firefox 45 it changes default colors for address bar and search bar.