Using and Installing Greasemonkey Scripts

Posted on April 4, 2012 by daniel

spacer
As a programmer, I often have need to tweak or examine little bits of a page’s HTML. Although firebug is a great tool and incredibly flexible, sometime it just doesn’t quite fit the bill. When such cases arise, greasemonkey is a great tool. It allows you to write small bits of javascript to run when a given page loads. One example of where this can be very useful is the following. I wanted to check the meta data on several pages on a website. Although I could easily do this with firebug, it would involve opening firebug for every site and then searching for the meta inside the html tab. It would work, but takes more time than I want to spend on ever page. However, with a quick greasemonkey script, I can have my browser display a small div in the bottom corner that prints out the meta info for any site I visit.

To create your own greasemonkey script, simply install greasemonkey, click on the icon and select New User Script. Then you will be prompted for some info about the script.
Name: what ever you want
Namespace: some unique identifier. A domain name you own is a good option
Description: What ever you want
Includes: www.mysite.com/*
Excludes: www.mysite.com/boring/*

After you enter this information, it will prompt you to select your editor and you can start writing your script. After you save, your script will be available in your browser when you refresh the page.

Finally, if you wish to copy your user script to another computer, simply save the script as a .user.js file and then drop and drag it into Firefox. Firefox will then prompt you to install the script and you can use it on the new computer.

Posted in JavaScript | Tagged html, JavaScript, web browsers | Leave a comment

Netbeans PHPUnit Code Completion

Posted on March 15, 2012 by daniel

By default, Netbeans dosen’t do code completion for PHPUnit classes even though it includes support for PHPUnit. Thankfully, adding in the code completion support is very easy. Simply go to Tools>Options>PHP>General and then click “Add Folder” under the Global Include Path section. Then navigate to where your PHPUnit install is located. (on my system, /usr/share/php/PHPUnit). By adding this folder, the PHPUnit classes will be included on all projects. Naturally, if you just wanted this to apply to a single project, you could do something similar by clicking on the project and choosing “properties”.

Posted in PHP | Tagged code completion, netbeans, PHP, PHPUnit, Ubuntu | Leave a comment

PHPUnit require_once(PHP/CodeCoverage… Error on Ubuntu

Posted on March 12, 2012 by daniel

spacer
When trying to install PHPUnit on Ubuntu 11.10, I received the following error:

PHP 38

After some serching, I found the answer was to upgrade my version of pear and then reinstall phpUnit using the Pear installer.

The following commands should fix the problem:
1. Upgrade Pear:

sudo pear upgrade PEAR

2. Install PHPUnit:

sudo pear config-set auto discover 1;
sudo pear install pear.phpunit.de/PHPUnit

Thanks to the PHPUnit website for the answer.

Posted in PHP | Tagged bash, linux, PHP, PHPUnit, Ubuntu, Unit Testing | Leave a comment

Apache /icons directory Index

Posted on March 5, 2012 by daniel

spacer
Generally I like to add Options -Indexes to my apache config files. Naturally I was surprised to find that www.mydomain.com/icons/ was returning a standard apache index. I checked my config files and all the files remove the Index options, so where was this coming from? Finally, I tried greping* the entire /etc/apache2 folder instead of just the “sites-enabled” folder. It turns out that the “mods-enabled/alias.conf” had a reference to it and contained the culprit Options Indexes. Removing this reference fixed the problem.

*I reserve the right to turn unix commands into gerunds.

Posted in Linux, System Administration | Tagged apache, grep, linux, Ubuntu, web server | Leave a comment

Why I like Firefox Better Than Google Chrome

Posted on March 2, 2012 by daniel
spacer

Being a web developer, I use all the common web browsers quite heavily. I have long been a Firefox fan for many reasons, however, Google Chrome has offered some steep competition. Chrome typically launches faster, renders pages faster, and freezes less often. For purely functionality, Chrome wins in my book. However, there is another aspect that I have a hard time getting past. Although Chrome may out perform Firefox, Google is profit driven, where as the Mozilla Foundation is not. Yes, the Mozilla Foundation needs to make money to employee its developers, but many of the decisions that are made by the Firefox development team demonstrate a strong commitment to their users. Take, for example, Firefox’s online bookmark syncing program they launched a while back. Although Firefox could have chosen to store all the users bookmarks in plain text, they chose to encrypt them instead. Not only that, but they encrypted the data before uploading it to their servers. This means that there is no way for Mozilla to access your data. They have protected user’s information so well that even they can’t view it. Although this means if you lose your sync key, your out of luck, it means that you are the only person in the world that can view your information; Mozilla cannot access it. That’s a far cry from Google’s privacy policies. Google already knows far too much about me; I would much rather browse the web with a company that I know will protect my privacy, even against themselves.

Additionally, while Google Chrome is built upon open source software like webkit, Google Chrome itself is not open source. Its free, but not open source. Firefox, on the other hand, is a long time supporter of open source and continues to release all of its source code to the public.

Although Chrome may be the better technical performer, Firefox’s philosophy and design choices still win the day in my book.

Posted in Web Browsers | Tagged bookmarks, encryption, firefox, google, google chrome, security, web browsers | Leave a comment