I’ve been working on a site lately that uses a lot of jQuery. I’m much more familiar with prototype so sometimes I find myself stumped at some of the problems I run into.

I had the site looking beautiful with superfish drop down menu and a nice side slider. Then I opened a page and suddenly superfish was throwing an error:

Error: jQuery("ul.sf-menu").superfish is not a function

My code looked like:

Javascript

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/superfish.js"></script>
<script type="text/javascript">
    jQuery('ul.sf-menu').superfish();
</script>

What baffled me most was that it went from working to not working in zero-to-ten!

After fumbling and useless google searching I finally figured it out. For some reason it was calling the superfish() function before the js/superfish.js file was loaded. There’s an easy fix for that:

Javascript

<script type="text/javascript">
    $(document).ready(function(){   
        jQuery('ul.sf-menu').superfish();
    });
</script>

Tada! Easy to fix: using the ready function on the document.

{ 0 comments }

I recently set up WAMP on one of my computers to host a local MediaWikirepository for personal notes about how to complete frequent / infrequent tasks and to organize the huge desktop directory of ‘notes’.

It’s been very useful and seeing as MediaWiki doesn’t requite you to use HTML in the posts I know I can export everything to human readable text files if need be.

I did occur to me, though, that I may need to put my WAMP server online every now and then to allow access from other machines. I don’t want this wiki of notes to be publicly accessible so I decided on using the .htaccess and .htpasswd file combination on WAMP to protect that directory. For the sake of simplicity we’ll assume you installed WAMP to the default directory (c:\wamp\)

This requires you have the Apache auth_basic_module module enabled.

Create your Password repository: .htpasswd

I chose to add my password file outside the web directory in a new directory called pwds (c:\wamp\pwds\.htpasswd) this way I can ensure it’s not accessibly via HTTP.

To add a user name and password to the .htpasswd file you’ll set it up as

user:password

Some setups require that you store an encrypted version of the password and there are tools online but I’d rather encrypt the value myself. By default WAMP doesn’t encrypt the password since it defaults to the auth_basic_module module which doesn’t require encryption.
You can enable the auth_digest_module module and restart services to use encrypted passwords but that’s a whole other article.

Add your .htaccess File

If you want to password protect everything you’d add the .htaccess file with the following lines to the root of your WAMP directory (c:\wamp\www\.htaccess), otherwise add these lines to an .htaccess file inside of the directory you want to protect.

AuthUserFile c:\wamp\pwds\.htpasswd
AuthName "Members Only"
AuthType Basic
require valid-user

The .htaccess file acts recursively. It will directly effect sub directories within the directory it is places. That’s why adding it to the root directory will password protect all directories

Login

Now when you try to access anything in the directory you just places your .htaccess file you’ll be prompted for a user name and password. There is no additional code required to create this login.

Learn More

{ 3 comments }

Getting Yesterday’s Date in PHP

July 2, 2009

It’s a blessing and a curse the way there are so many different methods to calculate things.

For instance calculating or retrieving yesterday’s date in PHP: I came up with 4 quick ways to calculate it.

I always remember method 1, using mktime() but decided to benchmark each of them to see which method of calculation is [...]

Read the full article →

Where the Heck Have I Been??

February 20, 2009

Just letting y’all know that LearnMorePhoto.com has launched and will be hosting all of blog.ninedays.org’s old photography related posts. This is an exciting time for us and we’re excited to hear your feedback.

Read the full article →

Reviewing Ninedays Blog – Traffic Questions

January 2, 2009

Part two of a year end review inspired by pro blogger.

Read the full article →

Reviewing Ninedays Blog – General Questions

December 31, 2008

Part one of a year end review inspired by pro blogger.

Read the full article →

Free iPhone, Storm or G1 from Chitika

December 15, 2008

Chitika wants you to win a new fancy phone- iPhone, Android or Storm – take your pick. Just run Chitika with AdSense creatively and enter the contest!

Read the full article →

Clipboard Express – Wordpress Plugin – New Release!

December 11, 2008

Two weeks ago I began using the WordPress Plugin SVN repo to create a WP plugin for work. I also registered one of my favorite plugins as well: Clipboard Express.

Over the past few days I’ve finalized the 1.2 release of Clipboard Express in reparation to add it to the WordPress Plugin directory. It’s [...]

Read the full article →

7 Ways to Find an Up and Coming Bloggers

December 4, 2008

Seven suggestions and tools to help you find the next big thing in blogging for your niche. It’s important know who the big mouths in your niche are and to make contacts and relationships with other bloggers early on so that you can build your readership and network of personal contacts. You want to be able to say you knew them [the big mouths] when…

Read the full article →

Has My Absence Made Your Heart Grow Fonder?

December 4, 2008

Busy with the noew job, learning and getting a new site set up for all my top posts from the Ninedays Blog. Are you ready? 2009 is bound to be my biggest year ever.

Read the full article →