Skip to content

Instantly share code, notes, and snippets.

Avatar

Dima Lebedynskyi dlebedynskyi

View GitHub Profile
@dlebedynskyi
dlebedynskyi / import-transform.js
Last active Sep 12, 2022
jscodeshift transform to update imports from one package to another
View import-transform.js
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 Apr 29, 2021
day.js patch for @formatjs/Intl polyfill
View Readme.md
@dlebedynskyi
dlebedynskyi / bookmark.md
Last active Nov 19, 2020
wipe cookies and reload
View bookmark.md

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 — forked from emmanueltissera/git-apply-patch.md
Generate a git patch for a specific commit #git
View git-apply-patch.md

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 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);
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;