Skip to content

Instantly share code, notes, and snippets.

View kwhitaker's full-sized avatar

Kevin Whitaker kwhitaker

View GitHub Profile
export function createCharacter(char) {
return dispatch => {
dispatch(submitCharacter(char));
return request.post('/new-character')
.send(JSON.stringify(char))
.then((response) => {
dispatch(routeToNewCharacter(response.body.id));
}, (error) => {
dispatch(receiveCharError(error.message));
});
@kwhitaker
kwhitaker / agent_interceptor.coffee
Created February 3, 2015 19:57
Decorator plugin for superagent.js, which lets you take actions on a response before the callback is fired.
# Use superagent's standard plugin architecture:
# superagent.get('/some/url').use(agentInterceptor).end(function(res){...});
agentInterceptor = (res) ->
Request = superagent.Request
oldCb = Request.prototype.callback
Request.prototype.callback = (err, r) ->
switch r.status
when 404
some404Func()
@kwhitaker
kwhitaker / DocCarousel.coffee
Created December 3, 2014 19:29
Slideshow/carousel plugin for jQuery
###
Multi-item carousel.
Written by Kevin Whitaker
Apply to a div to create a carousel out of a contained UL.
Animation is handled by CSS.
HTML structure looks like this:
<div id="#some-id">
<div class="carousel-wrap">
<ul class="carousel-list">
@kwhitaker
kwhitaker / gist:5438658
Created April 22, 2013 21:21
jsPlumb function that I'm having issues with
var adjustForParentOffsetAndScroll = function(xy, el) {
var offsetParent = null, result = xy;
if (el.tagName.toLowerCase() === "svg" && el.parentNode) {
offsetParent = el.parentNode;
}
else if (el.offsetParent) {
offsetParent = el.offsetParent;
}
if (offsetParent != null) {
@kwhitaker
kwhitaker / filters_view.js.coffee
Created March 5, 2012 17:13
Trying to scope back to currentView
class window.PlacementFiltersView extends Backbone.View
el: "#placements form#filters"
initialize: ->
currentView = @
# Create a hash of labels for the filter type-aheads
@filterLabels = []
jQuery(@el).find('.filter-top-level option').each ->
if jQuery(@).val() isnt ''
@kwhitaker
kwhitaker / gist:1827417
Created February 14, 2012 15:03
CSSLint command line rules reference
ids
Selectors should not contain IDs.
adjoining-classes
Don't use adjoining classes.
import
Don't use @import, use <link> instead.
box-sizing