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
interface Item { | |
type: string; | |
} | |
const listA: Item[] = [ | |
{ type: 'a' }, | |
{ type: 'b' }, | |
{ type: 'c' }, | |
]; | |
const listB: Item[] = [ |
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
\.( | |
[a-z]+ | |
(-(?!-))?)+ | |
(?: | |
__ | |
([a-z]+(-(?!-))?)+ | |
)? | |
(?: |
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
// @flow | |
/** | |
* Scale an input number between an input range proportionally down to be | |
* in an output range. | |
* | |
* @param {number} input - Input number. | |
* @param {Array<number, number>} inputRange - The input range. | |
* @param {Array<number, number>} outputRange - The output range. | |
* |
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
/** | |
* Get the position of a point on a circle. | |
* | |
* @param {number} radius - Radius of the circle. | |
* @param {number} angle - Angle of the point to calculate. | |
* @param {number} offset - How far outside the circle the point should fall. | |
* @param {number} dotSize - Adjust for the size of the dot. | |
* | |
* @returns {object} results for top and left coords. | |
*/ |
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
/** | |
* Calculate VWAP (volume weighted average price) for a list of bids. | |
* | |
* @param {number} total - Total shares bought. | |
* @param {Array<number, number>} positions - Tuples of position data. The first | |
* index is the amount of shares, the | |
* second index is the price of the | |
* shares. | |
* | |
* @example |
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
// Override the `isRequired` validation of a list of props for another, single | |
// prop. For example, if you had a number of props used to generate a URL path, | |
// you could require all of them *unless* a full path was passed as a prop. | |
// | |
// @param {array} toOverride - Array of strings to 'override', or ignore. | |
// @param {function} [type] - PropType validation function. Optional. | |
// @param {boolean} [required] - Validate the prop as required. Optional. | |
// | |
// @returns {function} Callback function for custom prop validation. | |
// See the `customProp` in http://bit.ly/1nhwVQ3. |
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
// Convert a ratio into a percentage. Useful for responsive images and videos. | |
// https://gist.github.com/brianmcallister/03b9038b45c02dabba3a779efc6c4e38 | |
// | |
// $ratio - 2 item list of integers. Represents a ratio. Defaults to 1:1. | |
// | |
// Examples | |
// | |
// ratio-as-percentage(); | |
// #=> 100% | |
// |
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
# Public: Natural sort an array. | |
# https://gist.github.com/brianmcallister/f0e77c185f4a0d6f7172 | |
# Ported to CoffeeScript from: http://www.davekoelle.com/files/alphanum.js | |
# See: http://www.davekoelle.com/alphanum.html | |
# | |
# This function has been modified to support passing in an array as an | |
# argument, as opposed to attaching this function to the Array prototype. | |
# | |
# array - Array to natural sort. | |
# |
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
# Private: Highlight individual words within the message text. | |
# | |
# text - Text to format. | |
# words - Array of words to highlight. | |
# | |
# Returns the formatted text. | |
highlightWords = (text, words = []) -> | |
return text if words.length is 0 | |
# Create a DOM element to contain the text so we can detect and handle |
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
# Parse the query string params. | |
# https://gist.github.com/brianmcallister/94d89b3c50b2b9e98f6d | |
# | |
# Examples | |
# | |
# If the query string is: | |
# test=test&foo&a=truee&bool=false&num=10 | |
# | |
# parseQueryParams() | |
# #=> {"test": "test", "foo": "", "a": "truee", "bool": false, "num": 10} |
NewerOlder