Friday, July 13, 2012

Inside a Sony PRS-T1 Reader

Having had passed to me a broken PRS-T1, I decided to rip it apart. Below is what it looks like, for the curious. Note the battery (which has been disconnected in the pictures) is soldered to the board, so not very easily replacable/reusable.

Here is the PRS-T1 service manual with instructions on how to open the thing up. Basically it has (pretty tight) clips along the inside sides.

(Right click and save, or open in a new tab/window, if you want full resolution to zoom in on.)



Sunday, January 29, 2012

Join / Merge / Combine / Concatenate PDF pages into a single PDF

There are many free (and open source) methods available.

pdfjoin / pdfjam - command line utility. Very easy to use, but has some limitations:
  • Output pages are all the same size
  • Hyperlinks are stripped
Use ghostscript to "print" all of the files into a new PDF file. With this method, you can use other ghostscript capabilities to further modify the output (such s resampling graphics, etc):
  •  gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf input1.pdf input2.pdf
pdftk (PDF Toolkit) - yet more command line tools for PDF manipulation. There are a bunch of different styles of command line (examples can be seen on web site). The simplest is:
  • pdftk input1.pdf input2.pdf input3.pdf cat output output.pdf
  • powerful but complicated GUI to PDFtk is available 
pyPDF - a tool for the programming / python oriented. It can split, merge, watermark, rotate, and extract information with simple python scripting. There is a GTK-based GUI available called PDF-Shuffler.

PDF Split and Merge is a cross-platform java based GUI (and command line) tool.

There are more! With so many choices, how does one choose? Whim, personal preferences, scale requirements, tools and platform on hand (ease of installation/integration), or just random.






Tuesday, January 17, 2012

Resampling jpegs inside a PDF (to shrink/reduce file size)

My wife is applying for various teaching jobs. Most of the positions require uploading documents to various school board applicant tracking systems. I carefully prepared the documents for her, also wanting to keep them for historical archival purposes. The uploads produce a bizarre error. Contacting the site administrator, we find out that there is a 1 megabyte file size limit on uploads and this is what produces the cryptic error. Sigh. (To add insult to injury, after resampling the scanned PDFs, it then turns out there's also crazy filename limitations... so all the nice descriptively  named files had to be renamed to eliminate various characters, and maintain a certain length). These are the gatekeepers of our children's education.

But I digress.

This info is a lot of places on the net already, but I want to add it here for my own reference as I've forgotten the simple command line a few times already and had to re-search it. 

In short, use ghostscript:
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
The PDFSETTINGS presets equate to the following resolutions:

  • /screen ... screen-view-only quality, 72 dpi images 
  • /ebook ... low quality, 150 dpi images
  • /printer ... high quality, 300 dpi images 
  • /prepress ... high quality, color preserving, 300 dpi images
  • /default ... similar to /screen

Other suggested command line arguments made various places:

  • -dCompatibilityLevel=1.4 
  • -dColorImageResolution=38 -dColorImageDownsampleType=/Average -dGrayImageDownsampleType=/Average -dGrayImageResolution=38 -dMonoImageResolution=38 -dMonoImageDownsampleType=/Average -dOptimize=true -dDownsampleColorImages=true -dDownsampleGrayImages=true -dDownsampleMonoImages=true -dUseCIEColor -dColorConversionStrategy=/sRGB
  • -dMaxSubsetPct=100
This page is quite good for further tips (such as recompressing with lossless compression).

Friday, December 16, 2011

Force java to use IPV4

Having problems with a java server application listening on IPV6. Adding the following to the java command line causes Java to use IPV4.
-Djava.net.preferIPv4Stack=true
 It's come in handy a few times. Sadly.

Sunday, December 11, 2011

Lenovo laptop low audio volume

I love lenovo/ibm laptops. Specifically their business line. I've used T series laptops for quite a while. I don't know if this is a lenovo-specific issue or not, but web searches over the years seems to indicate at least that a lot of lenovo laptop users share the problem: low audio volume, and an inability to turn it up to reasonable levels.

I've suffered this in Linux for years and years. There seem to be a lot of fixes proposed by people: kernel parameters, manual ASLA configuration tweaks. They never work for me. So I tend to use headphones for myself, or external (amplified) speakers if for others.

Lately I've been booting Windows on my laptop (T521)... mainly for Skyrim. And suddenly today I noticed the audio volume, which had seemed fine up until then was annoyingly quiet in all software. I have no idea what could have caused this. All the mixer controls were maxed, and still it was a struggle to follow speech if there was any amount of background noise in my environment.

Searching around I find that Windows people seems as baffled as Linux people by this behaviour. Lots of wacky suggestions. A lot of people saying the suggestions didn't work for them.

Finally I found a really simple solution (this is Windows 7, but other versions have similar controls):
Control Panel -> Hardware and Sound -> Manage Audio Devices -> [Playback tab] Speakers -> Properties -> Enhancements [tab] -> check Loudness Equalization -> OK. 
And suddenly I have all the loudness I could want. Why? How!

The description of this option is: "Loudness Equalization uses understanding of human hearing to reduce percieved volume differences." It reports itself as being provided by Microsoft. What does it really do? How does it magically make the volume in all apps suddenly decent? I can't believe it's just software amplification, but perhaps it is. It's hard to believe the description given has the global effect of "fixing" the volume issues.

Furthermore, what happened to make the previously "okay" volume suddenly so weak?

I really have no idea. Is there some equivalent for Linux? I don't know. Whatever it is, it works on this Lenovo box under Windows... like magic. I don't like magic, when it comes to computers. I want to know what's going on.


Monday, October 17, 2011

broken cyrus seen file

Someday I'm going to give up on running my own mail server. I say this especially when my hard drive fills up an my cyrus "seen" database files inevitably corrupt. This db file keeps track of your mailbox message status (whether you've read a message or not).

If you have this problem, you'll see a line like this in  your mail log:
DBERROR: skiplist recovery /home/cyrus/user/u/username.seen: ADD at 4C48 exists
The recommended way to fix this is to truncate the file at the location the problem is detected. In the case above, at the hex byte 4C48.

I've had to do this often enough that I've written a shell script to do it, which just needs the username and hex location supplied via command line.

Notes:
  • it's a shell script, but python is used to do hex conversion.
  • you'll probably need to change the path (/home/cyrus/user/) to your cyrus user directory (mine is non-standard).
  • you must supply the hex location where the corruption is detected. You can find this in your mail log file (usually /var/log/mail.log). 
  • if your cyrus files are owned by other than user cyrus and group mail, you'll need to change the chown cyrus:mail.
  • the existing *.seen file is backed up with a unique filename (current timestamp), so it can be restored if something goes wrong.
#!/bin/sh

if [ $# != 2 ]; then
    echo "USAGE: $0 login hex"
    exit
fi

TRUNC=`python -c "print int('$2', 16)"`
DATE=`date +%Y%m%dT%H%M`
DBPATH=/home/cyrus/user/$1

if [ -d $DBPATH ]; then
    dd if=$DBPATH/$1.seen of=$DBPATH/$1.seen.fixed bs=1 count=$TRUNC
    chown cyrus:mail $DBPATH/$1.seen.fixed
    chmod 600 $DBPATH/$1.seen.fixed
    mv $DBPATH/$1.seen $DBPATH/$1.seen.$DATE.corrupt.at.$TRUNC
    mv $DBPATH/$1.seen.fixed $DBPATH/$1.seen
else
    echo "No such directory: $DBPATH"
fi


Friday, October 14, 2011

fsck.vfat -a "Unable to create unique name"

On linux (kubuntu), trying to do an fsck on a vfat USB drive, I keep getting "Unable to create unique name".

The solution apparently is to use fsck.vfat -r [device]


I have no idea why interactive mode (-r) works, and automatic mode does not... but it gets rid of the problem.

(dosfsck is an alias for fsck.vfat and fsck.mdos)