Register now and start sharing your code snippets.
-->

Nifty alias for the make command to create an optimal amount of processes depending on the number of CPU's you have

Shell Script (Bash) posted 6 months ago by marko

Put this in your ~/.bashrc to automatically adjust the number of processes make creates. This snippet is licensed under the beerware license.

   1  # ----------------------------------------------------------------------------
   2  # "THE BEER-WARE LICENSE" (Revision 42):
   3  # < marko haapala at aktagon com > wrote this file. As long as you retain this notice you
   4  # can do whatever you want with this stuff. If we meet some day, and you think
   5  # this stuff is worth it, you can buy me a beer in return.
   6  # ----------------------------------------------------------------------------
   7  alias make="make -j$(cat /proc/cpuinfo |grep processor | wc -l)"

Tagged make, number of processors

Compiling xvidcap for making screencasts in wmii

Shell Script (Bash) posted 6 months ago by marko

I was unable to make screencasts in wmii using Istanbul. So here’s how I installed xvidcap. Unfortunately I cannot come up with a way for wget retrieval of the sourceball, so some manual labour is needed. Retrieve the sourceball and put it in /tmp. Then follow the instructions below. Also see the snippet for an alias for the make command first.

Note that I put the binaries in /usr/local/stow/xvidcap because the package comes from outside package management. I then use xstow to manage the symlinks in /usr/local/bin.

   1  sudo apt-get install libxml-parser-perl libxmu-dev libglade2-dev libgtk2.0-dev
   2  cd /tmp
   3  tar zxvf xvidcap*.tar.gz
   4  cd xvidcap*
   5  ./configure --prefix /usr/local/stow/xvidcap
   6  make
   7  sudo make install
   8  cd /usr/local/stow
   9  sudo xstow xvidcap

To remove xvidcap follow these steps

   1  cd /usr/local/xstow
   2  xstow -D xvidcap
   3  sudo rm -rf /usr/local/stow/xvidcap

Tagged linux, xvidcap, xstow, screencasts in wmii

Trusted and sensitive email protection with GPG using Gmail with Firefox

Shell Script (Bash) posted 6 months ago by marko

It’s really simple to use GPG to encrypt and/or sign email you send through Gmail.

Generate your private key.

   1  gpg --gen-key

Extract your public key, which you will send to people you need to communicate securely with.

   1  gpg --armor --export marko.haapala@ihatespamaktagon.com > my_public_pgp_key

Install FireGPG and restart the browser. Use GPG in Gmail.

Tagged firefox, gmail, gpg, trusted emails, sensitive emails, firegpg

Restricting memory usage of Firefox cache

Shell Script (Bash) posted 6 months ago by marko

Firefox hogs a lot of memory when using pages using Ajax enabled web pages. I need to restart the browser many times during a day at the office. This hack seems to have fixed that issue.

Open the location about:config, right click and create a new key of integer type.

Key:

   1  browser.cache.memory.capacity

Value:

   1  16384

Tagged firefox

Installing git without getting screwed over when it's time to uninstall, upgrade or install package maintainer's version

Shell Script (Bash) posted 6 months ago by marko

Although Git is one of the better source code managers it has a major drawback if you need to install it from the sources – it’s makefile doesn’t have an uninstall target as defined in the GNU coding standards. Therefore you might find your system screwed over when you want to uninstall or upgrade after installing from sources. This is a workaround that is sufficient enough to make me break my rule of not installing software outside of package management.

Also see the snippet for an alias for the make command first.

Prequisities

   1  sudo apt-get install asciidoc xsltproc xmlto xstow bzip2 build-essential zlib1g-dev tcl8.4

Installation

   1  cd /tmp
   2  wget http://kernel.org/pub/software/scm/git/git-1.5.5.1.tar.bz2
   3  tar xjvf git-1.5.5.1.tar.bz2
   4  sudo mv git-1.5.5.1 /usr/src
   5  sudo ln -s /usr/src/git-1.5.5.1 /usr/src/git
   6  cd /usr/src/git
   7  ./configure --prefix=/usr/local/stow/git
   8  make all doc
   9  sudo make install install-doc
  10  cd /usr/local/stow
  11  cat << EOF > /tmp/xstow.ini
  12  # this is the xtow configuration file
  13  # see xstow.ini(5) for details
  14  
  15  # list of links that will be handled as normal directories
  16  [traverse-links] 
  17  keep-targets = true      # add targets of the links to the keep-dirs section
  18  link = /usr/local/tmp
  19  link = /usr/local/var
  20  link = /usr/local/man
  21  link = /usr/local/share
  22  link = /usr/local/share/man
  23  link = /usr/local/doc
  24  link = /usr/local/info
  25  add-if-target = /*       # automatic add all absolute links
  26  
  27  # directories that never should be removed
  28  [keep-dirs]
  29  dir = /usr/local/bin
  30  dir = /usr/local/sbin
  31  dir = /usr/local/lib
  32  dir = /usr/local/include
  33  dir = /usr/local/share
  34  
  35  [matches]
  36  ignore = *~      # emacs
  37  ignore = core    # core file
  38  ignore = core.*  # new style
  39  ignore = CVS     # CVS directories
  40  ignore-regex = [0]+README.*
  41  
  42  # make other stow dirs public
  43  [stow-dirs]
  44  dir = /usr/local/local/stow
  45  dir = /usr/local/local/stow2
  46  
  47  [debug]
  48  module = ALL
  49  level  = 0
  50  
  51  [config-files]
  52  in-home = yes
  53  in-stow-dir = yes
  54  in-other-stow-dirs = yes
  55  file = /etc/xstow.ini
  56  file = /usr/local/local/etc/xstow.ini
  57  
  58  [links]
  59  absolute-paths = false
  60  EOF
  61  sudo mv -i /tmp/xstow.ini .
  62  sudo xstow git

Uninstallation

   1  cd /usr/local/xstow
   2  xstow -D git
   3  sudo rm -rf /usr/local/stow/git

Kind of makes one appreciate the work done by package maintainers, doesn’t it?

Tagged git, xstow, stow