Helping Netbeans/PhpStorm with Autocomplete/Code-hinting

Where Netbeans can’t guess the type/existence of a local variable, you can tell it in a multiline comment:

/* @var $varName TypeName */

After this comment (and as long as TypeName is defined in your project/project’s include path), when you start to type $varName, Netbeans will offer to autocomplete it, and will offer TypeName method/property suggestions. If you rename the variable with Ctrl+r (rename refactoring), Netbeans will change the comment, too.

I usually forget this syntax because type comes first in @param declarations.

Update: PhpStorm supports a similar syntax, but reversing the type and variable name:

/* @var TypeName $varName */

A Case Against Google+

Google+ will fit some people really well, and is certainly bringing some fresh ideas to the table to keep Facebook on its toes. That said, here’s why I kinda hope it doesn’t take off, and why I’m seriously considering leaving the party early.

  1. There were compelling reasons to abandon Friendster and MySpace at their peaks; frustrating performance, bugs, spam, bad UIs, visual nonsense, etc. Facebook seems to be scaling quite gracefully and they seem to constantly improve rather than frustrate.
  2. My main issue with Facebook would be privacy, but I find it highly unlikely that, in the long run,  Google+ or any other ad-supported social network will be a better steward of our personal information. That train goes in one direction.
  3. Establishing yet another silo of social network identities will cost us a huge amount of collective time.
  4. Since Google+ “circles” nearly remove all social cost from forming weak relationships (“just dump them in acquaintances”) we could be talking about a lot more time spent managing relationships. Circles may be the killer feature that we later really regret embracing.
  5. Prominent Google+ notifications appear at the top of all Google tools, and I couldn’t find a way to hide them without, say, keeping a separate account. With social networks being brilliant delivery mechanisms for dopamine; offering that hit while in Gmail, Docs, Calendar, and Search is going to be a disaster for a lot of people’s productivity.

Bookmarklet: Horizontally invert HTML5 videos

My demands for “reverse” glasses have gone unserved, but I made a bookmarklet that provides the same effect: “flopping” a video horizontally.

  1. Install the SwitchStance bookmarklet, for which you’ll need a modern browser that supports CSS transforms on video elements.
  2. Opt-in to YouTube’s HTML5 trial
  3. Load up any video without ads (here’s one of Matt Hensley skating)
  4. While the video plays, click the bookmarklet.

The video will mirror and you’ll see Hensley, a regular-footed skater, now skating goofy foot (in “switch stance“). Or you can get Paul McCartney to play guitar right-handed.

Bash: Resolve symlinks in your working directory

Say you have created a symlink from your home dir to another location:

$ ln -s /Applications/XAMPP/xamppfiles/htdocs ~/htdocs

Now you can easily change to the XAMPP htdocs: cd ~/htdocs and then get back home: cd ..

But how do you get to xamppfiles?

Update: Thanks to sapphirepaw, the solution is simple: cd -P htdocs/.. or to resolve your current wd: cd -P .

Less optimal methods follow:

The secret is pwd -P, which outputs your “real” working directory with symlinks resolved. By escaping this with $(...), we can include this in a cd command:

$ cd $(pwd -P)  # change working directory to the real current path.

So to get to xamppfiles from home:

$ cd htdocs $ cd $(pwd -P)/..

How to Modify a 3rd-party Chrome Extension

I wanted to add a little feature to the Delicious Chrome extension, but couldn’t find any reference to how to edit/clone a 3rd-party extension. It turns out—at least for making minor mods—it works how you’d think:

  1. Change some extension files.
  2. Restart Chrome.

Caveat: Undoubtedly an update of the extension would wipe out these changes, and following this advice might break the extension (or Chrome!).

Adding a link to the Delicious Bookmarks Extension

On XP, the extension files were in C:\Documents and Settings\<user>\Local Settings\Application Data\Google\Chrome\User Data\Default\Extensions\lnejbeiilmbliffhdepeobjemekgdnok\0.998_0.

To track my work, I did git init; git add . then repeated these steps:

  1. Change file(s)
  2. Restart Chrome
  3. Test. If OK, git commit -m 'desc of changes'

When done I’d added a simple link to the user’s bookmarks (screenshot). I wanted to make this easy for the Delicious team to incorporate these changes, so I generated this patch by diff-ing from the oldest commit:

git diff $(git rev-list HEAD | tail -n 1) > ~/del-chrome.patch

Shibalike: a PHP emulation of a Shibboleth environment

Update 2011-06-23: All the essential components of Shibalike are complete and the project is hosted on Github. This is currently blueprint-ware, but I’m excited about it.

A co-worker and I have laid out a design for a flexible system that can emulate a working Apache/PHP Shibboleth stack, without requiring any outside resources (e.g. an IdP, mod_shib, shibd). I see this as useful in several cases/for several reasons:

  • Setting up your own IdP for testing would be a pain and a maintenance headache.
  • Depending on your institution, getting attributes approved for release to a new host may be time-consuming or impossible.
  • Shibboleth won’t work on http://localhost/.
  • You want to be able to test/experience a similar sign in process on localhost as users do in production.
  • You want to be able to test your PHP-based shibboleth auth module without a working shib environment.
  • You want to emulate an IdP problem, or allow a secondary auth method to kick in if the IdP is down (without switching auth adapters).
  • You might want to “hardcode” an identity for a unit/integration test
  • You might want to give a select group the ability to login under a testing identity after they authenticate at the real IdP.

Continue reading