събота, 10 януари 2015 г.

How to convert color eps to grayscale

That turned out more complicated that it seems. The default ways didn't seem to work for me, because the eps was produced by Maple (so there is a bitmap graphics inside).

Here is what it worked for my figure.eps:

$epstopdf figure.eps
$gs  -sOutputFile=output.pdf  -sDEVICE=pdfwrite  -sColorConversionStrategy=Gray  -dProcessColorModel=/DeviceGray  -dCompatibilityLevel=1.4  -dNOPAUSE  -dBATCH  figure.pdf
$ pdftops -eps output.pdf

This can be done easily to a script like this:

#!/bin/bash
epstopdf $@ -o output_eps.pdf
gs -sOutputFile=output.pdf -sDEVICE=pdfwrite -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -dCompatibiltyLevel=1.4 -dNOPAUSE -dBATCH output_eps.pdf
pdftops -eps output.pdf

Save it as epstograyscale.sh
$sudo chmod +x  epstograyscale.sh
$sh epstograyscale.sh figure.eps

It worked on my PC.

вторник, 6 януари 2015 г.

Card reader stopped detecting my SD card

A little card reader fun before going to bed.
So we needed to format a 16GB SD card to ext4, it was formatted as fat32 (who the hell uses this format besides cameras?). So at first, my Sabayon wasn't detecting it at all. After starting gparted it appeared, but it couldn't be formatted to ext4 (gave couple of errors). Then we tried formatting it manually and we got:
$sudo mkfs.ext4 -n 'LUbuntu' -I /dev/sdb1
   mkfs.ext4: invalid inode size - /dev/sdb1
Another try to reformat it as fat32.
$sudo mkfs.vfat -n 'LUbuntu' -I /dev/sdb1
mkfs.fat 3.0.26 (2014-03-07)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
mkfs.vfat: unable to open /dev/sdb1: Device or resource busy
 $ sudo mkfs.vfat -n 'LUbuntu' -I /dev/sdb1
mkfs.fat 3.0.26 (2014-03-07)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
/dev/sdb1: No medium found
Then the card reader stopped detecting the card at all and it wasn't visible with $df or $fdisk -l.
I checked dmesg:
sudo dmesg|tail  
[238472.867688] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.867742] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.867825] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.867891] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.867965] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.868054] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.868131] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.868207] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.868277] FAT-fs (sdb1): Directory bread(block 8192) failed
[238615.530731] sdb: detected capacity change from 15803088896 to 0
After some googling it turned out that there is a solution. I did:
$sudo fsck.vfat -nVv /dev/sdb1
fsck.fat 3.0.26 (2014-03-07)
fsck.fat 3.0.26 (2014-03-07)
Logical sector size is zero.
which changed my dmesg to:
sudo dmesg|tail
[238472.867825] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.867891] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.867965] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.868054] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.868131] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.868207] FAT-fs (sdb1): Directory bread(block 8192) failed
[238472.868277] FAT-fs (sdb1): Directory bread(block 8192) failed
[238615.530731] sdb: detected capacity change from 15803088896 to 0
[240604.657313] sd 7:0:0:0: [sdb] 30865408 512-byte logical blocks: (15.8 GB/14.7 GiB)
[240604.786064]  sdb: sdb1
YAY!
Then I started gparted and formatted it to ext4 without any problem.
It's great when things end well, right? :)
Now let's see this Banana Pi.