php: xpath -etan zelan erabili adierazpen erregularrak (regex)

Zelan erabili adierazpen erregularrak (regex) php-n, adibidez:

“div” tag-a “class” atributo barruen “ui-sortable” balidxue dakona:

XML sarrera ($content aldagaidxen edukidxe):


567662

destacado

destacado: Home Actualidad ES

eta hau gudu lortu:



	

567662

destacado

destacado: Home Actualidad ES

beraz kendu biher diez:

  • class=”empty” dakoien “div”-ek
  • class=”close” dakoien “div”-ek
  • style atributue dakoien “div”-ek
  • “ui-sortable” balidxue dakoien “div”-ek “class” atributuen barruen:

PHP kodie:

$content = "".$_POST['content']."";
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->loadXML($content);
$dom->encoding = 'utf-8';

$xpath = new DOMXPath($dom);
$xpath->registerNamespace('php', 'http://php.net/xpath');
$xpath->registerPhpFunctions('preg_match');


$element_remove = $xpath->query('//div[@class="empty" or @class="close"]');
foreach($element_remove as $er)
	$er->parentNode->removeChild($er);

$element_remove = $xpath->query('//div[@style != ""]');				
foreach($element_remove as $er)
	$er->removeAttribute('style');
	
$element_remove = $xpath->query("//div[php:functionString('preg_match', '/\ ui-sortable/', @class)> 0]");
foreach($element_remove as $er)
{
	$attribute = $er->getAttribute('class');
	$attribute = preg_replace('/\ ui-sortable/', '', $attribute);
	$er->removeAttribute('class'); 
	$er->setAttribute('class', $attribute);	
}																											
print_r($dom->saveXML());

debian: KDE-n saguen temie GTK-ko aplikaziñueri imiñi

Ba hauri, KDE-n GTK aplikaziñuek kargata saguen “defektuzko” temie kargaten da, orduen in bi’dune da, geuk gudun temie “defektozkue” egin, guzan ba:

Adibidez oxy-white gu’du erabili:

su
cd /usr/share/icons
mv oxy-black oxy-black.bak
ln -s oxy-white oxy-black

ba oin barriro gure’du kanbidxe, eta gudu oxy-red:

su
cd /usr/share/icons
rm -rf oxy-black
ln -s oxy-red oxy-black

archlinux: yaourt -ek ez dau topaten libyajl.so.1

yaourt -Ss sl
error while loading shared libraries: libyajl.so.1: cannot open shared object file: No such file or directory

Benetan askotan pasaten dastez honelako gauzek eta beti konponduten diez bardin, edo aktualizeten edo “enlace simboliko” bat eindxe:

su
find / | grep libyajl.so$

erantzune:

/usr/lib/libyajl.so

beraz:

ln -s /usr/lib/libyajl.so /usr/lib/libyajl.so.1
exit

eta usuaidxo normal moduen:

yaourt -Ss sl

Konpondute :)

random wallpaper bash script

Hau script-e okurridu dast “wallpaper”-a aldatuteko sartzien zaran bakotzan

#! /bin/bash
FOLDER="${HOME}/wallpaper"
COMMAND=`ls -1 ${FOLDER}`
i=0
for C in ${COMMAND}
do
        let "i += 1"
        array[$i]=$C
done
R=0

while [ $R -gt $i ] || [ $R -lt 1 ]
do
        R=$RANDOM
done

# fluxbox
fbsetbg -f ${FOLDER}/${array[R]}

# gnome
#gconftool-2 --set --type=string /desktop/gnome/background/picture_filename {FOLDER}/${array[R]}
exit 0

fluxbox eta gnomentzako eindxe :)