Instantly share code, notes, and snippets.

Dima Lebedynskyi dlebedynskyi

  • Magic Leap
  • Florida, US
View GitHub Profile
@dlebedynskyi
dlebedynskyi / LoadableWebpackPlugin.js
Created Nov 20, 2018
loadable-component emit file webpack plugin
View LoadableWebpackPlugin.js
const path = require('path')
const fs = require('fs')
class LoadablePlugin {
constructor({ filename = 'loadable-stats.json', writeToDisk = false } = {}) {
this.opts = { filename, writeToDisk }
}
gather = (hookCompiler, callback) => {
const stats = hookCompiler.getStats().toJson({
View use-change-log.hook.js
/**
`useChangeLog` - dev-mode helper hook to let you
know why a memoized component re-rendered!
Usage example:
const YourComponent = React.memo((props) => {
// Just drop this fella into your memo component's body.
useChangeLog(props);
@dlebedynskyi
dlebedynskyi / package.json
Created Jan 27, 2018
sample-nodmon - with latest
View package.json
{
"name": "sample-nodemon",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"nodemon": "^1.14.11",
"pack-with-jsbn": "../pack-with-jsbn"
}
}
@dlebedynskyi
dlebedynskyi / package.json
Created Jan 27, 2018
sample-nodemon - no nodemon
View package.json
{
"name": "sample-nodemon",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"pack-with-jsbn": "../pack-with-jsbn"
}
}
View package.json
{
"name": "pack-with-jsbn",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"jsbn": "^1.1.0"
}
}
View LasyImage.jsx
class LazyImage extends PureComponent {
static defaultProps = {
engage: false,
};
state = {
initialEngage: false,
};
componentWillMount() {
View workbox.config.js
const fs = require('fs');
const path = require('path');
const loadJsonFile = require('load-json-file');
const dotNext = path.resolve(__dirname, '.next');
const stats = loadJsonFile.sync(`${dotNext}/build-stats.json`);
const buildId = fs.readFileSync(`${dotNext}/BUILD_ID`, 'utf8');
@dlebedynskyi
dlebedynskyi / operator_with_ligatures.md
Created Jul 8, 2017 — forked from renatorib/operator_with_ligatures.md
Using Operator Mono with Fira Code ligatures in Atom.
View operator_with_ligatures.md

Using Operator Mono with Fira Code ligatures in Atom.

  1. Open your Atom's Stylesheet
    image

  2. Put this css

atom-text-editor {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
@dlebedynskyi
dlebedynskyi / get_nested.js
Created Apr 13, 2017
get deep nested object prop. functional way.
View get_nested.js
// https://medium.com/javascript-inside/safely-accessing-deeply-nested-values-in-javascript-99bf72a0855a
const idx = p => o =>
p.reduce((xs, x) =>
(xs && xs[x]) ? xs[x] : null, o)
const getUserComments = idx(['posts', 0, 'comments'])
const user = {}
console.log(getUserComments(user))
@dlebedynskyi
dlebedynskyi / sw-test-cleaup.js
Created Mar 23, 2017 — forked from gauntface/sw-test-cleaup.js
Function to unregister SW and clear out old caches.
View sw-test-cleaup.js
window.__testCleanup = () => {
const unregisterSW = () => {
return navigator.serviceWorker.getRegistrations()
.then((registrations) => {
const unregisterPromise = registrations.map((registration) => {
return registration.unregister();
});
return Promise.all(unregisterPromise);
});
};