otf med xetex

$ cp foo.otf /usr/share/fonts/
$ fc-cache -fv
$ fc-list
$ kpsewhich foo.otf
$ otfinfo --features /usr/share/fonts/foo.otf
$ vim foo.tex

% foo.tex
\font\foo="Foo":+kern;+liga;+zero
\foo abcdefg 1234567890.
\bye

$ xetex foo.tex
$ edpfview foo.pdf

Posted in Uncategorized | Leave a comment

Svenska tecken med Perl modul URI::GoogleChart

#!/usr/bin/perl
use strict;
use warnings;

BEGIN {
    my $base_module_dir = ( getpwuid($>) )[7] . '/perl/';
    unshift @INC, map { $base_module_dir . $_ } @INC;
}

use CGI qw(:standard);
use URI::GoogleChart;
use encoding 'utf8';

print header;

print start_html(-title=>'Perl modul URI::GoogleChart');

my $u = URI::GoogleChart->new("pie-3d", 350, 100,
    data => [60, 40],
    label => ["Hålla mun", "och hacka!"],
) or die $!;

print "<img src=\"$u\">";

print end_html;

Posted in Uncategorized | Leave a comment

TTF fontar och svenska tecken i GD::Graph

#!/usr/bin/perl

# "module path"
BEGIN {
    my $base_module_dir = ( getpwuid($>) )[7] . '/perl/';
    unshift @INC, map { $base_module_dir . $_ } @INC;
}

use CGI qw/:standard/;
use GD::Graph;
use GD::Graph::bars;
use GD::Graph::colour;
use GD::Text;
use encoding 'utf8';

@data = (
  ["första", "andra", "tredje", "fjärde", "femte", "sjätte"],
  [1, 2, 5, 6, 3, 1.5],
  [sort {$a <=> $b} (1, 2, 5, 6, 3, 1.5)]
);

my $graph = GD::Graph::bars->new(600, 300);
$graph->set_legend("foo", "bar");

# Diverse egenskaper
$graph->set(
  x_label       => 'y-axeln',
  y_label       => 'x-axeln',
  title         => "Hålla mun och hacka!",
  y_max_value   => 8,
  y_tick_number => 8,
  y_label_skip  => 2,
  textclr       => GD::Graph::colour::black,
  labelclr      => GD::Graph::colour::black,
  axislabelclr  => GD::Graph::colour::black,
  fgclr         => GD::Graph::colour::black,
  legendclr     => GD::Graph::colour::black
) or die $graph->error;

# Datafärgen
$graph->set( dclrs => [ qw(lgray gray) ] );

# Fontar
GD::Text->font_path("/usr/share/fonts/bitstream-vera");
$graph->set_title_font( "Vera", 14 );
$graph->set_legend_font( "Vera", 10 );
$graph->set_x_axis_font( "Vera", 9 );
$graph->set_x_label_font( "Vera", 11 );
$graph->set_y_axis_font( "Vera", 9 );
$graph->set_y_label_font( "Vera", 11 );

# Format och utdata
my $format = $graph->export_format;
print header("image/$format");
binmode STDOUT;
print $graph->plot(\@data)->$format();

Posted in Uncategorized | Leave a comment

Prova cgi-utdata som ingångsdata för Lynx

$ foo.cgi "?bar=baz&pi=3.14159"| lynx -stdin

Posted in Uncategorized | Leave a comment

Bra och gratis tyska öppen-böcker

Wie Werde Ich Unix-Guru? Einführung in UNIX, Linux und Co. av Arnold Willemer
C von A bis Z: Das umfassende Handbuch av Jürgen Wolf

Posted in Uncategorized | Leave a comment

Förvandla toc.ncx till toc.html

$ xsltproc -o toc.html ncx2html.xsl toc.ncx
$ perl -Cio -pi -e 's/([^\x00-\x7f])/sprintf("&#%d;", ord($1))/ge;' toc.html

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- ncx2html: An (incomplete) XML stylesheet to transform NCX to HTML. -->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:ncx="http://www.daisy.org/z3986/2005/ncx/">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/ncx:ncx">
  <html>
    <body>
      <h1><xsl:value-of select="ncx:docTitle/ncx:text"/>: Contents</h1>
      <p>
        <xsl:if test="ncx:navMap/ncx:navPoint">
          <ul>
            <xsl:apply-templates select="ncx:navMap/ncx:navPoint"/>
          </ul>
        </xsl:if>
      </p>
    </body>
  </html>
</xsl:template>

<xsl:template match="ncx:navPoint">
  <li>
    <a href="{ncx:content/@src}">
      <xsl:value-of select="ncx:navLabel"/>
    </a>
    <br/>
    <xsl:if test="ncx:navPoint">
      <ul>
        <xsl:apply-templates select="ncx:navPoint"/>
      </ul>
    </xsl:if>
  </li>
</xsl:template>

</xsl:stylesheet>

Posted in Uncategorized | Leave a comment

Läsa epub-böcker i Lynx

$ unzip foo.epub
$ cd OEBPS
$ ls -1 *.html | \
xargs perl -Cio -pi -e 's/([^\x00-\x7f])/sprintf("&#%d;", ord($1))/ge;'
$ lynx file://`pwd`

Posted in Uncategorized | Leave a comment

Cd till .wav rippa och spela i OpenBSD 4.7

$ cdio cdrip
$ ls -1 *.wav | xargs aucat -i

Posted in Uncategorized | Leave a comment

Musik för programmering

Jan Johansson : Jazz på svenska, etc.
http://www.janjohansson.org/

Posted in Uncategorized | Leave a comment