Skip to content

Instantly share code, notes, and snippets.

🌄
Disconnected

Artem Sapegin sapegin

🌄
Disconnected
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
View HRM.md

Hot module replacement in React and webpack

The simplest way to enable HMR:

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

function render() {
View styleguide.md

English writing style guide

Style

  • 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.
View react-lifecycle-cheatsheet.md

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps Update state based on changed props
View maillists.md
@sapegin
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 = () => {
counter--;
if (counter === 0) {
callback(errors.length ? errors : null);
}
@sapegin
sapegin / index.js
Last active Jan 15, 2016
Detect minified files in Webpack
View index.js
/*
module: {
loaders: [
{
test: /\.jsx?$/,
loaders: ['detect-min']
},
]
}
*/
@sapegin
sapegin / config.js
Created Feb 13, 2015
Mocha + Require.js + Atomus (jsdom wrapper)
View config.js
// Author: Artem Sapegin http://sapegin.me, 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',
View ProgrammingLanguages.md

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(stylus())
.pipe(autoprefixer('last 2 versions', 'ie 9', 'android 2.3'))
.pipe(gulp.dest('build/'));
View table.md

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.