Skip to content

Instantly share code, notes, and snippets.

View lukekarrys's full-sized avatar

Luke Karrys lukekarrys

View GitHub Profile
@lukekarrys
lukekarrys / chart.js
Created May 16, 2014 08:44
how to make a google chart that looks just like the little ones in the google analytics dashboard
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Name', 'Height',],
['X', 97],
['Y', 97]
]);
// Create and draw the visualization.
new google.visualization.ImageLineChart(document.getElementById('visualization')).
@lukekarrys
lukekarrys / exportDir.js
Created March 16, 2015 07:42
Write an index file to a directory which a require for each file in the dir
var fs = require('fs');
var path = require('path');
var filename = function (file) {
return path.basename(file, path.extname(file));
};
module.exports = function exportDirectory (dir) {
var dirPath = path.resolve(__dirname, dir);
@lukekarrys
lukekarrys / anthonyify.js
Created August 16, 2011 20:18
Anthonyify
function walk(a,b){var c,d,e=0;do c||(c=b.call(a,e)===!1),!c&&(d=a.firstChild)?++e:(d=a.nextSibling)?c=0:(d=a.parentNode,--e,c=1),a=d;while(e>0)}walk(document.documentElement,function(){if(this.nodeType==3)this.nodeValue=this.nodeValue.replace(/./g,"ANTHONY")});
@lukekarrys
lukekarrys / calculate-points.js
Created April 23, 2012 03:26
Calculate total PF and PA for an NBA team from ESPN schedule page
var pointsFor = 0, pointsAgainst = 0;
jQuery('.mod-content .game-schedule .score').each(function() {
var score = jQuery(this),
win = score.prev().hasClass('win'),
scoreText = score.children('a').text().split('-'),
s1 = parseInt(scoreText[0], 0),
s2 = parseInt(scoreText[1], 0);
pointsFor += (win) ? s1 : s2;
pointsAgainst += (win) ? s2 : s1;
@lukekarrys
lukekarrys / pluck.js
Created November 14, 2012 21:36
Pluck URL Param
/* Got this from Instagram Profile Pages http://d36xtkk24g8jdx.cloudfront.net/bluebar/c535104/scripts/bluebar.js */
function get_param(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
);
}
@lukekarrys
lukekarrys / formatDate.js
Created May 21, 2013 21:13
Something about formatting two dates to be displayed as a range
var dateFormat = require('dateformat');
var formatDateRange = function (startProp, endProp) {
var monthFormat = 'm',
dayFormat = 'd',
yearFormat = 'yy',
separator = '/',
startFormat = monthFormat + separator + dayFormat + separator + yearFormat,
endFormat = monthFormat + separator + dayFormat + separator + yearFormat,
origStartFormat = startFormat,
startDate = new Date(this.get(startProp)),
var _ = require('underscore');
var inherits = require('inherits');
var delegateEventSplitter = /^(\S+)\s*(.*)$/;
module.exports = function (SuperView) {
function JQueryView(attrs) {
SuperView.apply(this, arguments);
// Since $el is a derived property we cant rely on ampersand-view's
// internal _handleElementChange since that will delegate events
@lukekarrys
lukekarrys / requirebin.md
Last active December 7, 2016 17:44
requirebin sketch
@lukekarrys
lukekarrys / README.md
Last active December 7, 2016 17:46
eslint-plugin-import 2.0.0 newline-after-import rule crash
@lukekarrys
lukekarrys / README.md
Last active December 7, 2016 17:48
react-router-redux bug