Thursday 28 November 2013

Going back to a previous directory in the Linux terminal

 A little cd trick to cd back in Linux terminal history:
 cd -  

So useful I had to share!

Wednesday 27 November 2013

Adding Syntax Highlighting to Linux less

Install source-highlight:
 sudo apt-get install source-highlight  

Add the following two lines to~/.bashrc
 export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s"  
 export LESS=' -R '  

Now source files opened with less will be nicely syntax highlighted. source-highlight supports many languages - see
 source-highlight --lang-list  
for a full listing.

Tuesday 7 May 2013

Using Nautilus file manager with Enlightenment window manager

I'm a fan of Bodhi Linux, which uses the Enlightenment window manager and is pretty speedy on all kinds of hardware. Unfortunately however, the built in file manager isn't yet fully functional in my opinion. As Dropbox has a dependency on Nautilus, I've integrated that into Enlightenment as the primary file manager.

To do this, we need to start Nautilus with the --no-desktop option. Start by making moving /usr/bin/nautilus to /usr/bin/nautilus.original, and create a new script at /usr/bin/nautilus containing the following command:
 #!/bin/bash  
 nautilus.original --no-desktop $@ &  

The $@ expands any passed arguments, allowing the use of the script as if it were the original Nautilus binary.

To ensure Enlightenment uses only Nautilus, we need to disable the integrated file manager from the Modules settings (Run Everything -> Modules -> Files). Disable EFM (Starter) and EFM Operation Info and close the settings window.

If you use the Places module, either on the desktop or in a panel, you'll also want to ensure that this launches Nautilus instead of the integrated file manager. To do this, right-click on the gadget, then go to Settings.  Finally, select Use a custom file manager and enter nautilus in the box.

And we're done - we're now using Nautilus as a replacement for the Enlightenment File Manager.


References:[Crunchbang Forums: Make nautilus --no-desktop default.]

Saturday 6 April 2013

Scanf in Go lang on Windows

A little gotcha when using fmt.Scanf in Go:

fmt.Scanf currently relies on the Unix line ending \n, while Windows uses \r\n. This means that when using fmt.Scanf, you must include the \n if you're building your Go program for Windows. For example:
 fmt.Scanf("%d", &num)  
will work in Unix but not in Windows. You're most likely to notice this when using fmt.Scanf multiple times - either in a for loop or simply sequentially. fmt.Scanf will likely appear to run twice as often as you expect, leading to unexpected program flow.

To resolve this issue, just make sure to include the \n in your use of fmt.Scanf, as demonstrated below.
 fmt.Scanf("%d\n", &num)  

Incidentally, if you're trying to track down errors like this one, you can always check function error codes, as demonstrated below.
  n, err := fmt.Scanf("%d", &num)  
     if err != nil {  
       fmt.Println(n, err)  
     }  
In the above case, we get this error:
 20 unexpected newline  
Which gives us the line number, and the issue from that line.



[References] Stack Overflow: parallel processing: How do I use fmt.Scanf in Go

Wednesday 6 March 2013

Linux hibernate hangs on resume - Solved

If s2disk successfully hibernates your machine, but on powering up the resume screen appears to hang, after it has appeared to stop working try pressing Alt-SysRq-E. This ends all processes in the virtual terminal used by s2disk, and, for me at least, allows me to resume working in my hibernated session.

Odd, but this might help others close to giving up on hibernation in Linux.

Monday 4 March 2013

Fixing plugin problems with Banshee music player in Linux

After installing Banshee on my minimalist Bodhi Linux install, trying to play music lead to Banshee asking to install plugins, and then hanging. Installing the following packages using the command below resolves the issue.
 sudo aptitude install gstreamer0.10-plugins-bad gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly  

Thursday 21 February 2013

Converting Latex to HTML using Pandoc

Install Pandoc using your disto's package manager, or by following the installation instructions here.

Then use:
 pandoc input.tex -o output.html --mathjax  

Nice and straightforward!