Skip to content

Instantly share code, notes, and snippets.

@ufukomer
Last active September 15, 2017 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ufukomer/e9e65234f0803cc5071841245451e214 to your computer and use it in GitHub Desktop.
Save ufukomer/e9e65234f0803cc5071841245451e214 to your computer and use it in GitHub Desktop.
Some shitty problems that occur while developing
  1. To not retyping fucking ssh passphrase key each fucking time: http://superuser.com/a/1158050
  2. Create a jetty test server: http://stackoverflow.com/a/29759263/3650955
  3. WebpackExtractPlugin with HMR: webpack-contrib/extract-text-webpack-plugin#30 (comment)
if (process.env.NODE_ENV !== "production") {
  if (module.hot) {
    const reporter = window.__webpack_hot_middleware_reporter__;
    const success = reporter.success;
    const DEAD_CSS_TIMEOUT = 2000;

    reporter.success = function() {
      document.querySelectorAll("link[href][rel=stylesheet]").forEach((link) => {
        const nextStyleHref = link.href.replace(/(\?\d+)?$/, `?${Date.now()}`);
        const newLink = link.cloneNode();
        newLink.href = nextStyleHref;

        link.parentNode.appendChild(newLink);
        setTimeout(() => {
          link.parentNode.removeChild(link);
        }, DEAD_CSS_TIMEOUT);
      });
      success();
    };
  }
}

The following only works if I run webpackHotUpdate() function manually in the browser console.

const cssFileName = 'bundle.css';
const originalCallback = global.webpackHotUpdate;

window.webpackHotUpdate = (...args) => {
  const links = document.getElementsByTagName('link');
  for (let i = 0; i < links.length; i += 1) {
    const link = links[i];
    if (link.href.search(cssFileName) !== -1) {
      const linkHref = link.href;
      link.href = 'about:blank';
      link.href = linkHref;
      originalCallback(...args);
      return;
    }
  }
};
  1. Change child by the hover of parent: http://stackoverflow.com/a/5061953/3650955
  2. CSS Modules import variables from external css file: http://stackoverflow.com/a/40779921/3650955
  3. Coloring svg: http://codepen.io/noahblon/post/coloring-svgs-in-css-background-images
  4. Thmeleaf index template not found like error: http://stackoverflow.com/a/31946688/3650955
  5. react-bootstrap center navbar items:
   .container {
     text-align: center
   }
  1. CSS: child above the parent (similar to overflow: visible)
  #child {
    position: relative;
    z-index: 3; /* I didn't need that one */
  }
  1. Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers
  mvn package // this command fixes the error
  1. webpack:///./~/react-transform-catch-errors/lib/index.js?:36 ReferenceError: "setTimeout" is not defined: Removed the line the it has been fixed:
  console.log(this.props.location);
  1. Stupid Java regex for html: https://github.com/ufukomer/qbloomy/pull/27/commits/9ecc21e494af5b7582ae09fee70f80fff4567ec8#diff-38a3d2be5c964a48104e6615b036d06cL74

  2. Are JSON web services vulnerable to CSRF attacks?: http://stackoverflow.com/a/11024387/3650955

  3. Github repo as an npm package: https://stackoverflow.com/a/28729646/3650955

  4. Webpack multiple outputs: webpack/webpack#1189 (comment)

  5. Symlink error: screen shot 2017-07-27 at 4 35 36 pm

  6. React router 4 regex path: remix-run/react-router#391 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment