Skip to content

Instantly share code, notes, and snippets.

View brandondurham's full-sized avatar

Brandon Durham brandondurham

View GitHub Profile
@tomcask
tomcask / draftjs-force-selection.js
Created January 10, 2017 16:52
Example of force selection in draftjs
const getEditorState = this.props.store.getItem('getEditorState');
const setEditorState = this.props.store.getItem('setEditorState');
const selection = this.props.store.getItem('lastSelection');
const editorState = getEditorState();
const updateSelection = new SelectionState({
anchorKey: selection.anchorKey,
anchorOffset: selection.anchorOffset,
focusKey: selection.anchorKey,
focusOffset: selection.focusOffset,
isBackward: false,
@redgeoff
redgeoff / index.html
Last active March 30, 2022 06:15
Pinch Zoom And Pan With HammerJS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<title>Pinch Zoom</title>
</head>
<body>
@markerikson
markerikson / appEntryPoint.js
Last active August 1, 2022 07:41
Webpack React/Redux Hot Module Reloading (HMR) example
import React from "react";
import ReactDOM from "react-dom";
import configureStore from "./store/configureStore";
const store = configureStore();
const rootEl = document.getElementById("root");
@dhbradshaw
dhbradshaw / init.coffee
Last active September 24, 2021 08:06
Customize tab titles in atom text editor.
# place this snippet into init.coffee in ~/.atom directory
atom.workspace.observeTextEditors (editor) ->
if editor.getTitle() isnt "untitled"
sp = editor.getPath().split('/')
title = sp.slice(sp.length-2).join('/')
editor.getTitle = -> title
editor.getLongTitle = -> title
for item in atom.workspace.getPaneItems()
import React from 'react';
const IGNORE_CLASS = 'ignore-react-onclickoutside';
export default function clickOutside(BaseComponent) {
return class ClickOutside extends React.Component {
static displayName = `${BaseComponent.name}ClickOutside`;
@jshbrntt
jshbrntt / pan-zoom-image.js
Last active October 16, 2018 11:10
A simple way of panning and zooming an image using Hammer.js.
// <img id="myimage" src="http://placecage/1280/720">
var image = document.getElementById('myimage');
var mc = new Hammer.Manager(image);
var pinch = new Hammer.Pinch();
var pan = new Hammer.Pan();
pinch.recognizeWith(pan);
@kellysutton
kellysutton / gist:c08398b77e1adadc2478
Created January 15, 2015 04:37
CSS Challenge Ideas

CSS Challenge Ideas

@ecarter
ecarter / mapOrder.js
Created December 2, 2011 15:40
Order an array of objects based on another array order
/**
* Sort array of objects based on another array
*/
function mapOrder (array, order, key) {
array.sort( function (a, b) {
var A = a[key], B = b[key];
@shimondoodkin
shimondoodkin / WebKit contentEditable focus bug workaround.html
Created July 13, 2011 19:28
WebKit contentEditable focus bug workaround
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>WebKit contentEditable focus bug workaround</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.2.js'></script>
<script type='text/javascript'>
//<![CDATA[
$(function(){