Posted on January 15th, 2009 by BKB Categories: ASCII art, Unix commands |
The Japanese answer to Unix banner is kbanner. It can convert kanji text like 雑 to ASCII art:
## ## ##
## ## ####
############ ## ##
## ## ##############
## ## ## ## ##
#### ###### ## ##
#### #### ##
## ## ############
## ## ##
############## ## ##
## ## ##
###### ############
#### ## ## ##
## ## ## ## ##
## ## ## ##
## ##############
Posted on January 15th, 2009 by BKB Categories: Uncategorized |
pdftotext has two versions, xpdf and poppler-utils.
The one on Linux is the poppler-utils version. This seems to output UTF-8 by default. This does not seem to have a compiled Windows version.
Compiling poppler-utils from source on Cygwin
I tried downloading the source code of poppler-utils and compiling it on Cygwin but failed due to lots of dependencies.
Missing "pkg-config"
The first problem was the lack of "pkg-config". This existed on Cygwin's setup.exe and so I installed it using that.
Missing "fontconfig"
The next problem was the lack of fontconfig. This was not detected by pkg-config although it had been installed by Cygwin previously. It was not clear how to tell pkg-config that fontconfig was already installed.
This particular dependency seems particularly unnecessary, since the libraries actually were installed on the system - what is the point of having a "configure" script if the configure script is set up to depend on pkg-config?
Tried to find a compiled version, tried Xpdf instead.
At this point I started looking for a compiled version of poppler-utils
but did not easily find any. I then decided to try Xpdf
instead. I put the Xpdf files into
C:\Documents and Settings\bkb\My Documents\software\xpdf
directory and tested it.
Test of Xpdf
The first test on a Japanese document was a failure, but when an encoding was specified using -enc UTF-8, it correctly output the Japanese in the PDF file.
Thus Xpdf seems adequate for what I want to do (index some PDF files).
Posted on January 15th, 2009 by BKB Categories: ASCII art, Unix commands |
As well as the Unix banner command, Figlet is also useful:
[ben@lemon] ~ 501 $ figlet figlet_test
__ _ _ _ _ _
/ _(_) __ _| | ___| |_ | |_ ___ ___| |_
| |_| |/ _` | |/ _ \ __| | __/ _ \/ __| __|
| _| | (_| | | __/ |_ | || __/\__ \ |_
|_| |_|\__, |_|\___|\__|___\__\___||___/\__|
|___/ |_____|
Posted on January 15th, 2009 by BKB Categories: MySQL |
To convert a datetime field into a date, use convert,
select count(*) from inputs where convert(datetime,date) > '2008-11-13';
To get a list of distinct dates from a table called inputs with a field called datetime containing datetimes, use
select distinct convert(datetime,date) from inputs;
Posted on January 15th, 2009 by BKB Categories: Japanese, MySQL |
The default collation of MySQL causes problems whereby it thinks that pairs of kanjis like 伊 and 会 are the same.
To solve this problem, change the collation of the table with collate utf8_bin, as in
alter table tests modify kanji varchar(12) collate utf8_bin
Posted on October 9th, 2008 by BKB Categories: Uncategorized |
There are a lot of Jabber clients.
After finally managing to get the Jabber2 server working, I started messing around with some clients.
| Client |
Rating |
Comment |
| Trillian |
0/5 |
Didn't do Jabber anyway but gets serious black marks for uninstaller malarkey. |
| Pidgin |
3/5 |
I got it to work on Windows but it failed mysteriously on Linux. Failed to activate after creating account, but did not give any help or idea of why failure occurred. |
| Kopete |
4/5 |
The first client I got to work, seemed to go smoothly on Linux. |
| Empathy |
2/5 |
Like Pidgin, this looks nice but actually is minimal and no help when things go wrong. |
| Pandion |
3/5 |
No help at all in debugging connection problems. Worked OK once I had figured out why the server was failing. |
| Miranda |
2/5 |
Broken, unhelpful |
| JAJC |
? |
I gave up at the stage of the downloads page. |
| SIP Communicator |
? |
The logo looks like a turd. I won't install anything written in Java unless there is no other alternative. |
| Exodus |
5/5 |
Exodus looks pretty good and setup information is helpful. Has a debug screen which helped me to understand why my server would not connect. |
Posted on October 7th, 2008 by BKB Categories: Google, Wordpress, php |
I tried using two of the plugins at Wordpress.org for Google Adsense. I first of all tried the "all in one adsense and ypn" plugin. However, this creates its own code which I'm not sure is allowed by Google. Then I tried the "Post Layout" plugin. This is much better, because it lets me add the Google adverts from Google instead of making its own. Instantly I found that the Google adverts had started to show up correctly on my Adsense page. But it adds too many. Google says that I should only put a maximum of three adverts onto each page. So I hacked the code of "Post Layout" so that it only incorporates the ads three times. In the file post-layout/plugin.php, I added a line
$pstl_options['done']=0;
and at the start of the routine pstl_the_content I added some code so that the "extra" stuff only gets incorporated three times:
// Make sure we don't get more than three ads on the page.
$pstl_options['done']++;
if ($pstl_options['done'] > 3) {
return $content;
}
As you can see from this page, it seems to be working correctly.
The whole thing then looks like this.
$pstl_options['done']=0;
function pstl_the_content(&$content)
{
global $pstl_options;
// Make sure we don't get more than three ads on the page.
$pstl_options['done']++;
if ($pstl_options['done'] > 3) {
return $content;
}
Posted on October 7th, 2008 by BKB Categories: FreeBSD |
The following files live in FreeBSD's /etc/ directory:
export
| Files |
| File |
Function |
Example |
| Controls which files are exported by NFS |
fstab |
Devices and mountpoints |
|
gettytab |
Terminal configuration database |
|
hosts.allow |
|
|
hosts.deny |
|
|
hosts.equiv |
|
|
hosts.lpd |
|
|
hosts |
Contains a list of IP addresses and the hosts associated with them. |
192.168.0.4 mypc |
libalias.conf |
|
|
localtime |
Contains time zone information. Does not have a manual page. |
|
login.conf |
Login configuration |
|
make.conf |
Global configuration for make |
|
manpath.config |
Configuration for man for where to find its files. |
|
master.passwd |
|
motd |
Message of the day |
|
netconfig |
|
|
nnswitch.conf |
Configuration for NSS (name service switch) |
|
ntp.conf |
Configuration for NTP (network time server) |
|
profile |
Global setup file for /bin/sh |
|
protocols |
Internet protocols |
|
rc.conf |
Initialization script |
|
rc.firewall |
|
|
rc.shutdown |
|
|
rc.subr |
Functions used by system shell scripts |
remote |
|
|
resolv.conf |
Sets up nameserver |
|
services |
Well-known services (port numbers for internet services) |
|
shells |
List of acceptable login shells |
|
sysctl.conf |
Multiuser mode configuration |
|
syslog.conf |
|
|
termcap |
Terminal database |
|
ttys |
Terminal initialization information |
|
wall_cmos_clock |
|
|
| Directories |
isdn |
|
|
namedb |
Nameserver |
|
Posted on October 7th, 2008 by BKB Categories: Microsoft Windows, Perl, Shift JIS / CP932, UTF-8 |
I've found that I have a lot less problems dealing with Japanese text if I always
use utf8;
in Perl scripts. However, on a Japanese Windows OS this creates problems, because directory and file names may contain kanji or kana. For example the Desktop directory on English-language Windows becomes
C:\\Documents and Settings\bkb\デスクトップ\
on a Japanese Windows PC. Although Windows uses Unicode internally, unfortunately as far as Perl is concerned, if I want to manipulate files, I have to send the file name as CP932 (code page 932) encoded text.
However, if I have a use utf8; section at the top of my Perl file, then a non-UTF-8 encoded directory name will cause all kinds of problems with editing.
The way I have solved this problem is, to continue to use utf8; at the top of the page, but to also
use Encode 'encode';
to encode the UTF-8 directory names into CP932 before sending them to functions like open. For example, here is how to make a directory called test on the desktop:
#! perl
use warnings;
use strict;
use utf8;
use Encode 'encode';
my $desktopdir = encode ('cp932',
'C:\\\\Documents and Settings\bkb\デスクトップ\\');
my $newdir = $desktopdir."test";
mkdir $newdir or die "Can't make directory '$newdir': $!\n";
Notice the double backslashes, which are necessary for the cases when there are two backslashes in a row, or an apostrophe after the backslash. Also notice that I use single quotes around the name of $desktopdir in order to avoid problems with the slashes.
Posted on October 7th, 2008 by BKB Categories: Microsoft Windows, Perl, top tip |
To create a Windows shortcut to a directory in Perl, use the Win32::Shortcut module as follows:
use Win32::Shortcut ();
my $s = Win32::Shortcut->new();
$s->Path('C:\\Documents and Settings\bkb\My Documents');
$s->Save('C:\\Documents and Settings\bkb\Desktop\sips.lnk');
If you use a path name like
"C:/Documents and Settings/bkb/Desktop"
then the link will be munged.
If you use
'C:\\Documents and Settings\bkb\Desktop'
then the shortcut is created correctly. The picture below shows a good and bad shortcut, next to the Cygwin icon:

There is a long discussion at Perlmonks but the above is the correct answer to the original question.