oriolrius.cat

Des del 2000 compartiendo sobre…

Year: 2004

Extensions de Firefox que uso

Reading time: 3 – 5 minutes

firefox.png

Per win ja fa temps que uso Firefox i totes les versions que han anat sortint fins a la versió 1, que tan soroll va fer fa uns dies. Però al linux fins avui usava el Mozilla, així que finalment m’he decidit a instal·lar la versió 1.0 de Firefox i disfrutar de les seves millores sobretot a nivell de velocitat. També he notat que usa una serie de fonts que no són iguals que les que em sortien en Mozilla, molt més boniques, és clar. Bé doncs com no li he posat algunes extensions que em són molt útils:

  • Linky permet administrar enllaços existens dis d’una pàgina, encara que no estiguin marcats com a tal en el codi HTML. La utilitat més interessant que li trobo és permetre verificar que tots els enllaços inclosos en un post publicat al weblog són vàlids. Per això només cal seleccionar l’entrada, primer el botó dret del ratolí­ i seleccionar l’opció Linky -> Open Selected Links in Tabs. D’aquesta forma tots els enllaços que tenim dins el text seleccionat es previsualitzen i, si volem, s’obren en pestanyes separades la qual cosa ens permet verificar que realment funcionen d’una forma encara més comode.
  • BUGMENOT ens dona un usuari i un pass en milers de pàgines que ho requereixen, sobre tot les més famoses. Tot i que jo dec ser gafe perquè al NYT no m’ha funcionat mai.
  • MozEx podem editar una ‘textarea’ amb l’editor que volguem. Aquesta extensió la vaig coneixer a partir del forum del Blog:CMS, concretament en aquest article, on es parla del mozex de mozilla.
  • Web Developer es tracta d’una barra de botons, que no tinc sempre carregada, però que és molt útil quan alguna de les webs personals que mantinc dona algún que altre problema de codi, és realment útils si toqueu webs a nivell de codi, o su uns ‘fisgons’.
  • AdBlock simplement una extensió que intenta bloquejar-nos tots els anuncis que porten les webs d’avui en dia, un ‘incordio’ realment. No va malament del tot.
  • Bloglines Toolkit permet sindicar-se als RSS a través de bloglines mentre estas navegant.
  • SiteBar aquesta extensió em permet usar el SiteBar a la sidebar del Firefox. Si no coneixeu el SiteBar, jo el trobo molt més útil que el del.icio.us. Fa temps vaig escriure sobre el SiteBar: SiteBar: Servidor de Bookmarks/Favoritos

Si busqueu alguna extensió més ‘rara’ que jo no uso, podeu passar-vos per la part d’extensions de la web de mozilla, concretament al producte firefox. Per altra banda també he trobat una pàgina amb una recopilació de les extensions que esta molt bé: Extensions Room de mozdev.org. Si algú vol desenvolupar extensions per Firefox he trobat una guia ràpida.

Una cosa que no sé fer amb el firefox i que m’agradaria saber fer, per si algú ho sap, és aconseguir que es guardin les pàgines de tots els tabs quan tanqui el navegador de forma que quan el torni a obrir es tornin a carregar automàticament.

Linux Tips: Modules, Who Are They, And How Do They Work?

Reading time: 2 – 3 minutes

[ Via Migraine Heartache ] A very nice feature of the Linux kernel is the modules. Modules are pieces of software that can be loaded and unloaded from the kernel at runtime. That way you can save kernel memory (and that’s important for small machines, since kernel memory is never swapped out on disk), and keep your kernel clean when you’re not working with some of your hardware.

Especially sound and network cards are really good to compile as modules, since sometimes they are a bit hard to configure, and when you have a module, you don’t have to recompile and reboot your kernel to configure some irq or io setting.

The Tools Used

The tools you use to handle modules are all located in /sbin. They are insmod, modprobe, lsmod, depmod and rmmod.. Notice the names, and compare them to some often used unix commands such as ls and rm and you’ll immediatelly understand what each command will do for you. As always I recommend reading the manual pages. Anyway, here’s what they do:

  • lsmod – List the modules currently loaded. A completely harmless command, even a normal user can run it.
  • rmmod – Removes a loaded module from memory. Checks dependencies, ie if a module needs another module, the other module may not be unloaded before the first one.
  • insmod – Inserts a specific module in memory. You may give a path, or just a filename with or without extension. In the latter case, insmod will search some standard module paths to find the module.
  • modprobe – Inserts a module in memory, but checks dependencies. If you modprobe module A, and module A needs module B to run, modprobe will insert module B and then module A.
  • depmod – Calculates dependencies between modules needed by the other module commands. This is most probably done by your init scripts at system startup, but some time you may need to execute a depmod -a.
  • modinfo – ens dona informació sobre les funcions del mòdul, els paràemtres que suporta, etc.(se l’havien deixat)

How do I make modules?

When you compile your kernel, you choose to make things as modules, instead of into the kernel itself.

The modules will be installed when you do a make modules ; make modules_install after your kernel is compiled. They will reside in a directory called /lib/modules/xx.yy.zz where xx.yy.zz is your kernel version.

Diferència entre un .gif transparent i un .png

Reading time: 1 – 2 minutes

Doncs jo de gràfics ni idea i menys als nivells que tocant alguns… per això tinc als amics que han fet Eng.Multimèdia, doncs d’això va l’email el Law m’ha enviat un email amb una mini-explicació de la diferència entre un .gif i .png transaparent que amb el seu permís us penjo aquí.

Lo dels png’s és facil. resulta que un gif té un canal de transparència, pero diguessim que es rollo binari, o hi ha color (amb el seu codi) o no. PNG va més enllà, pot haver color i amb una opacitat, de manera que tu pots definir uns bordes més suaus gràcies a que té una opacitat escalada i no en plan “si, no”.

El tema esta que llavors tu pots posar un damunt de qualsevol fons, pero ha de tenir un borde perquè sinó esta acorde amb el fons es veu com el cul, amb png al tenir un percentatge dopacitat queda super fi i queda bé.

Groovy: simplificant Java

Reading time: 1 – 2 minutes

groovy.png

Groovy és un llenguatge que usa les APIs de Java però que simplifica la programació al màxim. Sembla que no esta malament algún dia li podria donar un cop d’ull. També he trobat un article d’IBM que en fa una petita introducció, sembla molt senzill realment.

A O’Reilly Network es va publicar no fa massa un codi fet en Groovy que servia per crear un lector de feeds (tipus liferea) que treballava contra les APIs de bloglines. Això et pot interessar pof. L’article: A Complete Bloglines API Application ( versió imprimible )

Si algú l’ha provat o l’arriva a provar que avisi que tinc curiositat de saber fins on arriba la implementació de la API o del paquet de classes de java millor dit.

Treballant amb cookies de sessió i PHP

Reading time: 1 – 2 minutes

A vegades necessitem parlar amb una web des de PHP i aquesta usa cookies de sessió sense les quals no podem parlar amb la web. Per agafar la cookie d’inici de sessió podem usar aquesta funció:

function getgaleta($server, $port)
{
   $cont = "";
   $ip = gethostbyname($server);
   $fp = fsockopen($ip, $port);
   if (!$fp)
   {
       return "Unknown";
   }
   else
   {
       $com = "GET http://www.barcelonastyle.com/gc/web/webesp/framesetxsl.asp HTTP/1.0rnrn";
       fputs($fp, $com);
       while (!feof($fp))
       {
           $cont .= fread($fp, 500);
       }
       fclose($fp);
       return substr($cont, strpos($cont, "Set-Cookie: ")+12, 45);
   }
}

Si ara que ja tenim la cookie el que volem fer és usar-la per fer peticions contra el site, podem usar aquesta altre funció:

function getcontent($server, $port, $file,$galeta)
{
   $cont = "";
   $ip = gethostbyname($server);
   $fp = fsockopen($ip, $port);
   if (!$fp)
   {
       return "Unknown";
   }
   else
   {
       $com = "GET http://".$server.$file." HTTP/1.0rnCookie:".$galeta."rnrn";
       fputs($fp, $com);
       while (!feof($fp))
       {
           $cont .= fread($fp, 500);
       }
       fclose($fp);
       return $cont;
   }
}

Tonto però útil, tinc moltíssimes més funcions però tampoc és qüestió de marejar, només que les he trobat útils aquestes junt amb les dues anteriors.

Un parell de funcions que us poden ser útils

Reading time: 2 – 3 minutes

Porto uns quants dies que crec que estic deixant de ser humà m’acaba de trucar la Daphne i semblava un mussol. No era capaç de lligar una frase amb cara i ulls. Què té a veure això amb el codi que posa més avall? doncs que estic programant una especie de webspider o robot o diga-li com vulguis per un tema de Downcenter, per tal de nutrir d’informació la BBDD del proper software que surt l’1 de desembre.

Com que no puc explicar més detalls del que estic programant em limitaré a enganxar un parell de funcions que poden ser útils a més d’un que estigui programant en PHP. Segur que sabeu que quan accediu a un formulari HTML i aquest llença una petició la URL que s’envia, com es pot comprobar a la barra de direccions del navegador, agafa una forma rara. O sigui, els espais passen a ser símbols “+” i els caràcters ASCII extesos, per sobre el codi 127, es codifiquen en codis hexadecimals.

Doncs bé aquestes funcions el que fan és precisament això, els passes una cadena, per exemple, una URL en forma de 8 bits normal i corrent i te la converteix en el format que comentava anteriorment. L’altre funció el que fa és alrevés, passa de format codificat a normal. Espero que us sigui tan útil com ho ha estat per mi.

function cadenaNormal2Hex ($cadena) {
	// Canviem simbols Hex del mig de la cadena
	$llarg = strlen($cadena);
	for ($i=0;$i<$llarg;$i++) {
		$numascii=ord($cadena[$i]);
		if ( $numascii>127 ) {  // És text pla (???)
			$car=strtoupper(dechex(ord($cadena[$i])));
			$cadena = substr_replace ($cadena,"%".$car,$i,1);
		}//if
	}//for
	// Canvia el + per l'espai
	while ($pos = strpos($cadena," ")) {
		$cadena = substr_replace ( $cadena, "+", $pos,1);
	} //while
	return $cadena;
} // function
function cadenaHex2Normal ($cadena) {
	// Canvia el + per l'espai
	while ($pos = strpos($cadena,"+")) {
		$cadena = substr_replace ( $cadena, " ", $pos,1);
	} //while
	// Canviem simbols Hex del mig de la cadena
	while ( $pos = strpos($cadena,"%") ) {
		$codi=substr($cadena,$pos+1,2);
		$car=chr(hexdec($codi));
		$cadena = substr_replace ($cadena,$car,$pos,3);
	}//while
	return $cadena;
} // function

XML & DocBook: Structured Technical Documentation Authoring

Reading time: 2 – 3 minutes

docbook.jpg

XML is short for Extended Markup Language and is a subset of SGML, the Standard Generalized Markup Language. XML is an HTML-like formatting language. Whereas most HTML-related formats developed in the past adopted the “be conservative in what you send and liberal in what you receive” attitude, XML takes the opposite approach–documents should be 100% compatible. This compatibility is known as “well-formedness” of an XML document. To this end, even when the goal is clear, a document is rejected if it does not follow XML specifications to the fullest extent. In terms of practicality, this approach guarantees interoperability in the long run. Unlike HTML, which is the standard groupname for a lot of sub-protocols that are slightly different and not fully interoperable with one another, the strictness of XML ensures compatibility. XML also improves security dramatically, because there is only one way to interpret expressions, a way on which everybody agrees.

DocBook is an XML Document Type Definition or DTD. It is a subset of XML particularly suited for but not limited to the creation of books and papers about computer hardware and software. DocBook is well-known in the Linux community and is used by many publishing companies and open-source development projects. Most tools are developed for the DocBook DTD and are included in most Linux distributions. This allows for sending raw data that can be processed at the receiver’s end–wherever applications able to interpret XML directly are available.

The important thing to keep in mind is XML and DocBook let authors focus on content. In that sense, the presence of the word “markup” in the definition of XML is misleading. With XML, authors specify what type of data they are including, such as text explanations, command names, tables or images. How the content is formatted, laid out and displayed should not be their concern. From a single source, the receiver might generate PDF, PS, plain text, HTML and many other representations of the content.

Another advantage is DocBook XML files are written in plain text. Although many editors are available, such as oXygen and XMLmind, advanced DocBook users easily can write the source texts using vim, Emacs or any other text editor.

Publicat al Linux Journal: XML & DocBook: Structured Technical Documentation Authoring

Understanding and Attacking DNS

Reading time: 2 – 2 minutes

dns.gif

The Domain Name System (DNS) is a distributed resource used by most every network application. DNS data is generally trusted implicitly; false data therefore can jeopardize the integrity of network traffic and allow attackers to play manin- the-middle with all traffic. DNS security depends on the client, server, and their respective trust relationship. Securing the trust relationship and building a reliable server can create a reliable and secure DNS structure for the system administrator behind your corporate and private communication requirements. Security of a DNS server varies according to its active role and name resolution requirements. Server responsibilities can be classified as one of three types. Depending on the need of the server, one specific role should be chosen; in particular situations, multiple roles can be supported simultaneously on one physical server. In this shared configuration, authoritative and resolver servers are generally together. Running an individual server for each DNS role is ideal, specifically in a large production environment. After understanding the individual roles and mechanics between each server and experiencing problems individually, an administrator can securely and reliably maintain multiple DNS roles on a single system. DNS security is custom for each type of server, each type of communication, and each common software distribution, all of which will be explained in this article via an in-depth walkthrough.

OpenSSH for Windows

Reading time: < 1 minute

OpenSSH for Windows is a free package that installs a minimal
OpenSSH server and client utilities in the Cygwin package without
needing the full Cygwin installation. This is similar to the package
formerly available from NetworkSimplicity.

The OpenSSH for Windows package provides full SSH/SCP/SFTP support.
SSH terminal support provides a familiar Windows Command prompt, while
retaining Unix/Cygwin-style paths for SCP and SFTP.