MySQL: Show and change auto increment

November 23rd, 2010

show table status from <database> where name = ‘<table>’;
alter table <table> auto_increment = <value>;

Bash: Find and remove all .svn directories

November 13th, 2010

find ./ -name “.svn” -exec rm -rf  ‘{}’ \;

VirtualBox kernel driver not installed

October 16th, 2010

Try to update VirtualBox using package management.

If updating doesn’t solve the issue remove any previous installations and install the newest VirtualBox version (http://www.virtualbox.org/wiki/Linux_Downloads). Make sure you have kernel source installed before doing the installation.

Failed to open a session for the virtual machine Ubuntu.
Failed to open/create the internal network ‘HostInterfaceNetworking-eth0′ (VERR_SUPDRV_COMPONENT_NOT_FOUND).
Failed to attach the network LUN (VERR_SUPDRV_COMPONENT_NOT_FOUND).
One of the kernel modules was not successfully loaded. Make sure that no kernel modules from an older version of VirtualBox exist. Then try to recompile and reload the kernel modules by executing ‘/etc/init.d/vboxdrv setup’ as root (VERR_SUPDRV_COMPONENT_NOT_FOUND).

Failed to create the host-only network interface.
Failed to execute ‘VBoxNetAdpCtl add’ (exit status: 768).

Failed to open a session for the virtual machine Ubuntu.
The virtual machine ‘Ubuntu’ has terminated unexpectedly during startup with exit code 1

Kernel driver not installed (rc=-1908)

The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing

‘/etc/init.d/vboxdrv setup’

# service vboxdrv setup
Recompiling VirtualBox kernel modules, NOT. It has been packaged.

YaST segfault

October 15th, 2010

YaST got signal 11 at YCP file XML.ycp:3
/sbin/yast2: line 454: 8004 Segmentation fault $ybindir/y2base $module “$@” “$SELECTED_GUI” $Y2_GEOMETRY $Y2UI_ARGS

This started happening to me after I patched the kernel. Opening attachments with Thunderbird also caused segfault. Reinstalling yast didn’t help nor did updating graphic card driver.

Doing a distribution upgrade solved the issue.

OpenSUSE distribution upgrade

October 15th, 2010

Doing distribution upgrade with openSUSE is actually quite easy.

Use e.g. zypper to remove or disable all current version repositories.
zypper lr displays all repositories.
zypper d <repo> disables specified repository.
zypper rr <repo> removes specified repository.
zypper ar <uri> <repo> adds new repository.
After you have added all the new version repositories and disabled old ones run zypper dist-upgrade.

You can find the repositories from package repositiories. Add all official, semi-official (contrib) and KDE repositories for the version you are upgrading to. You might also like to add a new ATI/NVIDIA repository.

Tip of the day: Static instance

October 12th, 2010

class MyClass
{
  protected static $_instance;
  public static function getInstance()
  {
    if (!isset(self::$_instance)) {
      self::$_instance = new self();
    }
    return self::$_instance;
  }
}

Compiling zpipe.c

October 12th, 2010

Remember to link it to zlib library
gcc -lz zpipe.c

/tmp/ccMgDu96.o: In function `def’:
zpipe.c:(.text+0×55): undefined reference to `deflateInit_’
zpipe.c:(.text+0xb1): undefined reference to `deflateEnd’
zpipe.c:(.text+0×111): undefined reference to `deflate’
zpipe.c:(.text+0x18c): undefined reference to `deflateEnd’
zpipe.c:(.text+0x1f9): undefined reference to `deflateEnd’
/tmp/ccMgDu96.o: In function `inf’:
zpipe.c:(.text+0x25e): undefined reference to `inflateInit_’
zpipe.c:(.text+0x2b4): undefined reference to `inflateEnd’
zpipe.c:(.text+0x2f7): undefined reference to `inflate’
zpipe.c:(.text+0x33e): undefined reference to `inflateEnd’
zpipe.c:(.text+0x39c): undefined reference to `inflateEnd’
zpipe.c:(.text+0x3c7): undefined reference to `inflateEnd’
collect2: ld returned 1 exit status

Accessing memcached: Basic operations

October 11th, 2010

telnet <host> <post>
e.g. telnet localhost 11211

  • stats items to to view information about items, broken down by slab.
  • stats cachedump <slab> <limit> e.g. stats cachedump 1 100 to to view contents of slab.
  • get <key> e.g. get article_1 to view data stored in an item.
  • delete <key> e.g. delete article_1 to delete an item from the cache.
  • flush_all to flush the cache.

memcached NewCommands
memcached protocol

CodeIgniter quick setup quide

October 1st, 2010

Create following directory structure:

/var/www/project
/var/www/project/public
/var/www/project/public/static

Extract CodeIgniter_x.x.x.zip to /tmp

mv /tmp/CodeIgniter_x.x.x/index.php /var/www/project/public
mv /tmp/CodeIgniter_x.x.x/system/application /var/www/project/application
mv /tmp/CodeIgniter_x.x.x/system /var/www/project/system

Edit /var/www/project/public/index.php as follow:

< $system_folder = “system”;
> $system_folder = dirname(dirname(__FILE__)) . ‘/system’;

< $application_folder = “application”;
> $application_folder = dirname(dirname(__FILE__)) . ‘/application’;

Edit /var/www/project/application/config/config.php as follow:

< $config['base_url'] = “http://example.com/”;
> $config['base_url'] = ‘http://project’;

< $config['index_page'] = “index.php”;
> $config['index_page'] = ”;

Example apache.conf

<VirtualHost *:80>
  ServerAdmin webmaster@http://project
  ServerName project
  DocumentRoot /var/www/project/public
  <Directory /var/www/project/public>
    Options FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    RewriteEngine on
    RewriteBase /
    RewriteCond $1 !^(index\.php|static)
    RewriteRule ^(.*)$ /index.php/$1 [L]
  </Directory>
  ErrorLog /var/log/apache2/project-error.log
  LogLevel warn
  CustomLog /var/log/apache2/project-access.log combined
</VirtualHost>

If everything went fine you should now see a welcome message.

Disable DPMS and screensaver on Linux

August 18th, 2010

This is how you can easily disable display power management and screensaver functions on Linux.
Useful if you wish to watch videos while videoplayer doesn’t support automatic dpms disabling.

Files nodpms.sh/yesdpms.sh for disabling/enabling dpms are also available on scripts.

Create a file nodpms.sh with following content

#! /bin/sh
xset s off -dpms

To disable display power management just run: sh ./nodpms.sh

xset is a user preference utility for X.
The “s” option lets you set the screen saver parameters.
“off” simply turns the screen saver off.
“-dpms” disables Energy Star mode.
UNIX man pages: xset(1)