How to link to a specific scene in a Hype document

If you've made a multi-scene Hype document which is hosted online as a web page, you can link directly to a named scene in that document using this handy script:

function check_for_deeplinks(hypeDocument, element, event) {
	/*
	Allows "deep" linking from an external page into a specific scene in a Tumult Hype document.
	To use, put this on the first frame of the first scene in the Hype document.
	Then, set the link url to `my-hype-document.html#my-scene-name`, to go to the scene named 
	"my-scene-name".
	*/

	// Look for a hash in the url
	var hash = window.location.hash.substring(1);
	
	// Once the hash is found, remove it from the url so you can return to the first scene again
	// in future without redirecting again.
	history.pushState("", document.title, window.location.pathname);
	
	// Go through each scene to find the one whose name matches the hash
	for(var i = 0; i < hypeDocument.sceneNames().length; i++) {
		if(hypeDocument.sceneNames()[i] == hash) {
			// Go to the scene once you've found it
			hypeDocument.showSceneNamed(hash);
			break;
		}
	}
}

[gist]

Hazel rule to delete ResearchGate pdf cover pages

I download a load of academic papers in as PDFs from ResearchGate, since that's often the only place a free version of a paper is available.  Unfortunately, ResearchGate prepend downloaded PDFs with a branded cover page, which I obviously don't want.

On MacOS, it's easy enough to manually delete pages from a PDF using Preview.  But with a bit of help from Hazel, it's possible to automate it. 

A javascript hack to have Spry CollapsiblePanels remember their state

Adobe Dreamweaver uses the Spry CollapsiblePanel plugin to create boxes that expand and collapse when a heading is clicked.

The following code allows the open/close state of the panels on a page to be remembered when the page is reloaded, or when history is accessed. It can also be used to share the open/close state between many pages containing the same panels.

A quick javascript hack to fake adjusting HTML5 audio elements' timeupdate event frequency

I was trying to make a bunch of elements change position as an audio file played, using a snippet something like:

$(audiohtml).bind("timeupdate", onAudioUpdate);
$(audiohtml).bind("play", onAudioUpdate);
$(audiohtml).bind("pause", onAudioUpdate);

function onAudioUpdate() {
	// Move the elements here
}

But the trouble was that the audio element's timeupdate event only fires once every 200ms or so on my browser (this is set by the HTML5 audio specification and isn't modifiable as far as I know).

200ms was slow enough that the animation of the elements looked jerky (5 fps).

Instead, I used a 10Hz setInterval clock to trigger the movement functions, and used the audio's play and pause events to create and destroy the clock: