Category: Code

Old code: CSS rules on the fly from JavaScript (2006)

Again, some old code I'm not using anymore since I switched to jQuery but that might be useful for someone: /* * Public Domain * Created by Toni Corvera <outlyer@outlyer.net> in September, 2006 * * Creates a new CSS ruleset, should work with multiple rules correctly * e.g.: * loadCssRules('body{font-family:sans-serif;}a:link{color:red;}'); */ // void function loadCssRules(String […]

Read More

Old code: DOM extensions (2004-2006)

Nowadays I'm using something more powerful like jQuery or base2.DOM, but if you don't, these might prove useful. /* * Copyright 2004-2006 Toni Corvera <outlyer@outlyer.net> * * License: http://www.gnu.org/copyleft/lgpl.html LGPL * * Extra DOM-like methods (Note that at the time of writing they can't be * bound to the Document prototype, so they are global […]

Read More

Old code: JavaScript x-browser arrays (2005, 2010)

Last update: 2010-12-09 This block of code is deprecated, I'm only keeping it for archival purposes, see below for a more up-to-date equivalent /* * Public Domain * * Created by Toni Corvera <outlyer@outlyer.net>, 2005 * * Defines Array.find, and Array.merge */ // int Array.find(Object) if (!Array.indexOf) {/*IE has no indexOf*/ Array.prototype.find = function(what) { […]

Read More

Script: man2ps, man2pdf, man2evince

Usage: $ man2ps command will generate a PostScript (.ps) file from command's manpage Symlink or copy this script as "man2pdf" to create a PDF from a manpage. Symlink or copy this script as "man2evince" to call evince on a temporary PDF of the manpage #!/bin/bash # man2ps, (c) 2004,2005,2006,2009 Toni Corvera, published under a BSD […]

Read More

Script: video identification (Bash)

This script displays mplayer's information/identification lines of a multimedia file. Nowadays I prefer to use an undocumented feature of vcs (see below) #!/bin/bash # This script displays mplayer's information/identification lines of a multimedia file # Put in the public domain. <http://w.corvera.eu/2007/11/shell-vidid/> vididf() { mplayer -identify -frames 0 -ao null -vo null "$1" 2>/dev/null | grep […]

Read More

Valor de retorno en el prompt

Este código sirve para indicar si el último comando ha tenido éxito o no, de manera que siempre esté visible en el propio prompt, es ideal para depurar código entre otras cosas. Versión rápida (aunque no muy legible :P): export PS1='$( [ "$?" -eq 0 ] && M=")" || M="("; echo -n :$M ) '$PS1 […]

Read More

Instalación de la máquina virtual Java de Sun en Debian

La información de esta página no es necesaria en sistemas actuales, basta con instalar los paquetes sun-java-*. Debian incluye varias máquinas virtuales Java que funcionan bastante bien pero puede interesar usar la de Sun, por ejemplo en estudios de informática en que se de por hecho que se va a usar esa máquina.Éste es el […]

Read More

Conversión de páginas del manual a PostScript (o pdf)

La idea es crear un archivo PostScript (ps) o PDF con las páginas del manual de un comando, de modo que se puedan hacer impresiones de alta calidad o verlo en pantalla también en alta calidad. Se requiere Ghostscript para hacer la conversión. Substituye $COMANDO por el comando en cuestión. PostScript $ man -t $COMANDO […]

Read More