Content :
This file contains hidden or 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 matchMediaPolyfill from 'mq-polyfill'; | |
matchMediaPolyfill(window); | |
window.matchMedia('(max-width: 640px)'); | |
window.matchMedia('(max-width: 768px)'); | |
window.matchMedia('(max-width: 1024px)'); | |
window.matchMedia('(max-width: 1280px)'); | |
window.resizeTo = function resizeTo(width, height): void { |
This file contains hidden or 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
/** | |
* Recursively convert any data structure to readonly (with handling of privimitives): | |
*/ | |
type DeepReadonlyObject<T> = { readonly [K in keyof T]: DeepReadonly<T[K]> }; | |
type DeepReadonly<T> = T extends (infer E)[] | |
? ReadonlyArray<DeepReadonlyObject<E>> | |
: T extends object ? DeepReadonlyObject<T> : T; |
This file contains hidden or 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
// Example of using Underscore's _.debounce function | |
// debounce is useful for situations where you get multiple events fired | |
// from one action. For example resize event is sent multiple times when | |
// window is resized | |
var reloadIfResizeChange = _.debounce(function() { | |
window.location.reload(); | |
}, 200); | |
window.addEventListener('resize', reloadIfResizeChange); |
This file contains hidden or 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 |
(From: https://raw.githubusercontent.com/gulpjs/gulp/master/docs/recipes/incremental-builds-with-concatenate.md)
The trouble with incremental rebuilds is you often want to operate on all processed files, not just single files. For example, you may want to lint and module-wrap just the file(s) that have changed, then concatenate it with all other linted and module-wrapped files. This is difficult without the use of temp files.
Use gulp-cached and gulp-remember to achieve this.
var gulp = require('gulp');
This file contains hidden or 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
# Install Virtualbox from Homebrew (or download and install manually https://www.virtualbox.org/wiki/Downloads) | |
brew cask install virtualbox | |
# Install Docker | |
brew install docker docker-machine docker-compose | |
# Create your VM | |
docker-machine create -d virtualbox default --virtualbox-cpu-count "2" --virtualbox-cpu-memory "4096" | |
docker-machine start |
This file contains hidden or 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
# Delete all containers | |
docker rm $(docker ps -a -q) | |
# Delete all images | |
docker rmi $(docker images -q) |
This file contains hidden or 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
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key | |
# that enables you to choose a character from a menu of options. If you are on Lion | |
# try it by pressing and holding down 'e' in any app that uses the default NSTextField | |
# for input. | |
# | |
# It's a nice feature and continues the blending of Mac OS X and iOS features. However, | |
# it's a nightmare to deal with in Atom if you're running vim mode, | |
# as it means you cannot press and hold h/j/k/l to move through your file. You have | |
# to repeatedly press the keys to navigate. |
This file contains hidden or 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
/* | |
Another way of splitting a gulpfile into multiple files based on: | |
http://macr.ae/article/splitting-gulpfile-multiple-files.html | |
https://github.com/gulpjs/gulp/blob/master/docs/recipes/split-tasks-across-multiple-files.md | |
*/ | |
'use strict'; | |
var gulp = require('gulp'), | |
plugins = require('gulp-load-plugins')(), |
NewerOlder