Skip to content

Instantly share code, notes, and snippets.

Ian VanSchooten IanVS

Block or report user

Report or block IanVS

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thevangelist
thevangelist / my-component.spec.js
Created Aug 4, 2016
The only React.js component test you'll ever need (Enzyme + Chai)
View my-component.spec.js
import React from 'react';
import { shallow } from 'enzyme';
import MyComponent from '../src/my-component';
const wrapper = shallow(<MyComponent/>);
describe('(Component) MyComponent', () => {
it('renders without exploding', () => {
expect(wrapper).to.have.length(1);
});
@jmreidy
jmreidy / test_mocha.opts
Last active Jan 9, 2018
Unit test React Native with Mocha
View test_mocha.opts
--compilers js:./test/support/compiler
--require ./test/support/init
@mmrko
mmrko / mocha-react-css-modules.js
Last active Dec 28, 2018
Mocha & React & CSS Modules with Sass
View mocha-react-css-modules.js
// setup.js
import hook from 'css-modules-require-hook'
import sass from 'node-sass'
hook({
extensions: [ '.scss' ],
preprocessCss: data => sass.renderSync({ data }).css
})
@paulirish
paulirish / what-forces-layout.md
Last active Jun 19, 2019
What forces layout/reflow. The comprehensive list.
View what-forces-layout.md

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@jhliberty
jhliberty / ember-config-environment.js
Created Jun 12, 2015
Basic JWT Auth for Seeds.js/Sane Stack (aka Ember on Sails)
View ember-config-environment.js
var ENV = {
modulePrefix: 'frontend',
environment: environment,
baseURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
}
@justinwoo
justinwoo / using-rxjs-instead-of-flux-with-react.md
Last active May 20, 2019
Using RxJS instead of Flux with React to organize data flow
View using-rxjs-instead-of-flux-with-react.md

Reposted from Qiita

For almost a year now, I've been using this "flux" architecture to organize my React applications and to work on other people's projects, and its popularity has grown quite a lot, to the point where it shows up on job listings for React and a lot of people get confused about what it is.

Why I'm tired of using and teaching flux

There are a billion explainations on the internet, so I'll skip explaining the parts. Instead, let's cut to the chase -- the main parts I hate about flux are the Dispatcher and the Store's own updating mechanism.

If you use a setup similar to the examples in facebook/flux, and you use flux.Dispatcher, you probably have this kind of flow:

@mphasize
mphasize / beforeBlueprint.js
Created Mar 2, 2015
Sails-beforeBlueprint-Policy
View beforeBlueprint.js
/**
* beforeBlueprint
*
* @module :: Policy
* @description :: Simple policy to enable hooks into the model which can act upon req, res objects.
* @docs :: http://sailsjs.org/#!documentation/policies
*
*/
var actionUtil = require( 'sails/lib/hooks/blueprints/actionUtil' );
@LeoCavaille
LeoCavaille / .gitconfig
Last active Dec 3, 2015
How to properly rebase and deal with a contributor's PR
View .gitconfig
[alias]
checkoutpr = "!f() { git fetch origin refs/pull/$1/head:pr/$1; git checkout pr/$1; } ; f"
checkoutcontrib = "!f() { git checkout master && git pull && git remote add $1 git@github.com:$1/dd-agent && git fetch $1 $2 && git checkout -b $3 $1/$2 && git rebase master } ; f"
View iterm-commands
# Add this to .zshrc for VIM modes in shell....holy shit, amazing!!!!
# although this does effect the ability to scroll through bash history with ctlr+p, ctrl+n, if ctrl is remapped to cap locks via
# system preferences
bindkey -v
# preferences > keys -- hotkey to open iterm = option+space
# preferences > keys -- change hotkeys for moving previous/next tabs to more similar to VIM, combo with h (previous) l (next)
# preferences > profiles > keys -- right and/or left option key to +Esc, allows easier navigating of words in command line
commands:
@staltz
staltz / introrx.md
Last active Jun 19, 2019
The introduction to Reactive Programming you've been missing
View introrx.md
You can’t perform that action at this time.