Friday, December 30, 2011

Solution to Atheros AR9285 Wireless Card - Pinging works, but browsing the web does not.

A few years back I purchased a Compaq CQ62-215DX notebook for $300.00. Based on the AMD V120 CPU, it is all the power you need to watch movies, run microsoft word an surf the web.

Recently I updated some drivers, or I think I did during a routine Windows Update, and afterwards I was unable to surf the web. I was able to ping, but could not retrieve pages for major web sites. Other laptops worked so I knew it wasn't a router issue.

Doing a search yielded plenty of results with people having the same problem.

Windows 7 64-bit Home Edition
Netgear WNDR3700 - has b/g/n and supports 2.5 and 5ghz. 150mbps to 300 mbps.
Compaq CQ62-215DX Atheros AR9285 b/g/n

Step 1: Try all the drivers available for this card

There are about 2-3 driver packages on and the sketchy site.

Link to the Atheros 2011 drivers sp52131.exe
Link to drivers

I probably installed these 20 times and still got no connectivity. Not to mention the Auto Update Installation on Windows 7 home would keep trying to install the old drivers without my permission. (gpedit.msc is not available on windows 7 home which lets you stop this from happening).

Step 2: Found a post with a possible solution

After spending a few days researching, I stumbled upon a post on the hp forums where a user who had an ASUS laptop turned off the Wireless Mode from Auto to b/g and then was able to connect.

Problem is when you go to device properties for your wireless network card you may not have a Wireless Mode setting. I reinstalled all the old drivers to see if there was a wireless mode setting in previous versions and nope, HP did not make these settings available.

Step 3: Look at the .inf files

The next step was to determine where in the registry the advanced settings for the atheros wireless card were located. Long story short I was able to track the location of the registry keys used to configure the device, and I found a bunch of registry settings in the .inf files from the drivers. Next would be to add the registry settings to my Windows 7 registry.


TLDR; Wireless N did not work on the AR9285. Might be hardware, might be drivers. Whatever is I had to turn it off so that I could at least connect to the internet.

I first tried to unpack the driver packages and modify the .inf files so I could get the setup.exe to do this for me. After a few failed attempts I gave up trying to automate key registration, and instead went with hand editing the registry. (yes regedit.exe can blue screen/kill your computer so be careful)

From the .inf file in the we have these settings.

HKR, Ndi\params\NetBand,     ParamDesc, 0,  %WirelessMode%
HKR, Ndi\params\NetBand,
     Base, 0,  "10"
HKR, Ndi\params\NetBand,
     default, 0, "26636"
HKR, Ndi\params\NetBand,
     type, 0,  "enum"
HKR, Ndi\params\NetBand\enum,
"26636", 0,  %WirelessModeAuto%
HKR, Ndi\params\NetBand\enum,
"12",  0,  %WirelessMode11bgOnly%

WirelessMode                 = "Wireless Mode Selection"
WirelessMode11bgOnly         = "802.11b/g"
WirelessModeAuto             = "Auto"

Step 4: Enter these in the registry in the right place - good luck with that

To find where, I did a search for "Adhoc 11n" in regedit.exe. This is one of the settings you can choose for your drivers and it seemed unique enough. I only found two cases of this in my registry so I decided to add the above keys and values next to the Adhoc 11n. One of these had to be the correct settings for my device. Lucky for me the first one I chose happened to be the right one.

This is how your registry should look. (Yeah you can't see the Adhoc 11n, but it's within the htAdhocEnable)

Create a key called NetBand, and add each value as a string. You can compare the format to the shortPreamble above it which is a setting that was installed by the driver. (If you don't trust me look at the .inf file from

Next create a sub key within NetBand called enum. This is where you get to choose Auto or Wireless b/g

After doing this, go to your wireless network card, click properties, configure, advanced and you should now be able to choose b/g or auto.

Set it to 802.11 b/g and hit OK. Your wireless connection will restart and hopefully you will now be able to connect. It did for me. Woot!

NOTE: For those who have a little more time and effort, or maybe someone at HP can figure this out - change the .inf file and add above registry fields so we can configure the Wireless Mode. This would save a lot of people time and effort.

Friday, December 2, 2011

Install 389 in Fedora 16 Starting and Stopping LDAP

Refer to this page for some info about starting and stop the 389 server.

1) To setup the system for testing add an entry into your /etc/hosts such as 

2) To install 389 add the packages to fedora 16.

3) Run the command sudo There is a but that I believe sets up separate ldap servers and not config the entire system including the admin.

4) When it asks for a host, it will give something like Enter

5) Enter the domain.

On mine it asks for dc=com. I entered instead dc=example,dc=com

6) Answer the remaining questions and complete the installation
(If you make a mistake run sudo

7) To connect to 389 as an admin
run 389-console 
Enter User ID: dc=Directory Manager 
Passsword: [whatever u entered during the setup process] Administration 
URL: http://localhost/9830 

If you have problems use the java from sun instead of openjdk.
(google java sun alternatives linux)


Starting and Stop the service.

1) Start the 389 admin service

service dirsrv-admin start

This however starts up the admin portion of 389 and not the ldap server that stores data.

2) Start your 389 ldap service

I usually use service to start and stop my services
sudo service dirsrv@example start

With fedora 16, I'm finding that I'm using systemctl more often

This will also start and stop the dirsrv service
sudo systemctl start dirsrv@example

To start and stop all your ldap services
sudo systemctl start

3) The ldap server does not start on boot.

Current unsure why service dirsrv start does not work.


Sunday, September 4, 2011

rails spork autotest failures repeating endlessly

Rails 3.1
Spork 0.9 rc9
ZenTest (installs autotest binary)
Fedora Linux

After launching spork, and then autotest, any failed tests will continuously get retested by autotest. This is because autotest is looking for changes in file dates and will rerun all tests if it finds a change.


.autotest setup can be found in

Edit ~/.autotest

  Autotest.add_hook :initialize do |autotest|
    autotest.add_exception %r{^\.git}  # ignore Version Control System
    autotest.add_exception %r{^./tmp}  # ignore temp files
    autotest.add_exception %r{^./log}  # ignore log

    # from rails tutorial 201109
    autotest.add_mapping(/^spec\/requests\/.*_spec\.rb$/) do

I had to add the log exception to stop the failure cycle.

rails, devise and how to edit user account profile without providing a password

There are several options on the wiki to update an account information without providing a password

This is due to the fact that devise is asking for the current password for all profile changes. The wiki makes changes to remove password fields or the current password from the form.

The workflow I was looking for was to allow the user to change details such as first and last name without a password. Only when the current password is change is a password required.

rails 3.1
devise 1.4.4
From the Gem

copy the method update_with_password and add it to your user.rb model (or whatever model you're using to store account information)

      def update_with_password(params={})
        current_password = params.delete(:current_password)

        if params[:password].blank?
          params.delete(:password_confirmation) if params[:password_confirmation].blank?

        result = if valid_password?(current_password)
          self.attributes = params
          self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)


Next change the line
result = if valid_password?(current_password)
result = if params[:password].blank? && if params[:password].blank? || valid_password?(current_password) 

Don't check for current password if password is blank, go ahead and update

Sunday, August 28, 2011

Editing Aptana Key Shortcuts and rebinding commands such as open resource

Being used to eclipse pdt, the open resource command is an indispensable feature. You can open files by typing a few letters and matching filenames start appearing.

Conviently it's mapped to Control+Shift+R

Unfortunately, in Aptana, Eclipse and the Rails workspace, two other commands are bound to this same shortcut. Eclipse, being smart, will create a pop up menu with each of these commands and you can select the one you want with the mouse (typing 0,1,2 will do the same).

Anyone trying to keybind, or replace the shortcut will find that none of the Eclipse GUI menus will allow you to change it.

Edit:  One extra step, you need to download the bundle with eclipse in order to view in the Documents dir.
Click on Commands -> Select Rails or Ruby from the menu -> Edit this bundle.

Take note of the other menu items.
Mine were
Run Rake Task 1
Run Focused Unit Test 2
Open Resource 3

Aptana saves all the bundle scripts in this directory

~/Documents/Aptana Rubles/ruby.ruble/commands/

You will find all the aptana scripts *.rb


and change '+R' in

cmd.key_binding = 'CONTROL+M2+R'
cmd.key_binding = 'M1+M2+R'

to '+Y' or another key

Tuesday, July 19, 2011

Renaming Capabilities in Moodle 1.9.x

On the off chance you need to rename moodle capabilities


Here is what you have to do:

1) edit upgrade.php and add two create sql statement

$sql = "UPDATE {$CFG->prefix}capabilities
SET name = 'block/mycustomblock:viewadminpages'
WHERE name = 'block/mycustomblock:viewpages'";

$sql =
"UPDATE {$CFG->prefix}role_capabilities
SET capability = 'block/mycustomblock:viewadminpages'
WHERE capability = 'block/mycustomblock:viewpages'";

2) execute_sql($sql) both of them

3) The last part is that you MUST also change the mycustomblock/db/access.php to include the new capability type. This is because Moodle will compare capabilities in access.php to the ones stored in the database.
a) Moodle will search for new capabilities.
b) Moodle will delete them from the mdl_capabilities table, then add them as a new row.
c) Moodle will then delete the capability from mdl_role_capabilities. (I believe this is to preserve the referential integrity of foreign keys between mdl_role_capabilities.capability and

In access.php

Add :
'block/mycustomblock:viewadminpages' => array(
        'riskbitmask' => RISK_PERSONAL,
        'captype' => 'read',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(

Look at upgrade_blocks_plugins() in blocklib.php for more info.

Tuesday, July 12, 2011

Make Rails Devise Routes Look Better

AKA remap the routes in Rails Devise Authentication

Anyone who explores Devise in their rails app will find that all the generated routes fall under a single path. Since most people choose the User model for saving user information, devise will put all these methods under /users/

rake routes
        new_user_session GET    /users/sign_in(.:format)       {:action=>"new", :controller=>"devise/sessions"}
            user_session POST   /users/sign_in(.:format)       {:action=>"create", :controller=>"devise/sessions"}
    destroy_user_session DELETE /users/sign_out(.:format)      {:action=>"destroy", :controller=>"devise/sessions"}
           user_password POST   /users/password(.:format)      {:action=>"create", :controller=>"devise/passwords"}
       new_user_password GET    /users/password/new(.:format)  {:action=>"new", :controller=>"devise/passwords"}
      edit_user_password GET    /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
                         PUT    /users/password(.:format)      {:action=>"update", :controller=>"devise/passwords"}
cancel_user_registration GET    /users/cancel(.:format)        {:action=>"cancel", :controller=>"devise/registrations"}
       user_registration POST   /users(.:format)               {:action=>"create", :controller=>"devise/registrations"}
   new_user_registration GET    /users/sign_up(.:format)       {:action=>"new", :controller=>"devise/registrations"}
  edit_user_registration GET    /users/edit(.:format)          {:action=>"edit", :controller=>"devise/registrations"}
                         PUT    /users(.:format)               {:action=>"update", :controller=>"devise/registrations"}
                         DELETE /users(.:format)               {:action=>"destroy", :controller=>"devise/registrations"}
             user_unlock POST   /users/unlock(.:format)        {:action=>"create", :controller=>"devise/unlocks"}
         new_user_unlock GET    /users/unlock/new(.:format)    {:action=>"new", :controller=>"devise/unlocks"}
                         GET    /users/unlock(.:format)        {:action=>"show", :controller=>"devise/unlocks"}

Looking at this, I wanted to customize some of the routes so they are located elsewhere in my application. eg. Move the /users/sign_in to /login and /users/sign_up to /signup

Devise and rails routes offers a few methods of doing this which are mentioned on the Devise wiki pages, but the problem I ran into was how the registration controller was mapping over top of the users controller routes.

user_registration POST   /users(.:format)               {:action=>"create", :controller=>"devise/registrations"}
   new_user_registration GET    /users/sign_up(.:format)       {:action=>"new", :controller=>"devise/registrations"}
  edit_user_registration GET    /users/edit(.:format)          {:action=>"edit", :controller=>"devise/registrations"}
                         PUT    /users(.:format)               {:action=>"update", :controller=>"devise/registrations"}
                         DELETE /users(.:format)               {:action=>"destroy", :controller=>"devise/registrations"}
             user_unlock POST   /users/unlock(.:format)        {:action=>"create", :controller=>"devise/unlocks"}

I would like new_user_registration to point to /signup, and user_registration to /signup too. This is cause when the form is submitted, and an error occurs we want the use to remain on the /signup URL. After some help from this post on google groups:

I ended up with these devise routes: /login, /logout, and /signup and it puts some of the registration routes under /register, thereby leaving the user actions for my users controller and not for devise. Pretty now.

devise_for :user, :path => '', :path_names => { :sign_in => 'login', :sign_out => 'logout'}, :skip => [:registration] do
    scope :controller => 'devise/registrations' do      
      get :cancel, :path => 'users/cancel', :as => :cancel_user_registration
      post :create,  :path => 'signup', :as => :user_registration
      get  :new,     :path => 'signup' , :as => :new_user_registration
      get :edit,    :path => 'users/edit', :as => :edit_user_registration
      put :update, :path => 'users/edit', :as => :update_user_registration
      delete :destroy, :path => 'users'
rake routes
cancel_user_registration GET    /users/cancel(.:format)   {:action=>"cancel", :controller=>"devise/registrations"}
       user_registration POST   /signup(.:format)         {:action=>"create", :controller=>"devise/registrations"}
   new_user_registration GET    /signup(.:format)         {:action=>"new", :controller=>"devise/registrations"}
  edit_user_registration GET    /users/edit(.:format)     {:action=>"edit", :controller=>"devise/registrations"}
update_user_registration PUT    /users/edit(.:format)     {:action=>"update", :controller=>"devise/registrations"}
                 destroy DELETE /users(.:format)          {:action=>"destroy", :controller=>"devise/registrations"}
        new_user_session GET    /login(.:format)          {:action=>"new", :controller=>"devise/sessions"}
            user_session POST   /login(.:format)          {:action=>"create", :controller=>"devise/sessions"}
    destroy_user_session DELETE /logout(.:format)         {:action=>"destroy", :controller=>"devise/sessions"}
           user_password POST   /password(.:format)       {:action=>"create", :controller=>"devise/passwords"}
       new_user_password GET    /password/new(.:format)   {:action=>"new", :controller=>"devise/passwords"}
      edit_user_password GET    /password/edit(.:format)  {:action=>"edit", :controller=>"devise/passwords"}
                         PUT    /password(.:format)       {:action=>"update", :controller=>"devise/passwords"}
             user_unlock POST   /unlock(.:format)         {:action=>"create", :controller=>"devise/unlocks"}
         new_user_unlock GET    /unlock/new(.:format)     {:action=>"new", :controller=>"devise/unlocks"}
                         GET    /unlock(.:format)         {:action=>"show", :controller=>"devise/unlocks"}  

Edit: A quirk with devise is that the update_user_registration uses the same action="{URL}" as user_registration no matter what is defined in the routes. This causes the action for update_user_registration to send the put to /signup when we want it to go to /user/edit. The solution is to edit the registration/edit.html.erb and change
:url => registration_path(resource_name)
:url => :update_user_registration


Monday, January 17, 2011

Drupal SOAP with NuSOAP and this error message You must specify a name when you register an operation

While looking into Drupal and Soap I ran across this choice message

You must specify a name when you register an operation

I'm using:

Drupal 6.20
Services Module 6.x-2.4 - -
Soap Server 6.x-1.2-beta1 -
w/ NuSOAP -

The Soap Server 6.x-3x-dev has a warning: Prototype in active development - not ready for production use without careful scrutiny and testing, so I went with this older soap module dated from back in 2008. This older version uses nusoap, and is likely a lot slower than the standard php soap functions introduced in 5.x

After receiving the above message, I also ran across this patch and ran it against soap_server/soap_server.module. Seems like the soap module has already been patched to the most recent one.

In the file drupal module - soap_server.module do a find and replace for
ie single quote, pound character, and replace it with just a
single quote.

The soap wsdl can then be retrieved.