View gist:3cdb000b5f2816a70041c1306edc97f4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const maybeSelectConsecutiveEntity = editorState => { | |
const selection = editorState.getSelection(); | |
if (!selection.isCollapsed()) { | |
return editorState; | |
} | |
const startKey = selection.getStartKey(); | |
const startOffset = selection.getStartOffset(); | |
const prevOffset = startOffset - 1; |
View callModifierForSelectedBlocks.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { EditorState, SelectionState } from 'draft-js'; | |
import getSelectedBlocks from './getSelectedBlocks'; | |
/** | |
* Calls a provided `modifier` function with a selection for each | |
* selected block in the current editor selection. Passes through additional | |
* arguments to the modifier. | |
* | |
* Note: At the moment it will retain the original selection and override |
View gulpfile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var gulp = require('gulp'); | |
var del = require('del'); | |
var mocha = require('gulp-mocha-co'); | |
var istanbul = require('gulp-istanbul'); | |
var isparta = require('isparta'); | |
var coverageEnforcer = require('gulp-istanbul-enforcer'); | |
var paths = { | |
server: { |
View 0_example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createStore, applyMiddleware, compose } from 'redux'; | |
import request from 'superagent-es6-promise'; | |
import thunkMiddlware from 'redux-thunk'; | |
import promiseMiddleware from 'redux-promise'; | |
import logMiddleware from './middleware/log'; | |
import requestMiddleware from './middleware/request'; | |
// Create request middleware with our execute logic, return promise. | |
const executeRequestMiddleware = requestMiddleware((req, getState) => { | |
const { session: { token } } = getState(); |
View .js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// utils/calculateMiddlePoint.js | |
export default (touchA, touchB) => { | |
const diffX = touchA.pageX - touchB.pageX; | |
const diffY = touchA.pageY - touchB.pageY; | |
return Math.sqrt(Math.pow(diffX, 2) + Math.pow(diffY, 2)); | |
}; | |
// utils/calculateDistance.js |
View gist:e6e6e2152b96663db4a9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var React = require('react-native'); | |
var { | |
AppRegistry, | |
Component, | |
StyleSheet, | |
NavigatorIOS, | |
TabBarIOS, |
View gist:e48acd0a820bb322790b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var UIManager = require('NativeModules').UIManager; | |
// in your component, use whatever ref you have defined on the | |
// view you want to measure | |
UIManager.measure(this.refs.view.getNodeHandle(), (frameX, frameX, frameWidth, frameHeight, pageX, pageY) => { | |
// do something with the measured values | |
}); |
View gist:10eaf4f0d55ee2f9132f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Joi.object().required().keys({ | |
referenceParentId : Joi.number().integer().when('isReference', {is: true, then: Joi.required(), otherwise: Joi.forbidden()}), | |
isReference : Joi.boolean().required() | |
}); |
View json_manipulator.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json) | |
RETURNS json | |
LANGUAGE sql | |
AS $$ | |
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json | |
FROM ( | |
SELECT * FROM json_each(data) | |
UNION ALL | |
SELECT * FROM json_each(insert_data) | |
) t; |
View gist:f163d62924dd9d29dff9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Backbone = require('backbone'); | |
var _ = require('lodash'); | |
// extend `Backbone.AssociatedModel` with a create method, which will be | |
// used to create new models for us, instead of using `new` | |
// shamelessly inspired by Supermodel | |
var Cached = Backbone.AssociatedModel.extend({ | |
_cached: false, | |
_ref: 0, | |
ref: function () { |
NewerOlder