Skip to content

Instantly share code, notes, and snippets.

View TheHanna's full-sized avatar

Brian Hanna TheHanna

View GitHub Profile
@TheHanna
TheHanna / Foundation-Abide-Multiple-Events-Firing.markdown
Created March 17, 2015 20:10
Foundation Abide Multiple Events Firing

Foundation Abide Multiple Events Firing

When you use Foundation's Abide form validation with the data-abide="ajax" attribute, every time you click submit, n+1 events are fired.

A Pen by Brian Hanna on CodePen.

License.

@TheHanna
TheHanna / googleDriveOAuth2Middleware.js
Last active November 22, 2015 16:10
Google Drive API credential generation/token refreshing in MEAN.js
// This is valid for MEAN.js 0.4.0
// Requires a couple of changes to work:
// Add Drive scope to users Express route
// Modify the Passport.js google strategy to put a token expiration date into the database
// User middleware function below to auth API calls
exports.requiresOAuth2Token = function (req, res, next) {
var OAuth2 = google.auth.OAuth2;
var client = new OAuth2(config.google.clientID, config.google.clientSecret, config.google.callbackURL);
client.setCredentials({
@TheHanna
TheHanna / ajax.js
Last active February 16, 2016 19:41 — forked from xeoncross/ajax.js
Simple, cross-browser Javascript POST/GET xhr request object. Supports request data and proper AJAX headers.
/**
* @function ajax
* @desc IE 5.5+, Firefox, Opera, Chrome, Safari XHR object
* @param {string} url - The URL of the resource being requested
* @param {function} callback - Function to execute on successful response
* @param {mixed} data - Data to be sent with POST request
*/
function ajax(url, callback, data) {
try {
var xhr = this.XMLHttpRequest || ActiveXObject,
@TheHanna
TheHanna / Gruntfile.js
Last active February 25, 2016 19:14 — forked from strathmeyer/Gruntfile.js
A simple, blank Gruntfile
module.exports = function(grunt) {
grunt.initConfig({
});
// grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('default', ['']);
};
@TheHanna
TheHanna / app.py
Last active June 23, 2016 13:11
Flask by Example - Part 5
# just including the /resuluts/<job_key> route
@app.route('/results/<job_key>', methods=['GET'])
def get_results(job_key):
job = Job.fetch(job_key, connection=conn)
if job.is_finished:
result = Result.query.filter_by(id=job.result).first()
results = sorted(
result.result_no_stop_words.items(),
@TheHanna
TheHanna / gulpfile.babel.js
Last active April 27, 2017 21:47 — forked from danharper/gulpfile.js
New ES6 project with Babel, Browserify & Gulp (ES6 Gulpfile w/ glob for Windows compatibility)
const gulp = require('gulp');
const glob = require('glob');
const sourcemaps = require('gulp-sourcemaps');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const browserify = require('browserify');
const watchify = require('watchify');
const babel = require('babelify');
function compile(watch) {