Skip to content

Instantly share code, notes, and snippets.


Artem Sapegin sapegin

Block or report user

Report or block sapegin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Hot module replacement in React and webpack

The simplest way to enable HMR:

import React from 'react';
import ReactDOM from 'react-dom';

function render() {

English writing style guide


  • Use American English
  • Always use sentence casing, even in headings.
  • Singular they
  • Use contractions: it’s, we’ll.
  • Ellipses in quotations: […].
  • 2 times → two times.
  • Use Arabic numerals for centuries: 19th century.

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
componentWillReceiveProps Update state based on changed props
sapegin / preload.js
Created Feb 21, 2016
Tamia image preload es6
View preload.js
// Image preload
import { ensureArray } from './util';
export default function preload(images, callback) {
let done = () => {
if (counter === 0) {
callback(errors.length ? errors : null);
sapegin / index.js
Last active Jan 15, 2016
Detect minified files in Webpack
View index.js
module: {
loaders: [
test: /\.jsx?$/,
loaders: ['detect-min']
sapegin / config.js
Created Feb 13, 2015
Mocha + Require.js + Atomus (jsdom wrapper)
View config.js
// Author: Artem Sapegin, 2015
(function() {
var config = {
paths: {
lodash: '../bower_components/lodash/lodash',
jquery: '../bower_components/jquery/dist/jquery',
backbone: '../bower_components/backbone/backbone',
react: '../bower_components/react/react',
backboneLocalStorage: '../bower_components/backbone.localStorage/backbone.localStorage',

Programming languages I’ve ever worked with

  • ActionScript
  • AppleScript
  • Assembly language: MASM for DOS and Windows
  • Bash
  • BASIC: ZX Spectrum’s, QuckBasic
  • Batch: DOS, Windows
  • C
  • C++: VisualC++
View gulpfile.js
var gulp = require('gulp');
var livereload = require('gulp-livereload');
var stylus = require('gulp-stylus');
var autoprefixer = require('gulp-autoprefixer');
gulp.task('styles', function() {
return gulp.src('styles/task*.styl')
.pipe(autoprefixer('last 2 versions', 'ie 9', 'android 2.3'))

Colons can be used to align columns.

Tables Are Cool
col 3 is right-aligned $1600
col 2 is centered $12
zebra stripes are neat $1

The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.

You can’t perform that action at this time.