Archive for March, 2008

Wireless Keyboard with Ubuntu

If you use Logitech Wave wireless keyboard, you might have problem when you use dual boot – Ubuntu/Windows. Now, when you start the PC, the keyboard is recognized because you can go into BIOS without any problem, but when you get to boot loader (Grub), you can’t choose anything, so you might stuck with the first option (Ubuntu). But…of course, you would like to boot from Windows as well. So, the keyboard is dead when you are in Grub.

Solution on how to make your boot loader recognize wireless keyboard:

You should turn on USB emulation in your BIOS. There are no USB keyboard drivers loaded during the time grub is running. USB emulation treats it like a PS/2 keyboard so far as the software is concerned.

No Comments

Make Logitech USB microphone Work on Ubuntu

If you are like me – using Ubuntu operating system and having trouble with new Logitech USB microphone (for instance: AK5370). It shows up in lsusb, and Skype can even see it, but you can’t make a call with it. Same with mhwaveedit. And yes, even if you set the volume to max in KMix.

The solution is to use audacity, make sure you have selected the correct recording device (in this case AK5370) and it is very important to make sure the recording channels is set to 1 (mono), as seen from the /var/log/message output when plugging the microphone in, it does not support stereo (2 channel) recording.

After that, simply make sure your microphone is not muted, and audio recording from it is toggled to ‘on’ – then audacity will record from the microphone with very good quality. I am impressed, though limited to 1 channel might affect you tremendously. I use the microphone for podcasting and basic voice operations so 2 channel recording is not a necessity for me.

3 Comments

Open VCD Using VLC on Ubuntu

If you have installed VLC player. To open a vcd you may type in the terminal:

/usr/bin/vlc vcd://

As you close the terminal, VLC also closes. So how to close the terminal without closing VLC? Well, I can’t figure out how to close the terminal without closing VLC, but there are alternative approaches:

There are two alternative ways:

a. One way is to press Alt+F2, in the prompted box, enter the command we mentioned earlier:

/usr/bin/vlc vcd://

b. Another way is that you can open vcd directly through vlc. Under the ‘Disc’ tag view, under ‘Advanced Options’, just changed the value from vcdx to vcd2. See the screenshot below:

3 Comments

Use htaccess to Deny Access Directory Listing

Don’t have an index in all your directory’s? Many people create a blank index.html file in every directory to prevent directory listing. It’s ok for a small website, but imagine if you have a website that has hundred or thousand directories.

The easiest way is to write a htaccess file, include the following line in your .htaccess file to deny access to all the directory listings, if there is no index file.

Options -Indexes

No Comments

Cook up Web sites fast with CakePHP MySQL Syntax Problem

If you have read the CakePHP tutorial Cook up Web sites fast with CakePHP MySQL Syntax Problem, Part 2 from IBM, you may have encountered a problem at Section 3. Scaffolding -> Setting up the product tables -> Creating tables to hold product information. When you run the following MySQL query:

CREATE TABLE 'products' (
'id' INT( 10 ) NOT NULL AUTO_INCREMENT ,
'title' VARCHAR( 255 ) NOT NULL ,
'dealer_id' INT( 10 ) NOT NULL ,
'description' blob NOT NULL ,
PRIMARY KEY ('id')
) TYPE = MYISAM ;
CREATE TABLE 'dealers' (
'id' INT( 10 ) NOT NULL AUTO_INCREMENT ,
'title' VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ('id')
) TYPE = MYISAM ;

You will get an error message like the one below:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''products' (
'id' INT( 10 ) NOT NULL AUTO_INCREMENT ,
'title' VARCHAR( 255 ) N' at line 1

The syntax error is that all the ‘ in the query should be `, so the following queries will work fine:

CREATE TABLE `products` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT ,
`title` VARCHAR( 255 ) NOT NULL ,
`dealer_id` INT( 10 ) NOT NULL ,
`description` blob NOT NULL ,
PRIMARY KEY (`id`)
) TYPE = MYISAM ;
CREATE TABLE `dealers` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT ,
`title` VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY (`id`)
) TYPE = MYISAM ;

,

1 Comment

Use htaccess to Fake Different File Extension

Sometimes you want to confuse potential hackers by faking your file extension, this may reduce automated hacker attacks. If you have Apache server and you are allowed to write .htaccess file, write the following code in your .htaccess file.

Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^(.+)\.html$ /$1.php [NC,L]

In the example above, it will allow you to refer to your files as example.html instead of example.php

No Comments

Cook up Web sites fast with CakePHP ACL Problem

In Cook up Web sites fast with CakePHP, Part 2: Bake bigger and better with CakePHP by IBM, you may have problems working with Access Control Lists (ACL).

In your app directory the tutorial states within the terminal define your groups with the following code.

php acl.php create aro 0 null Users
php acl.php create aro 0 null Dealers

When you do this you will get the following response:

Could not open input file: acl.php

Now instead of using

php acl.php create aro 0 null Users
php acl.php create aro 0 null Dealers

try the following code:

../cake/console/cake acl create aro root 'Users'
../cake/console/cake acl create aro root 'Dealers'

now you may get an error message similar to the one below:

Fatal error: Class 'String' not found in /mycakelocation/cake/libs/model/datasources/dbo_source.php on line 1455

Now open the dbo_source.php, on line 29, replace

uses('set');

with

uses('set', 'string');

save the file and run the following lines of code again:

../cake/console/cake acl create aro root 'Users'
../cake/console/cake acl create aro root 'Dealers'

Now you are done!

8 Comments

JavaScript – Get Form Checkbox Array Values

When you create a form with checkbox, you may expect people to check on more than one checkboxes, and you may ask: Can I get the group of user checked values? The answer is yes. Checkboxes can be used as arrays and the values can be collected using JavaScript.

Imagine you have the form below:

<form name="form1" onsubmit="return validate(this)">
<input type="checkbox" name="names" value="Tom">Tom
<input type="checkbox" name="names" value="Jef">Jef
<input type="checkbox" name="names" value='Kate'>Kate
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>

You want to get the list of names user checked, this can be done by using the following script:

function validate(form) {
var namelist = "";
with(document.form1) {
for(var i = 0; i < names.length; i++){
if(names[i].checked) {
namelist += names[i].value + "\n";
}
}
}
if(namelist == "") {
alert("select names");
} else {
alert (namelist);
}
return false;
}

A live example can be viewed at: JavaScript Checkbox Array demo

5 Comments

Use htaccess to Deny Access to hidden Files

Filenames beginning with a dot, or dot-files are considered “hidden” by UNIX. Usually, you don’t want to serve those to visitors to your website. Dreamhost already disallows retrieving ‘.htaccess’ and ‘.htpassword’, but you can recursively deny all access to all hidden files by placing into a top-level .htaccess:

RedirectMatch 403 /\..*$

This is useful when, e.g. your website is a Subversion “working copy.”

No Comments

Make Acer Extensa headphone speakers Work on Ubuntu

If you have purchase a Acer Extensa 4620, 5620, 4620Z and have Ubuntu installed. You may encounter one problem: mic/headphone jack/speakers don’t work out of the box. To get audio working, you may need to tweak your system a bit, follow the steps below, and you will work it out!

1. install install linux-backports-modules-generic by running the following command in the terminal

sudo apt-get install linux-backports-modules-generic

2. open audio configuration file by first running the command below in the terminal

sudo gedit /etc/modprobe.d/alsa-base

3. now you may see a chuck of code similar to the one below:

options snd-via82xx-modem index=-2
options snd-usb-audio index=-2
options snd-usb-usx2y index=-2
options snd-usb-caiaq index=-2
...

add the following line of code at the end of the chunk of code:

options snd-hda-intel model=acer

4. double click speaker icon to launch volume control. Make sure under File > Change Device > HDA Intel is selected. After that select “Edit” “Preferences” Then check every device listed. When you close that you should now have Playback, Recording and Options listed in the Volume Control. In Options select “Front Mic”. At this point I could record audio from the Sound Recorder with the built in mic but it was way too loud and distorted so play with the recording levels until it sounds good.

By now, you should have your mic/headphone jack/speakers, everything internal external working!

Related Articles:
Make Acer Extensa 4620Z Wireless Work on Ubuntu

No Comments