← Older posts
Newer posts →
Using and Installing Greasemonkey Scripts
Posted on April 4, 2012 by daniel
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
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
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
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
Changing Symfony Routing Requirements
Posted on February 28, 2012 by daniel
One of my favorite features of Symfony is the routing sub-system. It allows for very flexible routing rules. On a project I have been working on, I have been tweaking the routing requirements in Symfony. One really nice feature is the ability to define your own routing classes.
homepage:
url: /
class: sfRequestHostRoute
param: { module: static, action: show, content: index }
requirements:
sf_method: [get]
sf_host: www.example.com
The above route will only match if the HTTP method is GET and the host is www.example.com.
To see how sfRequestHostRoute works, see this post.
However, I wanted to take it a step farther. I wanted to change the default class from sfRoute to sfRequestRoute (or some similar custom class). Sadly, factories.yml has no such option. Nevertheless, prodigitalson from stackoverflow.com pointed out a good second class solution. By using YML references, you can achieve something quite similar:
homepage:
url: /
class: &defRouteClass 'sfRequestHostRoute'
param: { module: static, action: show, content: index }
requirements:
sf_method: [get]
sf_host: www.example.com
routeTwo:
url: /someurl
class: *defRouteClass
param: {module: mymod, action: myaction}
requirements:
sf_method: [post]
sf_host: sub.example.com
Posted in 1.4, PHP, Symfony
|
Tagged factories.yml, PHP Framework, routing, routing.yml, sample code, Symfony, YML
|
Leave a comment
Mantis Bug Tracking Software Review
Posted on February 24, 2012 by daniel
Lately I have been playing around with a few different bug tracking programs, on of which is Mantis. Bugzilla is the biggest player in the bug tracking arena, but Mantis has its own niche.
Install
After an hour of messing around with an Ubuntu Server trying to install bugzilla, I was quite annoyed, and still hadn’t solved all the dependency problems; not exactly a painless install. Mantis, on the other hand, took only a few minutes to install.
User Interface
Mantis can’t be called pretty. It gets the job done, but not a lot of effort has been spent on eye-candy. On the other hand, the interface gives me just what I need. It shows me what bugs I need to work on and lets me modify and assign them. Although its ugly, it shows me what I want to see without wasting space. However, configuring mantis is a task that would be quite daunting if I wasn’t a developer. It involves manually editing php files to set certain settings. Many settings are also editable via a user interface as well, but it is very clunky.
Features
Mantis has a very good feature set. Understanding how to configure them can be real headache, but chances are, it can do it. It includes roadmaps, change logs, issue assignment, email notifications, user registration, and many more features. However, good luck enabling some of them.
Summary
I am content with Mantis, but unless your a developer, you will probably get a few headaches from using it. I would still like to give bugzilla a go, but the install process has given me way too much trouble.
Posted in Uncategorized
|
Leave a comment
Firefox Mobile to get a Speed Up?
Posted on February 23, 2012 by daniel
Having used Firefox on an android phone, I have been less than impressed. Although I love Firefox, the mobile version takes forever to load and leaves my phone laggy while running. Although I have kept it installed, I only use it when the default android browser doesn’t suffice. However, it looks like Firefox mobile might be getting a speed up. I ran across this article which indicates that Firefox is redesigning their mobile version to use native android libraries to achieve much faster start up times. I don’t want to get too hyped-up, but a viable Firefox browser for the android would be excellent.
Posted in Web Browsers
|
Tagged android, firefox, open source, web browsers
|
Leave a comment
Retrieving and Displaying Netsuite Address Information
Posted on February 21, 2012 by daniel
Adam Haeder requested to see some sample code for accessing address information via the Netsuite Webservices API. So here it is:
<?php
//$customer is nsComplexObject retrieved from a search or a get.
if (isset($customer->nsComplexObject_fields['addressbookList'])) {
$CustomerAddressbookList = $customer->getField('addressbookList');
$addresses = $CustomerAddressbookList->getField('addressbook');
foreach ($addresses as $CustomerAddressbook) {
$city = $CustomerAddressbook->getField('city');
$state = $CustomerAddressbook->getField('state');
$nsCountry = $CustomerAddressbook->getField('country');
$zip = $CustomerAddressbook->getField('zip');
$street = $CustomerAddressbook->getField('addr1');
$street2 = "";//filled in later
$attention = $CustomerAddressbook->getField('attention');
$phone = $CustomerAddressbook->getField('phone');
if ($phone === null) {
$phone = $customer->getField('phone');//if the address didn't have a phone, use the customer one
}
$nsID = (int) $CustomerAddressbook->getField('internalId');
$defaultShipping = (bool) $CustomerAddressbook->getField('defaultShipping');
$defaultBilling = (bool) $CustomerAddressbook->getField('defaultBilling');
if (isset($CustomerAddressbook->nsComplexObject_fields['addr2'])) {
$street2 = $CustomerAddressbook->getField('addr2');
}
$addressee = $CustomerAddressbook->getField('addressee');
}
}
?>
Posted in Netsuite PHPToolkit, PHP
|
Tagged api, backend, Developing with Netsuite, netsuite, PHP, php toolkit, sample code
|
1 Comment
Jquery Validation Plugin with multiple forms
Posted on February 20, 2012 by daniel
I love using the Jquery Validation plugin on my html forms. It makes frontend validation very easy and painless. However, today I noticed a strange problem, when I was pressing the submit button on a form, it was requiring fields to be filled out on a different form on the page. Thankfully the fix was easy. I was using the following code which worked fine for a single form:
$('form.validateMe').validate();
However, apparently if you have more than one form on the same page that requires validation, the validation plugin does not handle the jquery collection correctly. However, that can easily be fixed by using the each() method:
$('form.validateMe').each(function(){
$(this).validate();
});
This second method will work properly with multiple forms on a single page.
Thanks to Joern Zaefferer for information on the fix.
Posted in Html, JavaScript, jQuery, Plugin
|
Tagged data validation, forms, JavaScript, jQuery, sample code
|
Leave a comment