Skip to content

Instantly share code, notes, and snippets.

View reefdog's full-sized avatar

Justin Reese reefdog

View GitHub Profile
(* "Most Played Artists" by Michael Henley (mike.com@mac.com) v1.0 2006-Feb-17 *)
-- Check system version --
if (system attribute "sysv") < 4160 then if button returned of (display dialog "Sorry, this script requires Database Events.app, which is only distributed with Mac OS 10.4 Tiger and later." buttons {"Ignore", "Quit"} default button 2) is "Quit" then error number -128
-- Retrieve raw data --
tell application "iTunes" to set {every_artist, every_play} to {artist, played count} of the first playlist's tracks
set tracks to the length of every_artist
-- Tally up play counts --
@reefdog
reefdog / gist:3178666
Created July 25, 2012 21:03
Possible form validation autothing
(function($){
$.fn.observeRequirements = function(fnRequirementsMet, fnRequirementsUnmet) {
fnRequirementsMet = fnRequirementsMet || function(){}; // Empty fns may not be necessary
fnRequirementsUnmet = fnRequirementsUnmet || function(){};
var $wrappers = $(this); // I do this to help distinguish `this` once things get nesty
var requirementsMet = true;
$wrappers.each(function(){ // .each to support operating on element collections

Keybase proof

I hereby claim:

  • I am reefdog on github.
  • I am reefdog (https://keybase.io/reefdog) on keybase.
  • I have a public key ASCqa2f2aXw58ur8A3cWX9sfFhUJdckLLHEzty9K4_2lYAo

To claim this, I am signing this object:

@reefdog
reefdog / multiple_note_embed.html
Last active August 29, 2015 14:19
Embedding multiple DocumentCloud notes
<!-- The page DOM needs a container for each note, uniquely identified as `DC-note-{note_id}`. These can go anywhere in your page, though, so long as it's BEFORE the JavaScript below. -->
<div id="DC-note-{first_note_id}" class="DC-note-container"></div>
<div id="DC-note-{second_note_id}" class="DC-note-container"></div>
<div id="DC-note-{third_note_id}" class="DC-note-container"></div>
<!-- Only include the loader once; this and the other script tag should go at/near the bottom of the page. -->
<script src="//s3.amazonaws.com/s3.documentcloud.org/notes/loader.js"></script>
<script>
// Load each note individually.
@reefdog
reefdog / favstar-to-twitter.js
Created October 30, 2015 19:03
Favstar to Twitter redirect bookmarklet
(function() {
var href = window.location.href;
var parts = href.match(/favstar\.fm\/users\/([\w]{1,15})\/status\/([0-9]+)$/);
if (parts) {
window.location = 'https://twitter.com/' + parts[1] + '/status/' + parts[2];
}
})();
@reefdog
reefdog / twincities-css-override.css
Created December 3, 2015 21:13
Override rules to make DC viewer work on http://blogs.twincities.com/
#container .DV-docViewer,
#container .DV-docViewer-Container,
#container .DV-footer,
#container .DV-collapsibleControls,
#container .DV-textPage,
#container .DV-textContents,
#container .DV-thumbnails,
#container .DV-annotationContent,
#container .DV-annotationExcerpt,
#container .DV-annotationExcerptImage,
@reefdog
reefdog / petrify.js
Last active December 6, 2017 23:03
Redirect a GitHub URL to the last-committed version of that thing.
/*!
* Petrify
* Redirect yourself to a permanent version of a GitHub blob or tree.
*
* Say you're looking at `https://github.com/documentcloud/documentcloud/blob/master/public/javascripts/embed/search_embed.js#L315-L317`
* and you want to link to it in an email or GitHub comment. You realize that,
* when people follow the link years or even days later, it's likely the file
* will have changed so much that those line references won't be the same, and
* people won't know what you were talking about.
*
@reefdog
reefdog / document-embed-example.html
Last active February 18, 2016 21:31
Example of DocumentCloud document embed code
<div id="DV-viewer-282753-lefler-thesis" class="DV-container"></div>
<script src="//assets.documentcloud.org/viewer/loader.js"></script>
<script>
DV.load("https://www.documentcloud.org/documents/282753-lefler-thesis.js", {
sidebar: false,
text: false,
container: "#DV-viewer-282753-lefler-thesis"
});
</script>
<noscript>
@reefdog
reefdog / page-embed-example.html
Last active February 18, 2016 21:32
Example of DocumentCloud page embed code
<div class="DC-embed" data-version="1.1">
<div style="font-size:10pt;line-height:14pt;">
Page 1 of <a class="DC-embed-resource" href="https://www.documentcloud.org/documents/282753-lefler-thesis.html#document/p1" title="View entire Lefler Thesis on DocumentCloud in new window or tab" target="_blank">Lefler Thesis</a>
</div>
<img src="//assets.documentcloud.org/documents/282753/pages/lefler-thesis-p1-normal.gif?1455829953" srcset="//assets.documentcloud.org/documents/282753/pages/lefler-thesis-p1-normal.gif?1455829953 700w, //assets.documentcloud.org/documents/282753/pages/lefler-thesis-p1-large.gif?1455829953 1000w" alt="Page 1 of Lefler Thesis" style="max-width:100%;height:auto;margin:0.5em 0;border:1px solid #ccc;-webkit-box-sizing:border-box;box-sizing:border-box;clear:both">
<div style="font-size:8pt;line-height:12pt;text-align:center">
Contributed to
<a href="https://www.documentcloud.org/" title="Go to DocumentCloud in new window or tab" target="_blank" style="font-weight:700;font-fa
@reefdog
reefdog / note-embed-example.html
Created February 18, 2016 21:31
Example of DocumentCloud note embed code
<div id="DC-note-53674" class="DC-note-container"></div>
<script src="//assets.documentcloud.org/notes/loader.js"></script>
<script>
dc.embed.loadNote('//www.documentcloud.org/documents/282753-lefler-thesis/annotations/53674.js');
</script>
<noscript>
<a href="https://www.documentcloud.org/documents/282753-lefler-thesis/annotations/53674.html">View note</a>
</noscript>