Skip to content

Instantly share code, notes, and snippets.

View davidfurlong's full-sized avatar
👨‍💻

David Furlong davidfurlong

👨‍💻
View GitHub Profile
Add to header (after selectize.css)
<style>
.selectize-input input[type="text"] {
border:1px solid #d0d0d0 !important;
background:white !important;
padding:4px !important;
min-width:100px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1);
@davidfurlong
davidfurlong / proximitysearch.js
Created July 30, 2014 23:02
Proximity Search
// Returns the score if within the proximity, else returns -1
Array.prototype.indexOfAll = function(term) {
if(typeof term == 'object'){
console.error('indexOfAll expects an array of terms as an argument');
return;
}
var posOfTerms = [];
for(i in this){
if(this[i] == term){

Keybase proof

I hereby claim:

  • I am davidfurlong on github.
  • I am graph (https://keybase.io/graph) on keybase.
  • I have a public key whose fingerprint is 09E5 4284 984D BE6D 3338 5A78 52BB 204B 2564 24F7

To claim this, I am signing this object:

@davidfurlong
davidfurlong / stickfooter.css
Created October 15, 2014 18:37
Sticky footer that actually works
html {
position: relative;
min-height: 100%;
}
body {
margin: 0 0 100px; /* bottom = footer height */
}
footer {
position: absolute;
left: 0;
var Col = require('react-bootstrap/lib/Col')
var PageHeader = require('react-bootstrap/lib/PageHeader')
var React = require('react')
var Row = require('react-bootstrap/lib/Row')
var {connect} = require('react-redux')
var {reduxForm} = require('redux-form')
var DateInput = require('./DateInput')
var FormField = require('./FormField')
var LoadingButton = require('./LoadingButton')
@davidfurlong
davidfurlong / disableSSR.js
Last active March 16, 2017 14:25
disable server side rendering for a react component [hacky]
/*
A react higher order component (HOC) for disabling server side rendering (SSR) for a particular component.
Useful if a particular library / page doesn't support SSR and you
a) dont want to mess around with the server routing to handle it
b) dont want to the component to even be constructed on the server
c) dont want to modify the component's methods to handle loading the library on the client
(for example, you need to use window/client methods in the constructor)
DISCLAIMER: this is hacky, and will throw a console warning (in development) that the checksum is invalid (which means server & client rendering dont agree on HTML string)
@davidfurlong
davidfurlong / statelessHOCwithContext.js
Created March 26, 2017 12:57
React HOC which returns a Stateless Functional component which has contextTypes or defaultProps or propTypes
/* its not immediately obvious how to do this, which is why I've added it here */
const connectSubmitButton = (WrappedComponent) => {
const connectContext = (props, context) => (<WrappedComponent {...props} _reduxForm={context._reduxForm} />);
connectContext.contextTypes = {
_reduxForm: PropTypes.object.isRequired
};
return connectContext;
};
@davidfurlong
davidfurlong / conditional_js_property.js
Created April 17, 2017 07:34
Conditional js property
const _ = (obj, cond = (val) => typeof val === 'undefined' || val === null) =>
Object.assign({},
...(Object.keys(obj).map(key =>
cond(obj[key]) ? {} : {
[key]: obj[key]
})
)
);
/*

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@davidfurlong
davidfurlong / RoutedTabs.js
Last active January 8, 2018 14:35
Ant design + react-router v3 - Tabs with routes.
import React from 'react';
import { Tabs } from 'antd';
import PropTypes from 'prop-types';
import { browserHistory } from 'react-router';
function isLeftClickEvent(event) {
return event.button === 0;
}
function isModifiedEvent(event) {