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; |
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 |
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: { |
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(); |
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 |
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, |
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 | |
}); |
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() | |
}); |
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; |
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