Tuesday, January 29, 2013

Convert dynamic VirtualBox VDI volume to static

The command below will convert your dynamic storage volume to fixed, which I'm hoping will boost performance.

$ VBoxManage clonehd dynamic.vdi static.vdi --format VDI --variant Fixed
However, in Arch at least this command seems to wreak havoc with normal OS function. Things just kind of quit working, kwin, chromium, they all sort of die. Not just slow due to disk thrashing, but actually die. I'll have to leave it overnight and see if it actually works.

Another issue I found is that I have my virtualbox VM folder soft linked into my home folder, but stored in my Documents. I had to first delete this link otherwise VBoxManage refused to work due to finding a disk with a duplicate UUID.

Tuesday, January 22, 2013

Using tr to delete carriage returns

I wanted to change a files contents from being carriage return delimited to being space delimited, So of course I tried to pipe it through sed, but couldn't get it to do what I needed for whatever reason.

Found the "tr" command for "translate characters".

Can use -d option to delete chracters
tr -d "\n" < file.txt > file-sans-cr.txt
or give two strings to translate between
tr "\n" " " < file.txt > space-delimited-file.txt

Saturday, January 19, 2013

Using fuser to find who's doing what

I just ran across a use of the program fuser which I have never used. It might come in handy for debugging stuff. It is used to identify processes using files or sockets.

It was suggested to use fuser to find what user has access to my sound card.
~ $ fuser -v /dev/snd/*          
                     USER        PID ACCESS COMMAND
/dev/snd/controlC0:  tward       785 F.... cairo-dock
                     tward       791 F.... pulseaudio

Tuesday, January 15, 2013

Arch bluetooth connections fixed?

I have been having issues with bluetooth connections since I switched to Arch. I ran "journalctl" and saw an entry "Unable to connect to SEP" which led me to http://en.gentoo-wiki.com/wiki/Bluetooth_headset#Troubleshooting

After adding
  [General]
  Enable=Socket
to /etc/bluetooth/audio.conf my bluetooth speaker connected right away. Hope it stays fixed.

EDIT: This worked as I said, but a day or two later I was having the issue again and eventually found a message indicating a socket error (I don't remember exactly what it was). I undid this modification and haven't had any trouble since, so... who knows.

Sunday, January 13, 2013

Piping "find" results through xargs

Piping the results of find using xargs doesn't typically work exactly how I want. If a file or folder has a space in its name xargs doesn't handle it correctly.
From the xargs man page:
Because Unix filenames can contain blanks and newlines, this default behaviour is often problematic filenames containing blanks and/or newlines are incorrectly processed by xargs. In these situations it is better to use the -0 option, which prevents such problems. When using this option you will need to ensure that the program which produces the input for xargs also uses a null character as a separator. If that program is GNU find for example, the -print0 option does this for you.
So, long story short: add "-print0" to find, and "-0" to xargs:

find . -name "*txt" -print0 | xargs -0 grep -i poisson

Friday, January 11, 2013

LibreOffice document recovery actually recovers a document

I have been using Linux all day every day for about 8 years now and the application I've used more than any has been OpenOffice/LibreOffice.
Literally hundreds of times I have lost content due to a crash, power failure, command line reboot without saving or whatever. When this happens the next time you start *office it has always asked  me if I want to recover from my previously aborted session.

In all my 8 years and hundreds of times having lost content I have never had it actually recover even so much as a single word of unsaved content.

Well, yesterday I rebooted my machine from command line without saving a document I had been working on. When it came back up, I started LibreOffice Writer, and HOLY CRAP!!! My completely unsaved document was just there!

It didn't ask me to recover or anything, just started in the same state it had been in previously with the unsaved content!!!!!

I'm just amazed at the simple fact that this actually worked. Maybe I can begin to expect the style manager in Impress to actually manage styles now! I'm gonna go check on that right now...


My build

LibreOffice: Version 3.6.4.3 (Build ID: 3.6.4.3 Arch Linux build-3)

Thursday, January 10, 2013

Fix PDF showing inifinity instead of bullets

I've had this problem for a long time, sometimes a PDF was created with a font that doesn't get mapped properly and the bullet points show up as inifinity symbols.

I found this post for Ubuntu: https://bugs.launchpad.net/ubuntu/+source/fontconfig/+bug/551977

$ fc-match Symbol symbol.ttf: "Symbol" "Regular"
A workaround is adding this code to /etc/fonts/local.conf and the bullets would appear:
<match target="pattern">  <test name="family">   <string>Symbol</string>  </test>  <edit name="family" mode="prepend" binding="same">   <string>Standard Symbols L</string>  </edit> </match>
$ fc-match Symbol s050000l.pfb: "Standard Symbols L" "Regular"
This worked perfectly in Arch for me.

Wednesday, January 9, 2013

Regex search/replace to insert newlines

I use Kile and Mendeley. Mendeley generates bibtex references, but with no carriage returns, and the carriage returns are apparenly required.

Example:

@article{Baset_2012, place={New York, New York, USA}, ..., pages={1–2}}

I need each of the x={...}, sections to be on a separate line, and it takes a while to do it by hand.

To search/replace, I enter this search criteria:

\}, +([a-zA-Z])
And this replace criteria:

\}, \ \1

The red block is actually representing a CTRL+V of a newline character. Just select an entire empty line, copy and past into the expression. It will look like a blank space.