Skip to content

Instantly share code, notes, and snippets.

View mcsheffrey's full-sized avatar

Connor McSheffrey mcsheffrey

View GitHub Profile
@mcsheffrey
mcsheffrey / replace-and-shake.js
Created February 4, 2012 04:10 — forked from lukekarrys/ README.md
Replace all characters in text nodes that are not spaces and then "shake" the body
(function(undefined) {
var
deviateMin = 1,
deviateMax = 10,
marginSeed = 20,
paddingSeed = 20,
madnessInterval = 20,
findRegex = new RegExp(/[^ ]/g),
replaceText = "CONNOR ",
random = function(min, max) {
@mcsheffrey
mcsheffrey / fiddle.html
Created February 4, 2012 04:10 — forked from lukekarrys/ README.md
Pitchfork Review Score Scraper
<h4>Query</h4>
<p>Artist: <span id="artist">wil</span></p>
<p>Album: <span id="album">yankee</span></p>
<hr/>
<h4>Result</h4>
<p>Artist: <span id="result_artist"></span></p>
<p>Album: <span id="result_album"></span></p>
<p>Score: <span id="score"></span></p>
@mcsheffrey
mcsheffrey / replaceIn.js
Created February 4, 2012 04:10
Find and replace HTML with arbitrary text using Node
var jsdom = require('jsdom'),
fs = require('fs'),
allLinks = JSON.parse(fs.readFileSync('/Users/lkarrys/melt-git/IAC/bundles/common/src/main/resources/site/lib/helpers/data/link-like-data.nav', 'utf-8')),
file = process.argv[2];
if (!file) throw('it');
fs.readFile(file, 'utf-8', function(err, data) {
jsdom.env({html: '<html><body>'+data+'</body></html>', scripts: ['http://code.jquery.com/jquery-1.7.min.js']}, function (err, window) {
var $ = window.jQuery, $body = $('body'), linkLikes = $body.find('span.link-likes');