Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Fraser afraser

  • Rocket Insights
  • Newburyport, MA
View GitHub Profile
@afraser
afraser / apiclient.js
Created Jul 8, 2021
An axios-like wrapper around the fetch api that automatically aborts requests under a duplicate key. Provides an abort helper, and handles auth via aws-amplify.
View apiclient.js
import Auth from '@aws-amplify/auth'
/**
USAGE:
> api.post(`users/${id}`, { email: 'asdf@asdf.com' })
> api.get('users/${id}')
> api.patch(`users/${id}`, { email: 'adam@asdf.com' })
> api.delete(`users/${id}`)
*/
class ApiClient {
View FileDropzone.js
import React, { useState, useEffect, useRef } from 'react'
import cx from 'classnames'
import css from './FileDropzone.sass'
export function FileDropzone ({ onDrop, children }) {
const [dragging, setDragging] = useState(0)
const dropRef = useRef()
const handleDrag = evt => {
@afraser
afraser / draftjs_inline_equations.js
Last active May 11, 2021
Demonstrates inline equations with copy/paste supported in draft.js
View draftjs_inline_equations.js
<!--
Copyright (c) 2013-present, Facebook, Inc. All rights reserved.
This file provided by Facebook is for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
View boundless editor
import React, { Component, PropTypes } from 'react'
import Toolbar from 'containers/Toolbar'
import InlineMath, { forceUpdateEquation } from 'containers/InlineMath'
import EquationEditor from 'components/EquationEditor'
import { Editor, EditorState, ContentState, SelectionState, Entity, CompositeDecorator, Modifier, convertToRaw, RichUtils } from 'draft-js'
const SUPPORTED_COMMANDS = [ 'italic' ]
function findTex(contentBlock, callback) {
contentBlock.findEntityRanges(
@afraser
afraser / cookie_monster.coffee
Last active Aug 29, 2015
How about a Backbone model as an interface for setting and getting guest cookies?
View cookie_monster.coffee
View dabblet.css
/**
* Scroll bug
*/
*{
box-sizing: border-box;
}
input, textarea{
box-sizing: content-box;
}
@afraser
afraser / dabblet.css
Created Aug 3, 2012
The first commented line is your dabblet’s title
View dabblet.css
/**
* The first commented line is your dabblet’s title
*/
*{
+box-sizing(border-box)
}
input, textarea
+box-sizing(content-box)
.menu{x-sizing(border-box)
View dabblet.css
/**
* Toggle switch
*/
*{
box-sizing: border-box;
}
input, textarea{
box-sizing: content-box;
}
body{
View dabblet.css
/**
* ribbon banner
*/
body{
background: #333;
padding: 35px 0 0;
position: relative;
}
.ribbon {
@afraser
afraser / dabblet.css
Created Jul 20, 2012
Boundless Plus v2 layout - Hodgie
View dabblet.css
/* Boundless Plus v2 layout - Hodgie */
html {
height: 100%;
max-height: 100%;
}
body {
margin: 0;
background-color: #333;
height: 100%;
max-height: 100%;