Skip to content

Instantly share code, notes, and snippets.

@BenWard
BenWard / scrobblejam.js
Created November 27, 2011 01:25
Scrobble my Jam: A pre-configured, bookmarklet version of Scrobble my Jam ready for use. Scrobbles playback from http://thisismyjam.com to http://last.fm. Enjoy.
/* Scrobble my Jam
*
* Bookmarklet JavaScript for scrobbling http://thisismyjam.com to
* Last.FM. If it doesn't scrobble, it doesn't count.
*
* (c) 2011 Ben Ward (@benward, http://benward.me)
*
* BSD License
*
* Instructions: Select all of the JavaScript text below, and drag it to your bookmarks
@BenWard
BenWard / stickies.taskpapertheme
Created September 25, 2011 08:28
A simple TaskPaper theme to imitate Apple's Stickies.app notes.
<theme>
<!-- Color Variables -->
<color id="foreground" red="0" green="0" blue="0" alpha="1.0" />
<color id="background" red="1.0" green="0.95" blue="0.6" alpha="1.0" />
<color id="selection" red="0.7" green="0.835" blue="1" alpha="1.0" />
<color id="tag" extendsColorID="foreground" alpha="0.7" />
<color id="handle" extendsColorID="foreground" />
<color id="insertionPoint" extendsColorID="foreground" />
@BenWard
BenWard / intents.manifest.json
Created June 26, 2011 21:33
Hypothetical way of manifesting Web Intents for a service to the browser, along with some facility for property name mapping and proprietary requirements.
{
'vendor': 'twitter',
'intents': [
{
'name': "Follow",
'verb': 'follow',
'url': 'http://twitter.com/intent/follow',
'required_params': ['screen_name'],
'param_map': {
'user_name': 'screen_name'
@BenWard
BenWard / mogify-bookmarklet.js
Created November 25, 2010 02:10
Convert a Spotify URL into a MOG URL for music playback in North America.
javascript:(function()%20{function%20esc(s)%20{return%20s.replace(%27%20%27,%20%27-%27);}var%20track,%20artist,%20album,links%20=%20document.getElementsByTagName(%27a%27);for(var%20i=0;l=links[i];i++)%20{if(l.href.match(/^spotify:track:/))%20{track%20=%20l.innerText;}else%20if(l.href.match(/open.spotify.com\/artist/))%20{artist%20=%20l.title;}else%20if(l.href.match(/open.spotify.com\/album/))%20{album%20=%20l.title;}}window.location.href%20=%20%27http://mog.com/music/%27%20+%20esc(artist)%20+%20%27/%27%20+%20esc(album)%20+%20%27/%27%20+%20esc(track);return%20true;})();
@BenWard
BenWard / playmusic-full.js
Created November 25, 2010 02:40
A bookmarklet to move you from one music playback service to another. Can take you to MOG or to Rdio from pages on MOG, Rdio, Last.FM, Spotify, and some MySpace pages. Set `using: 'mog'` or `using: 'rdio'` as appropriate. Work in progress.
PlayMusic = {
using: 'mog',
esc: function(s) {
return s.replace(' ', '-');
},
sources: {
'rdio': {
match: /rdio.com/,
handler: function(url) {
var artist='', album='', track='';
@BenWard
BenWard / dehash-bookmarklet.js
Created October 4, 2010 22:13
From the files of ‘stupid one line scripts that the world should not need’, this takes a URL from a JavaScript-based app like Twitter or Hype Machine and presents you with an easily copyable, real URL that doesn't contain any ‘#’ nonsense.
javascript:(function()%20{var%20io%20=%20prompt(%22Dehashed%20URL%20(share%20this.):\n\nCopy%20the%20URL,%20then%20press%20OK%20to%20reload%20and%20confirm%20that%20it%20works,%20or%20cancel%20to%20stay%20on%20this%20page.%22,window.location.href.replace(/\/?#!?\/?/,%20%27/%27));if(null%20!==%20io)%20{window.location.href%20=%20io;}})();
@BenWard
BenWard / mogrdio.bookmarklet.js
Created August 12, 2010 21:05
A quick quick quick bookmarklet to redirect from an Rdio.com artist or album page to the equivalent page on MOG.
javascript:MOGRdioExt%20=%20{redirect:%20function()%20{var%20artist%20=%20%22%22;var%20album%20=%20%22%22;var%20parts%20=%20window.location.href.split(%27/%27);for(var%20i=0;%20i%20<%20parts.length;%20i++)%20{p=parts[i];switch(p)%20{case%20%27artist%27:i%20=%20i+1;artist%20=%20parts[i];break;case%20%27album%27:i%20=%20i+1;album%20=%20parts[i];break;default:break;}}if(%22%22%20===%20artist)%20{alert(%22This%20only%20works%20if%20you%27re%20viewing%20an%20Rdio%20artist%20or%20album.%22);}else%20{window.location.href%20=%20%22http://mog.com/music/%22+artist+%22/%22+album;}}};MOGRdioExt.redirect();
@BenWard
BenWard / gist:300776
Created February 10, 2010 19:57 — forked from mojodna/git-svn-diff.sh
A script to generate svn-style diffs from git repositories, compatible with Review Board
#!/bin/sh
#
# git-svn-diff
# Generate an SVN-compatible diff against the tip of the tracking branch
TRACKING_BRANCH=`git config --get svn-remote.svn.fetch | sed -e 's/.*:refs\/remotes\///'`
REV=`git svn find-rev $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH)`
git diff --no-prefix $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH) $* |
sed -e "s/^+++ .*/& (working copy)/" -e "s/^--- .*/& (revision $REV)/" \
-e "s/^diff --git [^[:space:]]*/Index:/" \
-e "s/^index.*/===================================================================/"
/* Use this to cause a function to fire no more than once every 'ms' milliseconds.
For example, an expensive mousemove handler:
$('body').mouseover(ratelimit(function(ev) {
// ...
}, 250));
*/
function ratelimit(fn, ms) {
var last = (new Date()).getTime();
@BenWard
BenWard / µf-datetime.html
Created January 19, 2010 21:13
A set of examples for flexibly marking up dates and times in microformats (such as hCalendar and hAtom), using up-to-date patterns.
<!-- The different ways of marking up dates and times with microformats -->
<!-- Microformats are quite flexible when it comes to marking up dates in valid
HTML4. The value-class-pattern allows you to mark-up different parts of the
date, providing tool-tip context or nesting the data silently alongside a
custom format.
Date formatting in microformats no-longer requires using the `<abbr>`
element. -->
<!-- Core requirement for dates in microformats: The date must be available in an