Skip to content

Instantly share code, notes, and snippets.

View mcsheffrey's full-sized avatar

Connor McSheffrey mcsheffrey

View GitHub Profile
@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');
@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 / 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 / gist:1991635
Created March 7, 2012 07:32
Is this bad?
this.current += ~~( dir === 'next') || -1;
contains(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return true;
}
}
return false;
}
@mcsheffrey
mcsheffrey / gist:2552977
Created April 29, 2012 20:05
jQuery each, for and closure
// OMG I heard jQuery.fn.each was like a HUGE perf hit!
// So I'm going to use a native for loop instead!
var lis = $("li"),
l = lis.length, // 5
li;
for (var i=0;i<l;i++) {
li = lis.eq(i);
li.click(function() {
alert("You clicked the "+ i +"th item");
// No matter which item is clicked, it always alerts 5!
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" lang="en" class="js flexbox flexbox-legacy canvas canvastext no-webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths ios"><head><link rel="stylesheet" type="text/css" href="//s7.addthis.com/static/r07/widget082.css" media="all">
<title>Oncology Clinical Trials - Genentech BioOncology - BioOncology</title>
<meta name="keywords" content="oncology clinical trials, clinical trials, clinical studies, cancer trials, Genentech">
<meta name="description" content="Find oncology clinical trials based on tumor type, phase, drug, city, and state.">
<meta name="google-site-verification"
$('body').on('touchstart', function(event) {
http://www.youtube.com/watch?v=PECk9A-07Pw
});
@mcsheffrey
mcsheffrey / gist:4265121
Created December 12, 2012 05:37
¯\_(ツ)_/¯
¯\_(ツ)_/¯
@mcsheffrey
mcsheffrey / gist:6407659
Created September 1, 2013 22:13
Example Module pattern
carousel = function(){
var config = {
CSS:{
classes:{
current:'current',
scrollContainer:'scroll'
},
IDs:{
maincontainer:'carousel'
}