désaccentuation

désaccentuation

J’oubliais, ce petit script pour “désaccentuer” du texte : utiliser entity_decode,
puisque é s’écrit &+e+acute; on peut récupérer le ‘e’ après le & :
function f_desaccentuation($v_str)

{
//htmlentities pour les accents !: référence devient reference
$str=f_str2utf8($v_str);
$str=f_str2iso(html_entity_decode($str,ENT_NOQUOTES,”UTF-8″));
$str=preg_replace(“/[\xa0-\xbf\xd7\xf7]/”,” “,$str);
$str=htmlentities(f_str2utf8($str),ENT_NOQUOTES,”UTF-8″);
$str=str_replace(” “,” “,$str);
$str=str_replace(“<“,”<“,$str);
$str=str_replace(“>”,”>”,$str);
$str=str_replace(“&”,”&”,$str);
$str=str_replace(“””,'”‘,$str);
$str=str_replace(“‘”,”‘”,$str);
return(preg_replace(“/\&(.)[^\;]*\;/”,”$1″,$str));
}

pas de table de conversion 🙂
Pocket

stty: standard input: Inappropriate ioctl for device

stty: standard input: Inappropriate ioctl for device

“stty: standard input: Inappropriate ioctl for device”
est un message systeme sur les redhat 6,
du (dans mon cas) à des combinaisons de su et &
j’ai réduit le test au minimum :

echo “su  root -c ‘ls &’ ”  >  /tmp/a ; sh /tmp/a

modif : dans /etc/sudoers,
changer
Defaults    requiretty

par
Defaults    !requiretty
(ou par utilisateur..)
Pocket

half-em and dash in Word : why copy paste command line from MS-WORD with dashes fail

half-em and dash in Word : why copy paste command line from MS-WORD with dashes fail

Word evolves , it replaces dash  by typographic characters the picky way. so dashes.
I was copy pasting from word and bang! :
# keytool -list –v -keystore tomcat.jks
Unrecognized command: –v
it is hidden to non hexadecimal reader
[root@h0l1ice11t conf]# echo "keytool -list –v ..."|od -cx
0000000 k e y t o o l   - l i s t   342 200 
      656b 7479 6f6f 206c 6c2d 7369 2074 80e2
0000020 223 v  
      7693 
fiiiix it …..
* in word, deactivate any automatism
menu file / option / verification / option auto-correction ….
uncheck outrageously
* and now replace – by – [sic]there is an option to type “half-em-dash”
the option : “Plus>>” “special” “half-em-dash”
conclusion : use MD (markdown), not MS
Pocket

poor man’s dyndns

poor man’s dyndns

As many, I committed a low cost dyndns ;

hourly, I call a server’s url. if the server notices a change, it updates a DNS zone :
root@clic12:/etc/cron.hourly# cat wgk
#!/bin/sh
IP=`ifconfig -a|grep 192|head -n 1|sed -e 's/  */|/g'|cut -d\| -f3`
URL="http://www.yoursite.net/zone.php"
wget -o /dev/null -O /dev/null "$URL" 2>&1 >/dev/null
wget -o /dev/null -O /dev/null "$URL?n=guy&ip=$IP" 2>&1 >/dev/null
and the php side (can manage many dyndnses):
//print_r($_SERVER);
 
$n=preg_replace("/[^a-z]/","",$_REQUEST["n"]);
if ($n)
 foreach(explode("\n",file_get_contents("zone.txt")) as $l)
   if (preg_match("/ $n /",$l)) $m=preg_replace("/^.* $n /","",$l);
if ($_REQUEST["a"]) die(file_get_contents("zone.txt"));
if ($_REQUEST["d"])
        die("ok".file_put_contents("zone.txt",strftime("%D %T reset
\n")));
if (!$n) die("list,reset");
$q=strftime("%D %T $n ".$_REQUEST["ip"]." ".$_SERVER["REMOTE_ADDR"]."
");
file_put_contents("zone.txt",$q."\n",FILE_APPEND);
$q=preg_replace("/^.* $n /","",$q);
if ($q == $m) die("ok same ip");
file_put_contents("zone.txt","***********NEWIP*******\n".$q."\n",FILE_APPEND);
if ($n=="guy")
        passthru("sudo /root/scripts/named_dyndns.sh yoursite.net adsl ".$_SERVER["REMOTE_ADDR"]);
?>.
and named_dyndns.sh + domain + subdomain + ip
#!/bin/sh
domain=$1
key=$2
ip=$3
if [ "$ip" = "" ];then echo "$0 domain key ip";exit;fi
dmx=/var/named/chroot//etc/named.xtra
sed -i $dmx -e "s/^$domain:$key IN A .*$/$domain:$key IN A $ip/"
/root/bin/named_make_domxtra2zon.pl $domain
after, this is your own domain/named/zone system,
that recreates a zonefile and reload named
Pocket