Skip to content

Instantly share code, notes, and snippets.

View princed's full-sized avatar
🏗️
Building

Eugene Datsky princed

🏗️
Building
View GitHub Profile
@azizur
azizur / Creating a static copy of a dynamic website.md
Last active February 19, 2025 16:22
Creating a static copy of a dynamic website

The command line, in short…

wget -k -K -E -r -l 10 -p -N -F --restrict-file-names=windows -nH http://website.com/

…and the options explained

  • -k : convert links to relative
  • -K : keep an original versions of files without the conversions made by wget
  • -E : rename html files to .html (if they don’t already have an htm(l) extension)
  • -r : recursive… of course we want to make a recursive copy
  • -l 10 : the maximum level of recursion. if you have a really big website you may need to put a higher number, but 10 levels should be enough.

Notes

  • This code handles any JS runtime error during rendering React components. Without this handling, once an error occurs, whole component tree is damaged and can't be used at all. With this handling, nothing will be rendered in production environment (error span in dev env.) + in production the error is logged to Sentry (if you are not using it just delete related code)
  • This is basicaly a workaround for proposed feature in React core - described in Issue: facebook/react#2461
  • Works for all variants of Component creation - React.createClass, extending React.Component and also stateless functional components.
  • To get this work, just put this snippet into your entry js file. Then it will work in whole application.
  • Also supporting React Hot Reload!
  • If you find this useful, please retweet https://twitter.com/Aldredcz/status/744650159942995968 :)

Ideas

  • specify custom error renderer (global / per component, e.g. by implementing method renderOnError() in a comp
@robertknight
robertknight / Build.md
Last active July 8, 2022 01:32
Minimal Webpack DllPlugin example

Compile with:

webpack --config vendor.webpack.config.js
webpack --config app.webpack.config.js

Use with the following index.html

@AMPivovarov
AMPivovarov / IDE Script #2.md
Last active July 19, 2022 05:27
IDE Script #2.md

Sample custom action for calling "git reset HEAD~1 --hard"

Usage:

  • Run "Tools -> IDE Scripting Console" action
  • Select groovy
  • Copy attached script to created scratch file
  • Select whole file
  • Press Ctrl+Enter
  • Call action "Find Git repositories without specified branch" (using "Help -> Find Action" action)
@paulirish
paulirish / what-forces-layout.md
Last active March 14, 2025 04:50
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.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@nkbt
nkbt / .eslintrc.js
Last active February 2, 2025 17:49
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@imjasonh
imjasonh / markdown.css
Last active January 3, 2025 20:15
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
gulp = require('gulp')
browserSync = require('browser-sync')
gulp.task 'browser-sync', ['webpack:dev-server'], ->
browserSync(
proxy: "localhost:8081"
port: 8080
)
@gregsh
gregsh / - IDE Scripting.md
Last active March 1, 2025 19:23
IDE Scripting

Here are my attempts to script an IntelliJ-based IDE using javax.script.* API (ex-JSR-223).

The list of available scripting languages and engines:

  1. Groovy - built-in, via Groovy jars and <app>/lib/groovy-jsr223-xxx.jar
  2. JavaScript (Nashorn) - built-in, via Java Runtime <app>/jbr/... (deprecated and will be removed soon)
  3. JavaScript (GraalJS) - https://plugins.jetbrains.com/plugin/12548-intellij-scripting-javascript
  4. JPython - https://plugins.jetbrains.com/plugin/12471-intellij-scripting-python
  5. JRuby - https://plugins.jetbrains.com/plugin/12549-intellij-scripting-ruby
  6. Clojure - https://plugins.jetbrains.com/plugin/12469-intellij-scripting-clojure
@loganfsmyth
loganfsmyth / use-strict-loader.js
Created January 20, 2015 02:12
Webpack 'use-strict' loader
var OriginalSource = require('webpack/lib/OriginalSource');
module.exports = function(source, map){
var identifier = this._module.identifier();
this.cacheable();
var origMap = this.sourceMap ? new OriginalSource(source, identifier, map) : null;
var strictPrefix = '"use strict";\n';