Skip to content

Instantly share code, notes, and snippets.

View noopnik's full-sized avatar

Nikita noopnik

View GitHub Profile
@noopnik
noopnik / protips.js
Last active August 29, 2015 14:24 — forked from nolanlawson/protips.js
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@noopnik
noopnik / gulpfile.js
Last active August 29, 2015 14:27 — forked from darkwing/gulpfile.js
var gulp = require('gulp');
var runSequence = require('run-sequence');
var minifyCss = require('gulp-minify-css');
var buildDir = './build/';
var minifyCssSettings = { advanced: true, aggressiveMerging: true };
// Main build
gulp.task('build', function() {
@noopnik
noopnik / what-forces-layout.md
Last active September 22, 2015 09:35 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

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()
@noopnik
noopnik / simple-nodejs-iv-encrypt-decrypt.js
Created July 28, 2016 10:13 — forked from yoavniran/simple-nodejs-iv-encrypt-decrypt.js
nodejs crypto - simple encrypt & decrypt using IV (Initialization Vector)
"use strict";
var crypto = require("crypto");
var EncryptionHelper = (function () {
function getKeyAndIV(key, callback) {
crypto.pseudoRandomBytes(16, function (err, ivBuffer) {
var keyBuffer = (key instanceof Buffer) ? key : new Buffer(key) ;
@noopnik
noopnik / ip4
Created December 7, 2016 17:25 — forked from DeadAlready/ip4
IPv4 firewall setup
*filter
# Default policy is to drop all traffic
-P INPUT DROP
-P FORWARD DROP
-P OUTPUT DROP
# Allow all loopback traffic
-A INPUT -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
@noopnik
noopnik / on-jsx.markdown
Created December 14, 2016 08:39 — forked from chantastic/on-jsx.markdown
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I lead the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can'

@noopnik
noopnik / Enhance.js
Created January 12, 2017 22:35 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@noopnik
noopnik / .eslintrc.js
Last active February 8, 2017 16:32
Eslintrc for React
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true
},
"ecmaFeatures": {
"jsx": true,
"modules": true,
export const authInterceptor = ({ dispatch }) => next => action => {
if (action.status === 401) {
Promise.resolve(dispatch(refreshToken()).then(() =>
next(action)
, (error) => {
console.log(error);
dispatch(logout());
}
));
} else {
{
"extends": "airbnb",
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"impliedStrict": false
}