Unix/Linux — Ubuntu/Debian — lock package version

October 11, 2011 by

In order to lock a package to a specific version and refrain it from being upgraded do:

sudo -s
echo PACKAGE_NAME hold | dpkg --set-selections

To verify the settings for a package to:

sudo -s
dpkg --get-selections PACKAGE_NAME

To re-enable a package to be upgraded do:

sudo -s
echo PACKAGE_NAME install | dpkg --set-selections

More info can be found here:
https://help.ubuntu.com/community/PinningHowto

Unix/Linux — .Xdefaults in X-Win32

February 27, 2011 by

In order to be able to use your .Xdefaults file in X-Win32 you have to do the following.

  1. Copy your .Xdefaults file to C:\Users\USERNAME\AppData\ Local\StarNet\X-Win32\Xdefaults. Where USERNAME is your Windows user name.
  2. Disable the Set Xresource Defaults option in the X-Win32 X-Config’s Window tab.

Unix/Linux — Insert TAB in command

November 19, 2010 by

If you need to run a command which requires you to insert a TAB, press Ctrl-V TAB to insert it.

This could be useful when you want to grep for TAB or split lines of a TAB separated file with cut.

Suversion — Change repository URL

August 1, 2010 by

If you have checked out a repository and the repository URL has changed, you can update the URL using the svn switch command. For example:

Old URL: https://www.oldrepo.com/svn/
New URL: https://www.newrepo.com/svn/

svn switch –relocate https://www.oldrepo.com/svn https://www.newrepo.com/svn

See svn switch in Version Control with Subversion book for more details.

Emacs — ispell — No word lists (Ubuntu)

November 16, 2008 by

In Ubuntu, if you get:

Error: No word lists can be found for the language “en_US”.

when trying to start ispell (e.g., M-x ispell-buffer) from Emacs, then you need to install the aspell-en package:

sudo apt-get install aspell-en

Emacs — Using rectangles

November 12, 2008 by

In Emacs, you can not only select by lines, but also by columns. If you select by columns, the selection is called a rectangle. You can use rectangles with the following shortcuts:

  • C-@ or C-Space — start selection (as usual)
  • M-x delete-rectangle or C-x r d — delete the rectangle delimited by the start selection and the current cursor position
  • M-x kill-rectangle or C-x r k — then you can use — M-x yank-rectangle or C-x r y
  • M-x clear-rectangle or C-x r c — replace the contents of the rectangle with spaces
  • M-x open-rectangle or C-x r o — insert spaces in the area and push the original contents to the right

C/C++ — Insert sequential values into container

November 7, 2008 by

To insert sequential values into a container, you could use the iota function available in ext/numeric header. For example:

#include <ext/numeric>
#include <vector>

std::vector<int> v(5);
__gnu_cxx::iota(v.begin(), v.end(), 0);

v will contain {0, 1, 2, 3, 4}.

For more information see sgi documentation

Python — Convert string to HTML/XML entities

October 18, 2008 by

In order to convert a string to HTML/XML entities you can use:

”.join([‘&#%d;’ % ord(ch) for ch in text])

For example if text=’mailto’ the output would be:

‘& #109;& #97;& #105;& #108;& #116;& #111;’

This might be useful in hiding email addresses in web pages.

Unix/Linux — Swap Ctrl and Caps Lock in X11

April 26, 2008 by

In order to swap the Ctrl and Caps Lock keys in X11, you can add the following line in Section “InputDevice” of file /etc/X11/xorg.conf:

Option “XkbOptions” “ctrl:swapcaps”

If you woud like to keep the Ctrl where it is and make Caps Lock act as a Ctrl also, you can add:

Option “XkbOptions” “ctrl:nocaps”

Unix/Linux — generate large file

April 11, 2008 by

In order to generate a large file of a set size you can use:

dd if=/dev/zero of=test100M.bin bs=100000000 count=1

where of is the output file and bs is its size in bytes.


Follow

Get every new post delivered to your Inbox.