Absolutely Tech

[HowTo] Remove admin bar from wordpress 3.1

The new admin bar in wordpress 3.1 is one good feature to have but sometimes its unwanted. For example you might already have some other kind of top bar with which admin bar may interfere. You can remove the admin bar by putting the following code in /wp-content/YOURTHEME/functions.php:

if(function_exists('show_admin_bar')){
	show_admin_bar(false);
}

[SOLVED] ‘Error at offset’ error in unserialize()

I came across this weird error in unserialize() where it refused to unserialize the serialized data. After hours of trying different things to solve it, finally converting the encoding worked.

The solution to the problem is to use the following function instead of unserialize():

function safe_unserialize($str){
       return unserialize( trim( mb_convert_encoding( $str,'auto','UTF-8' ) ) );
}

Cheers!

[SOLVED] Error “undefined reference to `libiconv_open’” while compiling

I was trying to compile sphinx server from source but I go the following errors on executing make

undefined reference to `libiconv_open’
undefined reference to `libiconv’
undefined reference to `libiconv_close’

To fix the error, you can compile without iconv (multiple encoding support) support. Use the following commands to compile. You can add more parameters as per your requirements.

./configure --without-iconv
make CFLAGS=-liconv
make install

I hope that helps

[SOLVED] kernel_thread_helper+0×7/0×10 during Ubuntu boot process

Recently, I tried installing Ubuntu on my friend’s computer. I used Maverick’s Live CD but the boot process stuck at kernel_thread_helper+0×7/0×10. I noticed a huge list of acpi errors above this message and figured it was somehow related to ACPI. To solve the problem I simply turned of ACPI.

Solving the problem in Live CD:
Insert live cd, and before the Ubuntu tries to boot into it press Esc repeatedly until you get to Ubuntu menu. Press F6 and select acpi=off and press enter. You can now press Esc again to close this sub-menu and press ‘Enter’ to boot into Live CD. This time your boot process should complete without any errors.

Solving the problem in installed system:
(Once you install Ubuntu using Live CD, you have to follow the following steps to fix this problem in your installation.)
1. In the grub menu, press ‘e’. Search for ‘quiet splash’ and add ‘acpi=off’ (without quotes) after that to make it look like ‘quiet splash acpi=off’. You’ll be able to boot in now.
2. Go to Applications->Accessories->Terminal
3. Execute:

sudo gedit /etc/default/grub

4. Find the line which says GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash” and change it to the following:
GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash acpi=off”
5. Exit gedit.
6. Execute:

sudo update-grub

7. Restart. This time you don’t have to edit anything. Ubuntu should boot without any issues.

Comments and suggestions are more than welcome.

Undo recent facebook style changes

Recently facebook made its font smaller. It worried lots of people with weaker eye sight. The font looks ugly as well. They reduced it all the way to 11px from 13px. And changed its color to #000 from #333. I made a quick greasemonkey script as it works cross-browser to fix the issue until facebook does something about it.

You can install the script from the following link:
http://userscripts.org/scripts/show/89552

Google Chrome: Chrome doesn’t need any extension for this to work. It’ll install the script right away.
Firefox: You need to install greasemonkey extension from https://addons.mozilla.org/en-US/firefox/addon/748/

Opera: It has its own Userjs API. This script might work on Opera. However, it has not yet been tested.

I don’t recommend using any version of IE, hence no instructions for that.

[HowTo] Use locate command and updatedb to search all partitions

Updatedb command by default does not include /media path for updating its database. You can change the settings in /etc/updatedb.conf so that it starts indexing other partitions too.

sudo gedit /etc/updatedb.conf

In the PRUNEPATHS setting, remove /media. Save the file and run

sudo updatedb

This will index all your files from /media folder. Make sure the partitions are mounted.

Cheers!

[Solved] apt-get “is to be installed” errors in Ubuntu

This class of error means the dependency is of different version than required. I tried to install deluge-console but it gave me the following error:

deluge-console : Depends: deluge-common (= 1.3.0-0ubuntu1) but 1.3.0-1~getdeb1 is to be installed

The error is not that self-explanatory. Here the deluge-common version required by deluge-console is 1.3.0-0 but 1.3.0-1 is installed. This means that I have newer version of a dependency required by the application I am trying to install.

Fortunately, you can force the version in apt-get:

sudo apt-get install deluge-common=1.3.0-0ubuntu1

I forced an older version, downgrading the package. This fixed the error for me and I could successfully install deluge-console after that.

This method can be applied to fix problems in other applications as well.

Cheers!

[Solved] Mp3 not playing on Amarok

After upgrading to Maverick, somehow Amarok stopped playing Mp3. Same thing happened when I upgraded to Lucid from Karmic.

To fix it, install libxine1-all-plugins:

sudo apt-get install libxine1-all-plugins

That fixed it for me!

Cheers!

[HowTo] Suspend Ubuntu from terminal or keyboard shortcuts

When learning to make bash scripts, at one point or other you’d like to know how to suspend your computer from terminal. Well, there are quite some methods available for Ubuntu. You can choose whatever suits your needs. I prefer method 3 (look below).

Method 1:

sudo sh /etc/acpi/sleep.sh force

Method 2:

sudo pm-suspend

This command might not be available in older versions of Ubuntu. It works perfectly fine on Lucid and Maverick.

Method 3:

This command does not require sudo so it might come in handy. For example, you can map it to a keyboard shortcut for easy access.

dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

One thing to notice here is none of the commands I mentioned here will ask your password on resuming. For that you’ll have to lock your computer before suspending. You’ll have to use gnome-screensaver-command --lock before suspending to lock the computer

Create a suspend script:

Open a new file in gedit:

sudo gedit /usr/bin/suspend-comp

Copy and paste the following code and save it:

#!/bin/sh 
sleep $1;
dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

If you want the script to ask for a password on resuming, copy-paste this code instead:

#!/bin/sh 
sleep $1;
gnome-screensaver-command --lock
dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

Add the executable bit:

sudo chmod +x /usr/bin/suspend-comp

Now suspend-comp time-in-seconds can be used in terminal. For example, if I want to have my computer suspended after 20 seconds I can simply type:

suspend-comp 20

Mapping it to keyboard shortcut for easy access:

Go to System->Preferences->Keyboard Shortcuts. Click Add. Type Suspend for Name and suspend-comp 0 in Command field. Click Apply.

Now scroll to the bottom of the list to find Suspend. Click on ‘Disabled’ on the right to ‘Suspend’. Now press any key combination to map the command to it. I used Ctrl+Alt+Shift+s.

Now simply pressing Ctrl+Alt+Shift+s will suspend your computer.

Cheers!

[HowTo] Find number of files inside a folder in Linux

I wanted to find out the number of files inside a folder. I didn’t want the folders to be included in the result.
A blog post on zimbio.com shows us how to do it with ls command which is not only downright inaccurate, it is also slower than what I am going to show you.
I am going to show you how to do it using find command which is extremely powerful once you know how to use it.
Executing the command below will print the number of files (excluding folders) in current directory (including all subdirectories):

find ./ -type f | wc -l

This can be used to find number of directories too:

find ./ -type d | wc -l

You can do more complex counting for example finding out the number of files which are of filesize 1Mb and more.

find ./ -type f -size +1M | wc -l

Finding number of symlinks:

find ./ -type l | wc -l

You can also see number of files accessed within last 1 hour from current directory:

find ./ -type f -amin -60 | wc -l

Here -60 means less than 60 minutes ago.

Only imagination is the limit with what you can achieve using find command.