Archive

Archive for May, 2010

PulseAudio and lirc [Update]

May 27th, 2010 No comments

Changing the system volume with a lirc enabled remote can be a pain in the arse if you don’t know what to look for. If you do, it’s quite simple:

There is a package called ‘pulseaudio-module-lirc’ (PulseAudio’s Wiki for module-lirc) that contains the volume control module for the PulseAudio sound server.

Install the package via yum

# yum install pulseaudio-module-lirc

and enable it

# echo "load-module module-lirc" >> /etc/pulse/default.pa

Here is a sample ~/.lircrc entry configured to forward signals to PulseAudio. Note that you may have to change the remote name and button names to match those in you /etc/lirc/lircd.conf.

begin
   remote = [your remote name]
   prog = pulseaudio
   config = volume-down
   button = [your vol_down button name]
   repeat = 0
end

begin
   remote =  [your remote name]
   prog = pulseaudio
   config = volume-up
   button = [your vol_up button name]
   repeat = 0
end

begin
   remote =  [your remote name]
   prog = pulseaudio
   config = mute-toggle
   button = [your mute button name]
end

Available configs include: volume-up, volume-down, mute, mute-toggle and reset.

Eventually, you have to reload PulseAudio:

# killall pulseaudio && pulseaudio -D

Update:

If you happen to have multiple PulseAudio sinks, you may want to modify /etc/pulse/default.pa like this

[...]
load-module module-lirc sink=[your sink name]
[...]

where you can get the sink name from PulseAudio manager ‘paman’ (flip to the ‘devices’ tab, and copy the name of the sink that you want the lirc module to control).

Categories: Uncategorized Tags: , ,

Java plugin for Firefox 3.6

May 26th, 2010 No comments

Since Mozilla dropped support on OJI (Open Java Virtual Machine Integration), the classic java plugin file javaplugin-oji.so doen’t work anymore for Firefox versions >3.6. Starting in Firefox 3.6, Mozilla will only support the standard NPAPI and NPRuntime interfaces.

However, a ‘Next-Generation Java plugin’ (that’s what Sun calls it) is available in Java version 6 update 10 or newer and supports the NPAPI and NPRuntime interfaces.

Installation is quite simple. Remove the symbolic links to libjavaplugin_oji.so from the Firefox plugins directory and replace it with to libnpjp2.so:

cd ~/.mozilla/plugins/
rm -f libjavaplugin_oji.so
ln -s <JRE>/lib/i386/libnpjp2.so . 

where <JRE> is the path to your Java runtime environment.

Resources:
http://java.sun.com/javase/6/webnotes/install/jre/manual-plugin-install-linux.html

Categories: Uncategorized Tags: ,

Netboot CentOS using Attansic L1 Gigabit Ethernet

May 16th, 2010 3 comments

To update the initrd.img to load additional drivers early in the boot process, normally you would simply run /sbin/mkinitrd and let the script do the work. But what if the initrd.img used during the installation of CentOS lacks an important driver? Maybe you want to netboot CentOS, but the initial ramdisk CentOS provides doesn’t have the right modules for you NIC.

This article gives an example, how to modify the initrd.img to include the drivers for the Attansic L1 Gigabit Ethernet Adapter by hand. (If you just want to know, how to get CentOS working with the L1 without caring about netboot etc., have a look at CentOS and Attansic L1 Gigabit Ethernet)

Read more…

Categories: Uncategorized Tags: ,

Setting up a tftp boot environment for Fedora

May 13th, 2010 No comments

I already wrote a little article, how to boot a FreeDos via PXE. Of course, you can boot Fedora (or CentOS) in like manner.
Read more…

Categories: Uncategorized Tags: ,

Extract single file from tar archive

May 12th, 2010 No comments

Sometimes, extracting a whole tar archive can be a waste of time (and temporarily disk space).

To extract just a single file, you can use

tar -x file -zf archive.tar.gz -C /tmp/

This extracts the file file to /tmp/


Of course, most of the time the relative path to the file is not as simple as in the example above:

tar -x path/to/file -zf archive.tar.gz -C /tmp/

This creates the file /tmp/path/to/file.


To avoid the creation of the file’s relative path (or parts of it) in the target directory, use the switch --strip-components

tar -x path/to/file -zf archive.tar.gz -C /tmp/ --strip-components=2

This creates the file /tmp/file


And finally, you can use stdout redirection to achieve the same result

tar -x path/to/file -zf archive.tar.gz -O >/tmp/file

or even shorter

tar xfz archive.tar.gz path/to/file -O >/tmp/file
Categories: Uncategorized Tags:

WordPress myStat plugin breaks rss feed

May 11th, 2010 No comments

I recently installed myStat to keep track of this blog’s rapidly increasing number of readers. Unfortunately, the plugin break the rss feed. The problem is the plugin’s myStat_footer() function, which does not check if the page is a feed before deciding to insert the myStat footer image into the page code.

To fix myStat v2.6, locate line 475 in mystat.php and change the myStat_footer() function

function myStat_footer() {
    global $cmn;
    if($cmn->getParam("myStat_debug")==1){$cmn->setDebug('FOOTER LOAD');};
    echo "<img style=(...);
}

like this

function myStat_footer() {
    global $cmn;
    if($cmn->getParam("myStat_debug")==1){$cmn->setDebug('FOOTER LOAD');};
    if (!is_feed()) {
        echo "<img style=(...);
    }
}

Resources:
http://wordpress.org/support/topic/325426

Categories: Uncategorized Tags: ,

Omnikey CardMan 4000 and pcsc

May 10th, 2010 No comments

There are basically two ways of getting the Omnikey CardMan 4000 to work: You can either use the original driver from HID (without CT-API support) or the free version from OpenCT
Read more…

Categories: Uncategorized Tags: ,

SyntaxHighlighter Evolved and line-height

May 9th, 2010 No comments

As you probably know, I’m using SyntaxHighlighter Evolved to post syntax-highlighted code. Some people mailed me, that in some of my posted code the underscores are not visible (although copy&paste works). Well, the culprit is the line-height attribute of the SyntaxHighlighter Evolved cascading stylesheet:

.syntaxhighlighter,
.syntaxhighlighter div,
.syntaxhighlighter code,
.syntaxhighlighter table,
.syntaxhighlighter table td,
.syntaxhighlighter table tr,
.syntaxhighlighter table tbody
{
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	outline: 0 !important;
	background: none !important;
	text-align: left !important;
	float: none !important;
	vertical-align: baseline !important;
	position: static !important;
	left: auto !important;
	top: auto !important;
	right: auto !important;
	bottom: auto !important;
	height: auto !important;
	width: auto !important;
	line-height: 1.21 !important;
	font-family: &quot;Consolas&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Courier New&quot;, Courier, monospace !important;
	font-weight: normal !important;
	font-style: normal !important;
	font-size: 1em !important;
	/*min-height: inherit !important; *//* For IE8, FF &amp; WebKit */
	/*min-height: auto !important;*/ /* For IE7 */
	direction: ltr !important;
}

Simply increasing the line-height from the default 1.1em to 1.21em in wp-content/plugins/syntaxhighlighter/syntaxhighlighter/styles/shCore.css did the trick.

Categories: Uncategorized Tags: ,

log4j performance

May 6th, 2010 No comments

Log4J is the current de facto standard not only in open source development. It claims to be fast and flexible: speed first, flexibility second. But there are some pitfalls when it comes to the crunch.

The costs of a log request consists of a method invocation and an integer comparison. This is typically about 1-20ns (depending on your processor) per call. However, this does not include the “hidden” costs of parameter construction.
A simple example:

logger.debug("Value: " + x*y);

Regardless of whether the message will actually be logged or not, the parameter construction will cause additional costs. These costs of parameter construction can be quite high and depend on the size of the parameters involved.

To avoid the parameter construction costs:

      if(logger.isDebugEnabled() {
        logger.debug("Value: " + x*y);
      }
  

This will not incur the cost of parameter construction if debugging is disabled. On the other hand, if the logger is debug-enabled, it will incur twice the cost of evaluating whether the logger is enabled or not: once in debugEnabled and once in debug. This is an insignificant overhead because evaluating a logger takes about 1% of the time it takes to actually log.

So if speed is a real issue, you should double-check your logging statements for “hidden” costs.

Resources:
http://logging.apache.org/log4j/1.2/manual.html

Categories: Uncategorized Tags: ,