понеделник, 23 февруари 2015 г.

A working tabs-restore plugin for gedit-3x

Yup, once you know what to look for, it's pretty obvious. I was quite desperate to find a plugin to save my tabs session and restore it on restarting gedit. I quickly found one, and tried to install it, but it never worked and I kept on getting all kind of odd errors (like "error loading python" or "error launching plugin"). Things are additionally worsened by not being able to see the tickmarks on the Plugins settings in Preference.
Anyway, it turned out the problem is that the pluging I was trying to install was for gedit-2. So I found this plugin to actually work *YAAAY*!
To install it, follow the steps on the page, i.e.
1. Download,
2. Copy the extracted files to ~/.local/share/gedit/plugins/ 
3. Copy and compile the settings schema as sudo/root: 
$sudo cp org.gnome.gedit.plugins.restoretabs.gschema.xml /usr/share/glib-2.0/schemas/
$sudo glib-compile-schemas /usr/share/glib-2.0/schemas/
4. Enable the plugin from Edit-Preferences-Plugins
Ok, there is a similar plugin which I didn't try, but you can find here.
Additionally, I found this useful list of actual gedit-3x plugins: Third party gedit plugins - versions 3.0 to 3.6 You might give it a try. 
Finally, if you ask the logical question why I'm using gedit when I'm actually under KDE, well, it has pretty cute IDE controls, it's ridiculously light and dumb that I wouldn't use it for anything but one particular project. Which doesn't apply fro kwrite for which I have in any moment like 5 opened windows. Of course, Kate has a pretty good session manager but then I couldn't find a proper way to use it as IDE, which decreases significantly its value. Anyway, now my Gedit has a tabs-restore! :)

събота, 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.