Using PHPUnit's returnCallback for a variable length valueMap


Awkward title aside, this is just a quick post about something I rigged together the other day. I have a mocked service locator object that needed to implement returnValueMap, but where the contents of the valueMap would vary based on which test I was executing. PHPUnit does not natively support modifying the valueMap after it's been assigned, so I wanted a way to append items to the map without re-defining the whole mock for every test.

Read more of this post »

Cloning a base project in PhpStorm


When I first started using PhpStorm (my current IDE) I noticed that I was applying a number of the same project-specific settings during each new project. Being a good (i.e. properly lazy) programmer, I figured that this should be automatable, so I dug into the project metadata that PhpStorm keeps in each project's .idea directory (at least on OS X). I found that with a few string substitutions I could create a template project with all the settings the way I like them, and then clone that metadata directory into each new project I created. You'll find a sanitized version of the script I use in this Github repo. Hope it saves someone out there some time.

Tags: phpstorm, script

Rel=disavow for Twitter


Last night I was thinking about links posted on Twitter, and how many people I know will regularly or semi-regularly post links to things that they are not endorsing, in the "look at this flaming pile of idiocy" sense rather than the "check out this cool thing" sense. I know Twitter automatically adds rel="nofollow" attributes to outbound links from tweets, but that still doesn't mean that a user clicking on that link isn't providing the destination site with views/hits/ad impressions/etc. It got me wondering if there was a better way to point out notably awful things on the web without rewarding the destination site.

The first thing I was hoping for is something like rel="disavow", similar to what Google put together in their webmaster tools site, only for outbound links instead of inbound. Then again, any link relations would likely be stripped by (or inadvertently targeting) I eventually came to the conclusion that the only thing to do was hope that like-minded internet users use an ad blocking software or (possibly) link to Google cached versions of the pages instead of their live sites, which also has the benefit of storing the offending content for longer if the owner tries to change or remove it.

So I'm wondering... am I over-thinking this? Does my desire to see sites without rewarding them make me a bad internet user? Some sort of, dare I say it, pirate?

Edit: good enough for me: