Skip to content

Instantly share code, notes, and snippets.

View dlebedynskyi's full-sized avatar

Dima Lebedynskyi dlebedynskyi

View GitHub Profile
@dlebedynskyi
dlebedynskyi / import-transform.js
Last active September 12, 2022 21:12
jscodeshift transform to update imports from one package to another
module.exports.parser = 'tsx';
module.exports = function transformer(file, api, options) {
const j = api.jscodeshift;
const root = j(file.source);
const { from: fromPath, to: toPath } = options;
const jestLookFor = ["mock", "doMock"];
replaceImports();
@dlebedynskyi
dlebedynskyi / Readme.md
Created April 29, 2021 16:06
day.js patch for @formatjs/Intl polyfill
@dlebedynskyi
dlebedynskyi / bookmark.md
Last active November 19, 2020 18:25
wipe cookies and reload

one line

(function () {
    var cookies = document.cookie.split("; ");
    for (var c = 0; c < cookies.length; c++) {
        var d = window.location.hostname.split(".");
        while (d.length > 0) {
            var cookieBase = encodeURIComponent(cookies[c].split(";")[0].split("=")[0]) + '=; expires=Thu, 01-Jan-1970 00:00:01 GMT; domain=' + d.join('.') + ' ;path=';
            var p = location.pathname.split('/');
@dlebedynskyi
dlebedynskyi / git-apply-patch.md
Last active May 11, 2020 18:07 — forked from emmanueltissera/git-apply-patch.md
Generate a git patch for a specific commit #git

Creating the patch

git format-patch -1 <sha>
OR
git format-patch -1 HEAD

Applying the patch

git apply --stat file.patch # show stats.
git apply --check file.patch # check for error before applying

@dlebedynskyi
dlebedynskyi / LoadableWebpackPlugin.js
Created November 20, 2018 23:22
loadable-component emit file webpack plugin
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({
/**
`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 / LasyImage.jsx
Created January 14, 2018 19:33
Lasy Image Loading
class LazyImage extends PureComponent {
static defaultProps = {
engage: false,
};
state = {
initialEngage: false,
};
componentWillMount() {
@dlebedynskyi
dlebedynskyi / workbox.config.js
Created January 14, 2018 18:39
Workbox cli config
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 July 8, 2017 01:48 — forked from renatorib/operator_with_ligatures.md
Using Operator Mono with Fira Code ligatures in Atom.

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;