Monday, December 10, 2012

Revert bad SVN commit

Found this, which works. seems like a strange way to revert to a previous version, but I guess that's how SVN works.
svn merge -r [current_version]:[previous_version] [repository_url]
svn commit -m "Reverting back to revision [previous_version]."
Thought it looks a bit scary, I tried it and it worked.

Thursday, December 6, 2012

Find and delete empty files/folders

Find can find empty files and/or folders and even remove them (scary).

# Find all empty files and/or folders recursively
find -depth  -empty 
# Find all empty folders, only recurse two levels  
find -maxdepth 2 -depth  -empty -type d 
# Delete what you find 
find -maxdepth 2 -depth  -empty -type d  -delete

Friday, November 30, 2012

Arbitrary screen capture in KDE


A nice post at floatingsun, explains how to get screen capture functionality in KDE similar to what you get with the Compiz screenshot plugin. Basically you set up shortcut and have it run the previously unknown to me application
kbackgroundsnapshot -region 

If you copy and paste from the linked website you will need to replace the hyphen with a "minus sign". Anyway, this command lets you select any screen region and puts a .png on your desktop.

In arch I had to install the kdegraphics-ksnapshot package.

It also locked up on me when I tried to press escape to exit without selecting anything, I had to CTRL+ALT+F1 and kill it from command line.

But that's one of the key things I've been missing from Compiz.

Monday, November 26, 2012

Sorting "find" results by date

I have been meaning to look this up for a while now. Sometimes I save a file, but I'm not sure in which folder. I use "ls -ltrh" all the time to sort contents of a folder by reverse time so the most recently modified items appear at the bottom (very useful example is ls -ltrh /var/log to find most recently modified log files).

The following command will use the results of  the find command to do the same thing over multiple folders. Its too complex to type all the time, so I put it in a script in my personal script folder. Another good idea would be to alias it.


    find . -type f -printf '%T@ %p\n' | sort -k 1nr | sed 's/^[^ ]* //' | head -n 10

This example shows only the 10 most recent files (head -n 10) and doesn't filter filenames in any way. It also only examines normal files, not folders or other.

MPRIS players in KDE


I've switched to Arch Linux and a KDE desktop. I love cairo-dock/compiz but it seems like its hard to get compiz to work consistently any more due to gnome etc... loading their own compositing tools that keep trying to take control.

So far I like Arch a lot, and I'm surprised to find that applications tend to run significantly quicker and use less RAM. Notably Windows in VirtualBox and Office 2010 under WINE which were both pretty slug like in Ubuntu.

Anyway, one of the issues is getting the play/pause button on my keyboard to work with Pithos, its assigned only for Amarok by default under KDE. This post gives a method of creating scripts for play/pause, stop, next, previous and reassigning multimedia keys to run them.

Sunday, November 25, 2012

Kile's 1024 character line limit

For some reason Kile (and Kate?)has a configurable line length limit.
When editing .tex documents its easy to exceed the default of 1024 characters and if you open a file with lines longer than the default it gives an error and sets the document to read only.

Go into settings->Configure Kile and select Editor->Open/Save set the line length limit to 0 and there will be no limit.

Wednesday, November 14, 2012

Maximize Minimize button discovery

I just found something by accident after all these years (well it may be a new feature...).

Right clicking on the maximize button maximizes a window only in the width direction.
Middle click maximizes in only the height direction.
Clicking either a second time restores back to original.

Tuesday, November 13, 2012

Using the script command

For years I've wondered why the script command gives no output in Ubuntu. I still don't know the answer, but I just found that by using the "-q" option it works!

-q is supposed to be for "quiet" mode, which I guess turns off the little messages like "script started". But it causes script to actually produce a script.
$ script -q <filename>

Thursday, November 8, 2012

Reset USB ports in Ubuntu 12.10

From http://davidjb.com/blog/2012/06/restartreset-usb-in-ubuntu-12-04-without-rebooting

If your USB port gets mangled and a device isn't working as it should:

  tward $ lspci | grep USB 
  00:1a.0 USB controller: ...
  00:1d.0 USB controller: ...

Then do the following:

  tward $ echo -n "00:1a.0" | \
          sudo tee /sys/bus/pci/drivers/ehci_hcd/unbind
  tward $ echo -n "00:1a.0" | \
          sudo tee /sys/bus/pci/drivers/ehci_hcd/bind

For each of the above controllers. 

Be aware that after you write to unbind, anything connected to that particular USB controller will be unavailable until you write to bind on the next command. So if your keyboard is connected to one of those, you may be in trouble.

Note: See the comment below for an updated procedure.

Thursday, November 1, 2012

Disable overlay scrollbars in Ubuntu 12.10 (Quantal)

Since I upgraded to 12.10, (Quantal) I have have all sorts of issues because apparently gnome is moving away from compiz and using something of their own, but I'm using cairo-session which uses gnome-session, ... Whatever anyway ubuntu-tweak isn't working completely for me and the stupid overlay tool bars kept reappearing. The command below disables them:
gsettings set com.canonical.desktop.interface scrollbar-mode normal
Another thing that's not persisting is window focus mode:
dconf write /org/gnome/desktop/wm/preferences/focus-mode \'sloppy\'
dconf write /org/gnome/desktop/wm/preferences/auto-raise false

Thursday, October 25, 2012

Branching with GIT

Yann Esposito compares BZR and GIT Distributed Version Control Systems (Source control).

I like this example of branching and merging for GIT though.

Cheap branching

You always work into the same main directory. For example, you can work on two fix in the same time. Say fix1 require you to work on file1 and fix2to work on file2. You can work in any order on file1 and file2 in themaster branch. And then go to branch fix1, commit file1 into it. Then go to branch fix2 and commit file2 into it. And finally merge the two branchesfix1 and fix2 into master.
> vim file1
> vim file2
> git br fix1
> git add file1 
> git commit -m 'fix1'
> git br fix2
> git add file2
> git commit -m 'fix2'
> git commit master
> git merge fix1
> git merge fix2
And this is great not to worry about working in the good branch and coding in the same time. You just worry about your code and then about the versionning system.
And I use this possibilities a lot. Working with bazaar, I often made the error to begin a change in the bad branch. then I have to copy my modifications, then revert. In short it was tiedous.
This is why I prefer using git on an every day usage. If Bazaar implement the same way of cheap branching than git. I should switch again.

File associations

There is a lot of information at libre-software.net

Associate all office documents to LibreOffice instead of OpenOffice.org

Display all the MIME types associated to OpenOffice.org documents with the following command:

cat /usr/share/applications/defaults.list | grep openoffice.org
Append all the concerned lines to the local file:
cat /usr/share/applications/defaults.list | grep openoffice.org >> ~/.local/share/applications/mimeapps.list
Open the defaults.list description file with gedit:
gedit ~/.local/share/applications/mimeapps.list
And replace all occurences of "openoffice.org" with "libreoffice" 
 
Finally, save the file. No need to restart, you're all set!

Friday, October 19, 2012

Disable overlay scrollbars in Ubuntu

Some nice tricks from noobslab for Ubuntu 12.10

Disable overlay scroll bars in Ubuntu

gsettings set com.canonical.desktop.interface scrollbar-mode normal

Disable crash reports

I have had a lot of issues with crash reports that just keep on occurring, even when I say "don't tell me again" and when nothing has apparently happened.
sudo gedit /etc/default/apport  
change "enabled=1" to "enabled=0"
sudo service apport stop

Add "open as administrator" as a right click option in nautilus

wget http://dl.dropbox.com/u/53319850/NoobsLab.com/libnautilus-gksu.so 
sudo cp libnautilus-gksu.so /usr/lib/nautilus/extensions-3.0/ 
sudo rm libnautilus-gksu.so