Firefox session restore: Just a little bit sweeter

December 19, 2009

The new Firefox session restore functionality that popped up a couple of updates ago is quite nice and has introduced a slight improvement to my workflow.

I don’t know about most of you but the minimum Firefox windows I have open is four and the aggregated number of open tabs is near a dozen. And that’s just at start up. After a few hours, not mention a day or two, I may have 30, 40, 50 tabs open in the four windows. Probably not more than 50 but I don’t know for sure.

This hyper surfing results from researching technical issues and when I find applicable information I want to leave it up for reference until the issue is resolved or until the info is deemed not relevant. There is nothing worse than having to waste time re-finding a drop of information in the ocean of technical documentation through which you have been wading for the past several hours, or days.

Well no software is perfect and as good as it is, Firefox and the applications it hosts do leak memory. Some a lot more than others. System requirements at startup are about 400 Meg of available RAM. At the height of a work session, with many open tabs, RAM usage will swell to 600-800M. After a few days without restarting RAM usage will go above a Gig and closing everything but the startup configuration still consumes over 600 Meg. The leakage filled up a 200 Meg barrel.

fire-kill-process

For this reason, as you all know, you have to restart Firefox from time to time to keep things perky, and operational. This is where the Firefox session restore comes in handy.

What I use to do when I needed to restart was go through every tab and close all the pages that I no longer needed, bookmarking ones that I might need again (which I hate doing because it results in a bookmark nightmare over time.) Then instead of closing Firefox normally — this is the little trick — open the task manager, click the processes tab, and kill the Firefox process. Firefox will immediately close.

When Firefox restarts it thinks it is recovering from a crash and will give you the option to restore the previous session, opening all your windows and pages they way you left them. Pretty sweet huh. There may be another way to accomplish this same thing, but it cant be as easy as this method.

And it just got a little easier with a simple check-box prompt improvement. Now I don’t have to go through the tedious process of closing the tabs I don’t need prior to restarting. At startup after a crash, Firefox now prompts with a selection of pages that were open at the “crash” and you can tick off the ones you don’t want.

firefox-session-restore

Just a little bit sweeter.

  • Share/Bookmark

AOL rebranding according to my advice

December 13, 2009

In recent posts I poo-poo’d the thinking of current medial moguls vis-a-vis the Google Myspace deal as well as Rupert Murdoch’s plans to charge for their content. Now at least someone is catching on and is not intent on self-destruction as they cling on to the old way of doing things.

Here is what I said in early Nov (and numerous times before):

Content is king on the Internet. Want to improve your traffic, improve your content. Since users create the content at MySpace, it becomes essential to attract users who can consistently generate quality pop content. Even if you have to pay to get them.

Here is what AOL CEO Tim Armstrong said in early December:

Because AOL is content, the brand has to be like content: fluid, flexible, and changeable. It exists as a host for new innovations and new content experiences. In a world where people believe what you do and not what you say, it is these new experiences that will define this brand and people’s perceptions of it. AOL Seed is the first example of this. Here AOL are pioneering the content economy with a publishing platform that will allow budding creatives to publish, find an audience for their work, and make money doing so.

Media outlets that try to own and or control submitted or hosted content to their sole benefit are in for big trouble over the coming years, especially if that tactic is essential to their core business model. Think recording industry.

Yeah, maybe AOL use to suck, but now they plan to share the wealth with those who actually have a talent for creating engaging content. If AOL management can pull it off, don’t be surprised if this model is a raging success.

Rewarding individual talent is preferable to powerful people making tons of money simply because they have power and money. I’m actually quite put out with the latter.

  • Share/Bookmark

WordPress drill-down admin pages

October 8, 2009

I was gaining momentum on the Geocache Manager WordPress plugin last week after solving a couple of longstanding problems with unauthenticated Ajax calls and a few Javascript quirks with Internet Explorer when yet another pesky problem surfaces. When I say pesky it means that I have been fooling around with it for several days without zeroing in on a solution, thus making zero headway on the project. To make matters worse, the problem lies with a feature that has existed from the beginning and had worked until I upgraded from WordPress Mu 2.7 to 2.8.4a last week.

In the admin panel I have a custom top level menu with two entries: a page for the map management and a page for options. The following bit of code…

function addAdminMenu(){
	add_action('admin_menu', array(&$this, 'gcgc_plugin_menu'));
}

function gcgc_plugin_menu() {
	$gcgc_relpath  = str_replace('\\','/',dirname(__FILE__));
	$parent = $gcgc_relpath.'/gcgc-admin-form.php';
  	add_menu_page('Private Geocache Manager', 'Geocache', 1,
                                 $parent, array(&$this, 'gcgc_admin_page'));
  	add_submenu_page($parent, 'Geocache Options', 'Options', 1,
                                 'gcgc_options', array(&$this, 'gcgc_options_page'));
}

function gcgc_options_page(){
	$gcgc_relpath  = str_replace('\\','/',dirname(__FILE__));
	include($gcgc_relpath.'/gcgc-options-form.php');
}		

function gcgc_admin_page() {
	$gcgc_relpath  = str_replace('\\','/',dirname(__FILE__));
	include($gcgc_relpath.'/gcgc-admin-form.php');
}

…will give you a menu like so:
geocache-menu

That all works. The geocache admin form lists all the courses defined and for each course there is a link to load a new admin page for that course. This is basic functionality that has existed since the 1st week of development and suddenly the link no longer works. The link now generates a redirect to a sub-blog with a page not found. WTF! Where do you start at on that.

I admit I am a little weak on WordPress redirects and I am having a difficult time understanding why the redirect would go to a sub-blog in the WordPress Mu installation instead of the current blog. But aside from that I don’t understand why it started issuing a redirect in the first place when the code that generates the link hasn’t changed in like five months.

UPDATE: I fixed the redirect problem by deleting the sub-blogs. Now I am just getting a mangled url, like so:

http://gulfcoastgeocache.com/wp-admin/?c=1
So let's go over what I am thinking so far. I am of course using the wp-admin framework and have the faulty link set up similar to the pages accessed from the admin menu. The URL on the Geocache admin link is:
.../wp-admin/admin.php?page=private-geocache-manager/gcgc-admin-form.php
Then on that page there is an entry for each geocache course and each course has an anchor link to its own admin page, like so:
<a href=".../wp-admin/admin.php?
        page=private-geocache-manager/gcgc-admin-cache.php&id=20">
Geocache Name</a>

After checking the usual suspects -- verifying paths, searching for typos, confirming no function parameters had been inadvertently changed -- the only thing I can think of is that the drill-down admin page was working previously only due to a flaw in previous WordPress. I remember when putting it in that it seemed easy. Too easy.

Over the past few days I've done quite a bit of searching using every term anyone could probably think of having to do with registering an admin page that is not on a menu. Compared to other development platforms out there (Make no mistake, WordPress is a development platform) there just is not that much in-depth technical documentation outside of your standard stuff. There are many redundant articles on adding an admin menu, for example, but not much on adding a multi-page, drill-down admin system. You have to figure that out on your own. Either not many people are doing advanced development or they are very tight-lipped about their stuff.

This morning I finally came upon an article that at least verifies my thinking:

WordPress 2.8.1 contains changes to improve the security of plugins by ensuring that only correctly registered plugin pages can be accessed as well as only showing the link to the page to users who have the capability required in the add_x_page call.

The article makes no mention of dynamically created sub-pages accessed by means other than the WordPress menu structure but down in the comments I find a fellow traveler:

I already have add_action(’admin_menu’, ‘FUNCTION’); for my main settings page. However, there’s a plugin page which is not a menu link (but an inside plugin page which is referenced when the plugin settings are saved).

And the answer to my problem, if not the solution:

You cannot just link to pages that are not registered as this would make it easy to load up files which should not be loaded so you have two choices to fix your plugin.

He goes onto say that the workaround is to use a WordPress admin action hook or a call back to the main page to process the main form submissions.

I like to keep my pages small and manageable and this plugin will ultimately have half a dozen admin pages when all the features are added. As of now there are only three. But since I want many small files instead on one big file here is what I am going to do: I am going to create a main admin container page that includes the proper admin panel when loading based on the URL. Should have seen this problem coming and set up like this in the first place. Oh well. I'll report back when I get the changes complete.

Read the follow-up:

WordPress drill-down admin pages II

  • Share/Bookmark

WordPress ajax and $wpdb

September 20, 2009

Anyone who does any tinkering with WordPress templates or plugins is likely familiar with the WordPress class for interfacing with the WordPress MySQL database, $wpdb. In the previous article here in The Garage, Viewer-facing Ajax in WordPress Plugin, I described a problem I was having with Ajax requests from the public side of a website from a user who is not logged in. Pesky little problem it has been.

In a nutshell, if the user is not logged in they do not have access to any of the built-in WordPress Ajax functionality so you have to write your own Ajax handler, which is not a problem until you need to access the database using $wpdb since the $wpdb class is not normally available to a page or script that is loaded outside the WordPress context. My research led me to a couple tricks around this limitation such as a template redirect or loading the core Worpdress files in the external Ajax handling script, eg,

include_once(‘wp-config.php’);
include_once(‘wp-load.php’);
include_once(‘wp-includes/wp-db.php’);

In theory, after loading those core files I can now make calls to the MySQL tables using the $wpdb class just as if I was logged in to the admin panel. In the back of my mind I am thinking that maintaining extra scripts for anonymous db access is a lot of work and loading the core WordPress files is a lot of overhead just to run a couple of simple queries. Really not optimal.

So I was still looking for a better solution even as I was working on making the above work when I stumbled upon the better solution. Somewhere around March WordPress released an update (v2.8 I believe) which has support for Ajax actions initiated by a user who is not logged in. Along with the ‘wp_ajax’ hook there is now also a ‘wp_ajax_nopriv’ hook that provides the same functionality but for users that are not logged in. So when your main plugin code is loading all you need to do is check to see if the user is logged in or not and then initialize the appropriate action hook.

//load nopriv ajax handlers for front-end ajax users not logged in
if ( is_user_logged_in() ) {
    add_action('wp_ajax_getVectorMarkers', 'getVectorXML');
    add_action('wp_ajax_getVectorMarkersText', 'getVectorXMLText');
} else {
    add_action('wp_ajax_nopriv_getVectorMarkers', 'getVectorXML');
    add_action('wp_ajax_nopriv_getVectorMarkersText', 'getVectorXMLText');
};

Using the ‘wp_ajax_nopriv’ hook allowed me get rid of a lot of code that was written specifically for displaying custom maps to users who are not logged in. It makes me very happy!

Evidently not too many people know about ‘nopriv’ as the info was difficult for me to Google down. (Click here to see the thread where I found the information.) The alternative methods are also discussed in the thread if you are not in the position to upgrade to the latest WordPress version with the ‘nopriv’ option. (Here is the WordPress Trac nopriv change documentation.)

I can verify that wp_ajax_nopriv also works with WordPress Mu version 2.8.2.

  • Share/Bookmark

Viewer-facing ajax in WordPress plugin

September 3, 2009

It’s rare that I can’t solve a programming problem no matter how complex and thus I rarely leave a question on a support forum. I can’t even remember the last time; probably over a decade ago. Here is one I left recently at the supposedly fantastic WordPress.org plugin support forum.

I am writing a plugin to manage map resources and I having a couple a issues that I have been unable to figure out. I have a test site set up here –> http://gulfcoastgeocache.com/

I am using the Google Map API and lots of ajax both admin and viewer-facing to display custom maps. On the viewer facing side I am using SACK to call a small php script that in turn calls the actual function inside the plugin class.

$gcgc_path  = str_replace('\\','/',dirname(__FILE__));
require_once($gcgc_path.'/gcgcclass.php');
$gcgc_Manager->getVectorXML($_POST[id]);

The class function:

function getVectorXML(){
    header("Content-type: text/xml");
    $parms = array('id' => $_POST['id'],
                   'id_type' => 'vector_id'
                    );                         

    $cachets = $this->getVectorMapData($parms);
    $xhtml = "";
    $xhtml .= "";
    if($cachets){
      $xhtml .= "";
    	foreach ($cachets as $c){
    		$xhtml .= "";
    		}
    }
    $xhtml .= "";
    die($xhtml);
  }

Works fine if the user is logged in but is failing if user is not logged in. More accurately, the ajax round trip succeeds but my xml response is -1 if user is not logged in. No data is coming back.

The codex example for ajax does not illustrate a cookie being sent on the viewer-facing side but this is where I am thinking the problem lies, but really I am at a loss for an idea right now.

This is my first WP plugin so I may be having a noob moment. I’ve been revisiting this issue repeatedly over the past couple of months and, I hate to admit, I can’t figure it out. Any help would be greatly appreciated.

I posted that five days ago and not a peep. I even bumped it a couple of days ago. Still nothing. I’m not sure if the question is too stupid to warrant a response or if maybe it is too hard. I think the only way to get a quick response, or any response at all, for that matter, is to leave your query in broken English and to ask a question that indicates you don’t have a clue about what you are doing.

I’m not impressed. If anyone has a clue about the ajax, please let me know.

  • Share/Bookmark

GoDaddy and the virtual army of web page hangers

August 22, 2009

For the past few days or so I’ve been working on converting a regular brochure website into a content managed WordPress website. The previous web… er, I don’t know what to call them actually. Certainly they are not designers or developers or anything of the sort that might have real technical knowledge. If they were they would provide real value with their service and there would be some keyword meta tags along with a stat counter on the site. Let’s call them web page hangers. The Internet is full of these page hangers who are out calling themselves “web developers” and such. It’s a reseller scam set up by the big hosting companies designed to rip-off the unknowing buyer of Internet services.

So the previous web page hanger had the website and the email hosted at 1and1. Not a problem; I have all my stuff hosted at 1and1. The only problem is that the customer thinks everything is hosted at GoDaddy, where they purchased the domain name. They are not even aware that their website is actually saved at and hosted from 1and1.

The page hanging company simply entered 1and1′s name servers in the DNS and pointed the whole shebang away from GoDaddy to their hosting account at 1and1 where they have set up an external domain record and some mx records for a few email forwarding accounts. Fairly standard from a technical standpoint but from a business perspective this practice is extremely bad form and I see it over and over again.

About 80% of new website clients over the past decade have had this problem where getting information — like a user name and password — from the previous provider is like pulling teeth. The page hangers basically have the customer’s site held hostage until the client gets someone who knows how to cut the strings and say farewell. I’ve seen cases where unscrupulous web page hangers were charging literally thousands of dollars over a year to make the simplest of changes.

So I got everything switched back to GoDaddy and have been using GoDaddy’s hosting service. This is my first GoRound with GoDaddy and at this point I must say that GoDaddy is about the worst piece of Internet software I have ever used to manage an Internet account, and I’ve been around a very long time. I thought 1and1′s user interface sucked but GoDaddy makes 1and1 seem like a world-class operation.

GoDaddy is so bad I can’t be sure it’s not made that way on purpose to somehow enhance sales through trickery. For example I almost bought a pack of forwarding accounts when i didn’t need them because you don’t know you have them until you activate a credit, which is of course buried in the maze of incomprehensible, unintuitive, bifurcated, navigation choices that never seem to lead to the same place. Kudos to their 24/7 telephone support, but the fact that you need it so much speaks volumes about the site and it’s nearly worthless on-line help facilities.

Furthermore they — both the page hangers and the service providers — somehow dupe people into buying stuff they don’t need. My client has the GoDaddy deluxe email package, domain protection, and business registration that they don’t use and don’t need. The hidden, free forwarding accounts is all they needed.

I can see why the page hangers didn’t want to use GoDaddy’s service — after being set up with 1and1 they probably couldn’t figure out how to get anything done at GoDaddy.

  • Share/Bookmark

Typical IT job listing

July 11, 2009

Here is a Monster job listing sent to my email from Monster:

Web-related Prog/Analyst II

About the Job

Responsible for the definition, design, construction, integration, testing, and support of reliable and reusable software solutions, addressing business opportunities.?  Includes systems analysis, creation of specifications, coding, testing, and implementation of application programs and data interfaces.
Includes Java, JSP, J2EE, JDBC, EJB, JavaScript, C+?+?, Visual Basic, COM, DCOM, ActiveX, ASP, HTML, DHTML, XML, ColdFusion, Visual Age, WebSphere, .?NET, etc.

  • Service Experience 3-5 years experience with Financial Services clients
  • Works substantially with little supervision or oversight to deliver key milestones
  • Served as BSA on multiple project lifecycles; Demonstrated  experience in industry (1 – 3 years)
  • 3+? years of project experience in the quality assuranceand testing phases of projects
  • Client experience preferred
  • Deep knowledge of specific technologies and new and current architectures
  • Skills in object, data, and /? or process modeling, business process design (2-4 yrs)
  • Lean/?Agile development experience (1+? yrs)
  • Provides clear concise communication with project team and mid-level management
  • Leading projects involving third parties and suppliers

Salary
$36.00 – 39.00 USD /?hour

If I.T. is your chosen profession this is some kind of a bad joke. Anyone who is qualified for the above job and takes that job at that rate is a fucking moron. Sorry if I’m talking about you, but that is just the way I see it. I know times are tough, but you are cutting your own throat when you work at a steep discount. After taxes and expenses the incumbent would be making about what a Wal-Mart associate makes except with no benefits. And you just know there will be some prick at the other end of the grueling, hour-long commute harping on your ass for being 10 minutes late. After all you’d be just a low paid, easily replaceable peon. A good secretary makes as much.

Let’s put the above offer into perspective. Way back in 1988 I was doing similar work on a contract basis. The technology was different of course since everything was still DOS-based and the scope of the work was much smaller but I was a one-man show working my way through college and I only had about 5 yrs experience when I started. I was being paid $25 / hr.

In 1992, the year after receiving my degree I left that job for a better opportunity and a little bit more money. This is the way it is supposed to work, right? You work hard, prepare yourself, and you will advance in your profession and earn more money as you get more experience. The American Dream.

Today, that maxim of capitalism is out the window. Since 2001 my earning potential has steadily gone backwards while living expenses and fuel have skyrocketed. It makes sense really if you look at the increasingly fast slide towards socialism/facism in America. To be more socialistic or fascist means implicitly to be less capitalistic. The systems are mutually exclusive. For one to thrive, the other must wither.

In 1995 my career was progressing well so I made a 20 yr commitment and a 30 year commitment, my first child and a mortgage, respectively, based on a modest assumption of increasing my earning potential over the years. In 1999, I was the proud and happy father of another 20 year commitment.

So what happened in 2001? 9/11 certainly impacted the economy but that was only a temporary setback. The Internet bubble burst in 2000 and that also was a setback but again, just temporary. The Y2K fiasco certainly didn’t help our credibility.

So what did happen to cause the I.T. industry to collapse? Well, Enron happened. Tyco happened. Worldcom happened. In other words, corruption happened. Then government happened. Enron and other greed based corporation’s failure was the beginning of the end because it led to Sarbanes Oxley, or SOX as it is known in the vernacular.

How did Sarbanes Oxley decimate the I.T. industry? All I have is anecdotal evidence but I think it is solid. Every engagement I’ve been on since 2002 has involved interaction with “the auditors.” Most companies must hire internal auditors to get ready for the external auditors. Teams of auditors from big accounting firms are not cheap. Regulatory compliance isn’t cheap. (Zhang 2005: This research paper estimated SOX compliance costs as high as $1.4 trillion.)

Greedy corporations don’t just add on new expense because the government said so, they add it on and cut it somewhere else. I.T. was a logical choice for the cuts because much of the work can be outsourced to India and other third-world countries whose citizens will work for a small fraction of what an American needs to earn in order to keep up with inflation and to honor their long-term commitments.

The bottom line is that Sarbanes Oxley caused $1.4 trillion dollars to be shifted from IT to bean counting and regulatory compliance; from people who actually contribute to the success of a company to people who do nothing but suck up good air and good money into a black hole. And before you say SOX was necessary and that government intervention and regulation works, let me point out that the economic crisis in which we now find ourselves is again due to corporate and bureaucratic corruption of the type that SOX was supposed to fix.

So the problem for many of us IT professionals is to figure out how to keep our long-term commitments that were made based on a model that is no longer valid. (That model being the American Dream.) In other words, how do I pay for a house that I bought in 1995, for which taxes and insurance have increased the monthly payment 20%, with earnings that are 40% less than what I was making then?

  • Share/Bookmark

First retail website

May 29, 2009

I’ve done a many web database applications for corporate clients over the past decade but I’ve  just finished the first set of requirements for my first retail web design client, Jeter’s Furniture Refinishing. They are a local outfit and I have seen their work first hand and it’s really good. Check them out if you need some furniture fixed or an antique restored — or if you just want to see my first retail website.

snapshop-jeter

  • Share/Bookmark

Rumble Strips

February 15, 2009

I revived enormous incongruities into a new blog I am calling Rumble Strips. It was either that or Surface Gradient Anomalies.

I don’t know how much I’ll be writing to the blog since I have been trying to improve my mental outlook by totally ignoring the news about politics and such, but it doesn’t make sense to have almost half a decade of writing sitting in the closet. I had to update the WordPress version to 2.7 and then export the database and import into wpmu. In the process I somehow lost all my categories and I don’t want to screw around with it.

  • Share/Bookmark

Superbowl twitter

February 4, 2009

You got to check this out. An animated timeline of Twitter traffic during the superbowl.

  • Share/Bookmark