Web Dev Notes

Blog about web development by Robert Dawson

Top search queries (as of June 2013)

Seriously? This is what people search for on my website? 

concerta and alcohol

lumosity bpi

what is a good bpi

average bpi lumosity

average bpi

So, essentially, people care about two pages on my website (links 2-5 are the same) and the people who most visit my website (a) have ADHD or ADD and/or (b) subscribe to Lumosity.

Conclusion: Looks like an architectural overhaul is seriously overdue! 

Bookmarklet to switch subdomains

If you ever find yourself needing to switch subdomains, such as from beta.mysite.com to www.mysite.com, here is a bookmarklet to make life easier. Because dragging my mouse to the address bar, selecting the entire subdomain, and then tediously typing in a new one is so exhausting!

With this handy bookmarklet, all you have to do is click it and type in the subdomain you want. It's not telepathy, but it's tolerable. To make this bookmarklet, make a new bookmark on any given page and then replace the URL with the following code.

javascript:var env=prompt("Subdomain?","e.g., www");if(env!="e.g., www"){window.location=window.location.href.replace(/http:\/\/(.+?)\.(.+?)\.(.+)/g, "http://"+env+".$2.$3");};

Set Messages Status to Available on Startup

Maybe it's my overbearing electromagnetic influence, but I routinely encounter a problem with the Mac app, Messages, in that, if it doesn't detect an Internet connection, it changes its status to "Offline" and, because I shutdown and opt to restart with the same applications open, the status of Messages remains "Offline" when it opens, even when I try to change it to "Available." Um.

So, to solve this simple but annoying bug for Apple, download the following AppleScript script bundle and add it to your login items so it runs on startup.

Set Messages Status to Available on Startup

Instructions

  1. Download to /Documents/scripts/Applescript/.
  2. Uncompress (from .zip to .scptd).
  3. Go to System Preferences > Users & Groups > Login Items (tab).
  4. Select the + sign.
  5. Find your script.

If you don't feel like downloading the script bundle above, just open the AppleScript Editor application, start a new script, and paste in the following code:

if application "Messages" is not running then
launch application "Messages"
end if

tell application "Messages"
set status to available
end tell

EmotionML

Good morning, human.

As the web is becoming ubiquitous, interactive, and multimodal, technology needs to deal increasingly with human factors, including emotions. The specification of Emotion Markup Language 1.0 aims to strike a balance between practical applicability and scientific well-foundedness. The language is conceived as a “plug-in” language suitable for use in three different areas: (1) manual annotation of data; (2) automatic recognition of emotion-related states from user behavior; and (3) generation of emotion-related system behavior.
— http://www.w3.org/TR/2013/PR-emotionml-20130416/
In
Comment

Presentation re: 2013 HTML5 Developers Conference

Monday through today, I attended the HTML5 Developers Conference at the Palace Hotel in SF and thoroughly enjoyed it! It was highly technical and overwhelmingly detailed and, oh, so much fun! I even made a very short presentation to present to coworkers tomorrow:

Taking a swipe at swiping

I have to take a small swipe at the touch gesture of swiping on mobile devices. Below is a screenshot of an app I installed this morning called doable. It's good! But they use swiping in an in intuitive way, to complete tasks. Tapping on a task takes you to that task's details, where, to add annoyance, you have no option to complete the task.

What would I do? I would increase the size of the outer and inner circles to the left of each task name and let users tap either circles to indicate completion. I would also indicate completion by fading from an intense color to transparent before moving the task down to its next place in the frequency-based hierarchy.

Hide/show info and change URL without reloading

Problem

You have a page with information by year. And year headings are linked, like this:


Information under the latest year is shown, while information under previous years is hidden. When a user clicks a year, you want to show that year's information and add a hash value (e.g., #2013) to the URL so that returning to this page will return it to the previous open/close state.

Solution

var current_path = location.pathname;
var year_hash = (location.hash.substr(1) != "") ? location.hash.substr(1) : "";

$("h2").on("click", function()
{
location.hash = $(this).text();
});

if ( location.hash.match(/^\#\d{4}$/) )
{
$("h2:first").click();
$("h2:contains(" + year_hash + ")").click();
}

Automator script to copy all open URLs in Safari to clipboard

Problem

You need to send someone (or do anything with) a list of URLs you have open (in Safari or Chrome on Mac).

Solution

Use this Automator workflow script:

on run {input, parameters}
	set _urls to {}
	tell application "Safari"
		repeat with _tab in tabs of window 1
			set end of _urls to URL of _tab
		end repeat
	end tell
	set {_tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
	set the clipboard to _urls as string
	set AppleScript's text item delimiters to _tid
	
	return input
end run

Then, just paste wherever you like!

The Pad in 2022?

Is it silly to suppose that a future iPad might simply be called Pad? Think about it. If a company can redefine a common verb like "like," isn't it possible to redefine a proper and much less commonly used noun?

Open selected text in TextMate with Automator

Like most developers with a Mac I presume, I love TextMate! One of the things I have often wanted to do is to select text in an application and paste it into TextMate. Thanks to Aaron at 9thport.net, here is a dead-simple solution!

Steps

  1. Open Automator.
  2. Make a new Service script.
  3. Add Run Shell Script.
  4. Write "cat | mate" and save as "Launch TextMate".
  5. Open System Preferences.
  6. Go to Keyboard > Services.
  7. Check Launch TextMate and give it a shortcut, like F6.
  8. Go to an application with text, select it, and hit F6!

 

How to use phpDocumentor on WordPress (on Mac)

Here are the steps it took for me to get phpDocumentor to create documentation for a WordPress installation.

Steps

  1. Open phpDocumentor.ini*
  2. Uncomment the line (line 25 for me) starting with "memory_limit"
  3. Set memory_limit to "2048M"**
  4. Open Terminal and go to the directory above the one your wordpress installation
  5. Use phpdoc (takes a few minutes)

Example

phpdoc -o HTML:frames:earthli -d wordpress -t wordpress/docs

* I'm using MAMP and my directory is /Applications/MAMP/htdocs/phpdoc/.
** Probably overkill; consider available RAM. For me, 1024M wasn't enough. I kept getting this error:

phpdoc FAILED: Bad environment variable $PHP (set to "/usr/bin/php")

Blackmine

I want to make a task manager for philosophy students, particularly followers of Existentialism, called Blackmine, in which you are given a predefined and unchangeable set of possible steps or actions, none of which resolve anything and all of which lead back to the beginning.

Greasemonkey script to convert Redmine URLs into actual hyperlinks

I use Redmine and each issue page contains a field identified as "URL(s) to be edited," which contains URLs related to the issue at hand. Unfortunately, these URLs aren't actually linked! They're just text. And I have been tediously copying and pasting each link, one at a time, into a new tab in my browser.

Well, not anymore! Today, to ease my suffering (and to try something new), I created my first Greasemonkey script to convert those text-only URLs into hyperlinks. I hope it's helpful, as this script could be easily modified to work with any text in any HTML element (thanks so much to jQuery).

To use this script, first install a Greasemonkey-compatible extension in your browser. Greasemonkey has traditionally been primarily used in Firefox, but you can also add Greasemonkey support in Chrome (and probably IE, but why even check?). Then, install my script! And modify to suit your own needs.