Archive for the ‘Internet’ Category

CouchDB and malformed URLs

CouchDB chokes on malformed URLs. This request works in Firefox but not curl or when called from a PHP script. The problem is that the space after the comma in the endkey is not properly encoded. The solution is to remove the space.

localhost:5984/db/_design/forum/_view/postsbak?startkey=["forum/test_page_1"]&endkey=["forum/test_page_1", {}]

Luckily the CouchDB team know about this (Doesn’t gracefully handle malformed URLs) and hopefully will be fixing it soon.

Debian in VirtualBox for local web development

Have you ever wanted to develop your web application locally. Using VirtualBox you can develop with a near clone of your production environment. Giving you a personal sandbox where you can go crazy before you commit to your teams development server.

The first thing we need to do is install virtualbox. Go to the  virtualbox download page and get the software package that appropriate for your platform and run the installer once downloaded. Linux user should be able to install it using their distro’s software management tool. The windows installer will walk you through a couple of steps. For the most part you can use the defaults. Though I always un-check add icon to desktop when I install software.

Go to Debian’s network install iso page to download the stable iso file we will use to install from. Save the file someplace convenient where we can find it later. The Linux distro doesn’t matter, if you can you should use the same as is on your production, staging and testing environments. The more things we keep the same across uses the fewer surprises there will be down the road.

Once we have VirtualBox installed and the Debian iso downloaded we are ready to install. Run VirtualBox and click on the blue starburst to create a new virtual machine. Name the virtual machine something short and easy, no crazy characters, something like local-dev. We can use this name later for the machine name, which will help us keep things straight. Now change the Operating System type to Linux and the version to Debian. Next you can set the memory to 128MB if you only installed the base system. You might need to set the memory to more depending on the amount of software you installed in the virtual machine. Next you should choose to create a new virtual hard drive. What was true with memory will be true here. You don’t need a huge virtual hard drive size, 1.5GB should be enough for a simple install, but the more software you want the larger virtual hard drive you will want to create. I choose to create as small as possible size because I am only using it for web dev testing and it’s not going to actually host any of the source files. Now the virtual machine setup is finished.

Before we install Debian we need to tell the virtual machine to boot from the iso we downloaded. Select your new virtual machine and click on the yellow settings button shaped like a gear. Here we have access to all the options for the virtual machine. We want to click on CD/DVD-ROM, and add a check next to Mount CD/DVD Drive. Then we want to put a dot next to ISO Image File. Now click on the yellow folder with the green up arrow to the right. This will take us to the virtual media manager. While on the CD/DVD Images tab click on the Add icon and navigate to where you saved the Debian iso file. Once it’s added select it and click on the select button. Now click on OK to close the Settings dialog box.

With your new virtual machine selected click on the green start arrow. The virtual machine will now boot from the iso and being to the install process. It’s best to follow the Debian install documentation to get the system installed and up and running. Once the OS is done installing run aptitude and install apache, php and other servers do your liking.

Configure apache, php, et al. in the  We want to make a point of configuring Apache to point to a specific directory, the one we will later mount our source code on.

Now that Debian is installed and our servers are configured we want to switch to host-only networking. You can use Bridge networking too, but I prefer host-only as it keeps a constant IP address for my virtual machine when I move my laptop from location to location. First you must halt the virtual machine before you can edit any of the settings. In the settings dialog choose the Network item and change the Attached to: option from NAT to Host-Only Adapter. The VirtualBox Host only Ethernet Adapter should be selected below it. I also take this time to un-check Mount CD/DVD Drive under the CD/DVD-ROM option. Select OK to close the Settings dialog. Now we are

Now we need to make it easy to access our local server by editing the host file. The host file lets us create alias names for servers. The Linux host file will be at /etc/hosts and the windows host file will be at %SystemRoot%\system32\drivers\etc\

Add this line:

192.168.56.107              local-dev.example.com   local-dev

Where the IP address is the one assigned to your dev server in VirtualBox and local-dev is the host name you want, and example.com is a domain name you want. Really you only need the host name.

You will also have to setup the same host file on the local-dev virtual machine.

Now we want to setup a samba share ( or setup a Windows share) on our host machine that will share the directory our source code is stored in.

Once the share is ready we want to mount the share in our local-dev machine.

Now we have the local-dev maching mounting the source code from the host to the root directory where apache is serving. We can now go to http://local-dev in our web browser and we should see the files as they are served up by apache. Now we can edit our source locally and test the results immediately from the local apache install.

CouchDB on transactions

Homey don’t play that: transactions are a form of locking, and I un-friended locking years ago, for posting too many lame updates to my log files.

CouchDB Implements a Fundamental Algorithm

Twitter Marekting Tools

  1. Hash Tags help people find your tweets on specific topics. They are a way of adding meta-data to your tweet to group tweets of a similar topic together. Use a # mark followed by any word, with no spaces, such as #swineflue. Special search engines like Hash Tags index and organize tags and help spread your tweet around.
  2. TweetDeck is a desktop client that helps you manage twitter. It separates our your general tweets from those you are mentioned in from direct messages. It checks for new tweets on a user adjustable schedule and has a discreet onscreen notification when something new pops up.
  3. Twitter Search do a quick search for your topic to find new users to follow.
  4. bit.ly sure there are a lot of URL shorteners out there, but bit.ly also features link tracking. Sign up for a free account and start collecting metrics on the links you publish in your tweets.
  5. TwitterBerry keeps your up to date when you’re on the run.

Twitter as marketing tool

What do middle seats on airplanes and the current recession have in common? New blog post: http://tinyurl.com/ca35fp

This is a great example from Hugh of using twitter to drive traffic to your blog.

Facebook

old friends become facebook friends as the water that is life slowly overflows our deck and pulls us to her longing embrace.

Forbidden vs Not Found

Don’t just block access to your config files, hide them all together. When an attacker or robot is scouring your website looking for vulnerabilities and finds a wp-config.php file that is forbidden then they still learn that they are dealing with a wordpress install. It might take them a bit longer to attack your site, but they will know a bit about what they are attacking. However if you instead return 404 File Not Found for any config files gleaned for you might be able to throw them off the scent.

RewriteRule ^(.*)config(.*)\.php$ $1config$2\.php [R=404,L]

This code can be put in your .htaccess file and will match any file that has the word config in it and the extension of .php; so this will return 404s for all php config files not just wordpress config files.

HTML5 <section>

The <section> element is new to html5. It is used to carve the page up into different thematic parts. It is used to seperate parts of the page that have different themes or purposes; such as the main content area from the comments from advertising areas of the page. The <section> is Sectioning Content; which defines the
scope of headers, footers, and contact information
; that is it creates a new level of importance for items created within as related to all items contained within the section.

HTML5 DocType

It is time we did away with all the old and ugly DOCTYPES and embraced the future in the HTML5 DocType. Allowing for forward compatibility down the road.

<!doctype html>

There are only two uses for the DocType:

  1. To trigger non-quirks mode (standard mode) to render the web page.
  2. To tell a validator how to check the page for conformance to an HTML level.

Web browsers do not actually check to see if the HTML is written in the version specified by the DocType. They really don’t care. They just want to know which mode to render it in. You can send XHTML strict with an HTML4 strict DocType and it will render the same either way. The only purpose of the DocType for web browsers is to trigger non-quarks mode.

So will browsers reconize the new HTML5 DocType as one that triggers non-quarks mode? The answer is yes. Firefox supports the new DocType as do the most popular browsers. Even Internet Explorer 6 will trigger standards mode when presented with an unknown DocType.

So the new DocType will trigger standards mode, but won’t the browser ignore all the new HTML5 tags? The simple answer it to just not use the new tags and elements or the removed tags or elements. Without using either of those two sets you’ll find that you still have most of the tags that you have used before when coding standard HTML401 or XHTML documents.

By narrowing the tags we use and creating clean markup we can embrace the future standard of HTML. This adoption will pressure browser makes to step up the pace for HTML5 support, and when the new tags become available we will be stragictly posed to easily update our pages simply by adding new elements to our pages.

html5

This blog now validates to HTML5.

Made some changes, now I need to update this.