Skip to content

Instantly share code, notes, and snippets.

@BenWard
BenWard / gist:1858216
Created February 18, 2012 08:24
Oneliner, bookmarklet script to bypass Facebook news apps (e.g. The Independent.)
window.location.search.split('&').filter(function(item,i){i=item.split('='); return(i[0]&&i[0]=='redirect_uri')}).forEach(function(u){window.location=unescape(u.split('=')[1])})
@BenWard
BenWard / gist:1729232
Created February 3, 2012 09:25
Script to show a growl notification for pending Homebrew updates
brew outdated | growlnotify -n "Homebrew Update Check" -t "Homebrew Updates Available" -a Xcode -s -d "brew-updates"
@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 / pinboard-full.js
Created January 29, 2011 07:47
A smarter bookmarklet for Pinboard.in; wraps selected text in <blockquote> tags, keeps variables out of the global scope, supports filling tags from rel="tag" markup in the page, and titles from hAtom entry titles.
(function() {
// Change `silent` to true to invoke the promptless, self-closing
// version of the bookmarklet.
var silent = false;
var url = location.href;
var title = document.title;
// Look for a single hAtom entry on the page, and iff one is found, extract
// the entry-title in place of the document title:
@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 / 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 / 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();