Categories
Computers Linux

Acerfand crashes Acer Aspire One 110

I have an Acer Aspire One 110 Ab that I have upgraded with 1 GB RAM (for a total of 1.5 GB) as well as upgrading the BIOS to version 3309.

Before upgrading the BIOS, which was done in an attempt to improve the stability of 802.11 networking, the acerfand program worked wonders to keep the fan running as little as possible.

Once I upgraded the BIOS to 3309 the acerfand program no longer worked. Instead of turning the fan off the fan was running at full speed for a second every other second.

On March 14th, version 0.07 of acerfand was released and I tried it out in the hope that it would fix the fan issue for by BIOS version. While it did turn off the fan, it caused the computer to reboot after a few minutes. Clearly, this was even worse than the alternative.

I did some trial and error and changed the value 0x20 to 0x21 (two places) for the 3309 specific values. In other words, roughly half-way down in the file, my acerfand file now looks like this:

"${BIOS_VERSION_3309}")
	#change: handle 3309 seperate 0xAF -> 0x20
	R_FAN=55
	R_TEMP=58
	FAN_CMD_OFF=21
	FAN_CMD_AUTO=00
	RAW_FAN_STATE_OFF="0x21"
	;;

This has completely solved the issue. The fan now stays off as long as the temperature is below 70 degrees Celsius. The rest of the time (which is virtually always) it is dead silent. Case closed. For now.

Categories
Computers Mac

OS X panics when inserting USB memory

Suddenly my Macbook started crashing whenever I inserted a USB memory stick. Not just crashed – it completely froze.

iousbfamily-crash

The problem report report listed a module called IOUSBFamily and I had a vague idea that I had changed that some time back for something that had to do with my iPhone.

iousbfamily-report

It turns out the solution to the problem was rather simple. Just log onto Apple Developer Connection and search for IOUSBFamily and whatever version of OS X you are running. In my case I searched for “IOUSBFamily 10.5.6”.

Download the Mac OS X USB Debug Kit file for your version of OS X. The .dmg file will include the kernel extension with logging enabled as well as the standard one. Install the one without “log” in the file name. Then restart your computer. The problem should now be solved.

Categories
Computers

Count number of bits in a Ruby integer

How would one count the number of set bits in an integer? If it was a C/C++ application I guess I would do a for-loop and shift out the bits and keep a running sum. I would be hard pressed to do it in less than three lines of code and would probably do it in five to include the curly braces.

Given the same problem and having to find a solution in Ruby I came up with this:

v.to_s(2).split(//).inject(0) { |s,i| s + i.to_i }

In other words; first convert the integer to a binary string and split the string into an array. Then use the inject method to start with zero (remember even numbers are objects in Ruby) and iterate over the array with a code block, adding each digit in the binary string to get the total sum.

Categories
Computers Linux

Target fix for Statpress Reloaded

Statpress Reloaded by Manuel Grabowski is a nice and simple plugin that helps to keep track of the hit rate to WordPress blogs and is something I personally use it for this site.

statpress

Apart from the fact that the plugin is a bit slow it miscalculates the monthly target hit rates. This has been mentioned to the plugin maintainer but until that fix gets added, here is a short description and fix.

The following sections in statpress.php are repeated in four places and is used to normalise the number of hits so far this month over the entire month.

/ date("d", current_time('timestamp')) * date('d', mktime(0, 0, 0, date('m', current_time('timestamp'))+1, 0, date('Y', current_time('timestamp'))))

However, this uses entire days which leads to incorrect results. The error is more predominant early in the month and early in the days.

I have replaced the above segment (four instances) with this:

/ (time() - mktime(0,0,0,date('m'),date('1'),date('Y'))) * 86400 * date('t')

This uses seconds since the beginning of month as the basis for normalisation which is more precise. It is not perfect – among other things it will fail exactly on midnight on the first of each month due to a divide by zero.

Categories
Computers Mac

Messenger for Mac signing out each night

Every night at precisely 01.00 CET (00.00 GMT) Messenger for Mac signs me out. When this happens a manual intervention is required in order to sign back in. I just can’t figure out why this is happening. The error message is “The system is unavailable now so you have been signed out of Microsoft Messenger”. I am running Microsoft Messenger for Mac version 7.0.1.
messenger-signout
messenger-version

Categories
Computers Linux

Increase upload size to Drupal site

If you run a Drupal site and want to upload big files you may have run into the default file size limit of 1 MB. While this is probably fine for most blogs it is way too small for most intranet deployments.

The limit for PHP is by default set to 2 MB for file uploads.

To increase this to 10 MB, add the following to the .htaccess file in your Drupal directory or to the Apache site definition:

php_value upload_max_filesize 10M
php_value post_max_size 20M

More information can be found here.

Categories
Computers Linux

Using Drupal to run an intranet

I have been looking for ways to replace a Sharepoint driven intranet with something else. The driving force behind this has mainly been one of platform compatibility. Sharepoint is great if you use Office and Internet Explorer on Windows. For all other users it is a usability nightmare.

There are lots of hosted or shrink-wrapped solutions for sale but the market of intranet solutions is now so mature that I felt there had to be open source solutions.

I found Alfresco, LifeRay and a few others and installed most of them. I was perplexed, however, by the sheer amount of features that were enabled out of the box. I really prefer something that starts off light and can then expand according to my needs. KnowledgeTree felt lighter but didn’t do much more than document management and I knew I also wanted a wiki as well as forums.

For a while I tried to integrate KnowledgeTree with MediaWiki and phpBB for a best-of-breeds solution. I couldn’t get all of the them to play nicely together and allow users to authenticate using accounts from a Windows Active Directory.

drupalorg

In the end I settled on Drupal. Why? It starts off light but has a truck-load of modules that can be added. I like the structure of the code. And it feels fresh – perhaps almost too light. I would have liked to see some professional free themes targeted for intranets, they would have helped to sell in the concept internally in competition with professional offerings.

The question of the authentication integration with Active Directory was solved very nicely by the module “Webserver authentication” and adding HTTP authentication to the web site in Apache where the web server is configured to use the bindings provided by Samba‘s WinBind. The only thing to remember is to set the Drupal administrator to the the same login name as the administrator in the Windows domain. After that you should disable the log out menu option in Drupal. The only thing remaining is to add some Javascript code to be able to provide a link to make the browser forget the cookie in order to force a relogin.

Categories
Computers Mac Music

Saving a clip from YouTube

It’s gearing up to be a very nice spring for all die-hard fans of Depeche Mode. There are clips on YouTube of their next single – Wrong – and it totally rocks!

dm-wrong

So, how to get this onto my iPhone to be able to pass the time until April 20th when their next album “Sounds of the Universe” is to be released?

It turns out it to be quite easy. There are a number of Firefox add-ons that claim to be able to download content from YouTube. I imagine YouTube isn’t too happy about people downloading content and keep trying to shut down options to circumvent it. I found that the add-in “Fast Video Download” did wonders. The add-on adds the icon in the bottom-right corner of Firefox in the screenshot above.

isquint

The output from the add-on is the Flash video file with a .flv extension. This then needs to be converted to avi format. Now there are many applications that claim to do this and they all charge around $30-40. iSquint does a terrific job and it is for free. The applications has actually been discontinued but it is still available for download.

Categories
Computers Linux

Accessing an Oracle database from Perl

In the previous post I described how to install the Oracle Database 10g Express Edition on Ubuntu and to add some data. In this article I will show how to access that data from a Perl script.

I assume you already have Perl installed, together with the DBI framework for generic database support. We will need to add DBD::Oracle which is available from CPAN. To install this module, run this as root:

# perl -MCPAN -e shell
cpan> install DBD::Oracle

Two things are worth noting. First, the root user must have the same Oracle environment set as described in the previous article. Just issue ‘source /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh’ to fix that. The second thing to note is that you will most likely get errors during testing of the newly built module which will prevent it from being installed. To override that you will need to add ‘force’ before the command, i.e.:

cpan> force install DBD::Oracle

Now, the groundwork is done and we just need to write the script. Save this in oracle_read.pl and make it executable.

#!/usr/bin/perl -w
use strict;
use DBI;
my $dbh = DBI->connect( 'dbi:Oracle:xe',
      'scott',
      'tiger',
      ) || die "Database connection not made: $DBI::errstr";

my $sql = qq{ SELECT id,name,age FROM persons };
my $sth = $dbh->prepare($sql);
$sth->execute();
my($id, $name, $age);
$sth->bind_columns(\$id, \$name, \$age);

print "List of persons:\n";
while( $sth->fetch() ) {
    print "$name [$age]\n";
}
$sth->finish();
$dbh->disconnect;
Categories
Computers Linux

Oracle under Ubuntu

I am a rather proficient user of MySQL but I recently needed to set up an Oracle database to test against. Since I haven’t worked with Oracle databases in more than ten years it took literally hours to get something up and running. What follows is a description on how to install Oracle XE on Ubuntu 8.10, add a user, create a table and then drop the created schema. Everything will be done from the command line.

Note that this installs the Oracle Database 10g Express Edition. Although free it comes with similar constraints as the Microsoft SQL Server 2008 Express server – maximum 4 GB data, use maximum 1 GB of RAM and run on maximum 1 CPU.

First, add the Oracle repositories by appending the following two lines to /etc/apt/sources.lst

# Oracle Repository

deb http://oss.oracle.com/debian unstable main non-free

Then, we must add the Oracle key to avoid warnings:

wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle -O- | sudo apt-key add -

Now we are ready to install by using apt-get (either run the following as root or prepend every line with sudo)

# apt-get update
# apt-get install oracle-xe oracle-xe-client
# /etc/init.d/oracle-xe configure

The last command will present options to change some default settings. you can probably use most of the defaults. I just changed the HTTP port from 8080 since I already had another service running on that port. Note that the configuration script takes a very long time to finish.

When the script is finished it is possible to access the Oracle web interface at http://127.0.0.1:8080/apex (or some other port if you changed the default). However, it will only be accessible on the local host. If you are installing on a headless remote server like me you can port-forward using SSH:

$ ssh -L 8080:127.0.0.1:8080 user@host

Or, you can remove this limitation as described further below.

Next step will be to add the Oracle environment to your shell. The installation will have added scripts to set up the environment under /usr/lib/oracle/xe/app/oracle/product/10.2.0/. There are actually two scripts: server/bin/oracle_env.sh and client/bin/oracle_env.sh. I don’t think it matters which one but it makes more sense to use the one under ‘server’.

Append this to your .bash_profile file:

. /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh

Then log out and back in – or run ‘source .bash_profile’.

Now it is time to log onto the system:

$ sqlplus system@localhost 

If you would have logged on remotely you would have written ‘sqlplus system@host’ – but we haven’t enabled remote access yet.

Type the password you selected during installation. At the SQL prompt, enter:

> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
> EXIT;

Now it is time to add the first user. Save the following to a file (oracle_create.sql).

-- oracle_create.sql
CREATE USER scott IDENTIFIED BY tiger 
    DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp 
QUOTA UNLIMITED ON users;
CREATE ROLE myrole;
GRANT CREATE session, CREATE table, CREATE view, 
    CREATE procedure, CREATE synonym TO myrole;
GRANT myrole TO scott;
-- Switch user
CONNECT scott@localhost/tiger;
--
CREATE TABLE persons (
	id int,
	name varchar2(32),
	age number
);
--
INSERT INTO persons
	(id, name, age)
	VALUES (1, 'Joe', 35);
INSERT INTO persons
	(id, name, age)
	VALUES (2, 'Mary', 32);

You can then create the user and populate the table by running:

$ sqlplus system@localhost
> @oracle_create
> SELECT * FROM persons;
> EXIT

The ampersand indicates that SQL statements should be read from a file. Since the file ends with .sql the extension does not have to be stated. Please note the connect statement in the SQL file. This means that after that point we will be running as the user scott.

To drop everything we have created run the following:

$ sqlplus system@localhost
> drop user scott cascade;
> drop role myrole;
css.php