Skip to content

Instantly share code, notes, and snippets.

View b2whats's full-sized avatar
🎯
Focusing

Akimov Vladimir b2whats

🎯
Focusing
View GitHub Profile
@toddmantell
toddmantell / destructuredImport.js
Last active June 11, 2018 22:44
transform destructured import to CommonJS
//Should transform: import {Component} from 'react';
//to: const _Component = require('react').Component;
export default function ({types: t}) {
return {
visitor: {
ImportDeclaration(path) {
const {node} = path;
path.replaceWith(
t.variableDeclaration('var',
@busypeoples
busypeoples / README.md
Last active October 28, 2020 04:34
Loader

Loader

Introduction

Minimal loader with state management capabilities.

Checkout out the demo.

Setup

Make sure to add a .babelrc file:

@erukiti
erukiti / optimizer.js
Created October 12, 2017 11:40
最適化プラグイン
const {transform} = require('babel-core')
const babylon = require('babylon')
const WasCreated = Symbol('WasCreated')
const source = `
let b = 0
console.log(b)
b = b + 2
console.log(b)
@busypeoples
busypeoples / IntroductionToFlow.md
Last active June 29, 2020 08:22
Introduction To Flow

Introduction To Flow

Intended for developers interested in getting started with Flow. At the end of this introduction, you should have a solid understanding of Flow and how to apply it when building an application.

Covers all the basics needed to get started with Flow.

Covers all the basic needed to get started with Flow and ReactJS.

@kana-sama
kana-sama / 2.js
Last active October 3, 2017 00:39
Tardis idea of using lazy value on js for lists
class Lazy {
constructor(value) {
this.value = value;
this.cache = null;
this.isCached = false;
}
exec() {
if (!this.isCached) {
this.cache = this.value();
@acdlite
acdlite / coordinating-async-react.md
Last active June 17, 2024 11:56
Demo: Coordinating async React with non-React views

Demo: Coordinating async React with non-React views

tl;dr I built a demo illustrating what it might look like to add async rendering to Facebook's commenting interface, while ensuring it appears on the screen simultaneous to the server-rendered story.

A key benefit of async rendering is that large updates don't block the main thread; instead, the work is spread out and performed during idle periods using cooperative scheduling.

But once you make something async, you introduce the possibility that things may appear on the screen at separate times. Especially when you're dealing with multiple UI frameworks, as is often the case at Facebook.

How do we solve this with React?

@Kovrinic
Kovrinic / .gitconfig
Last active March 30, 2026 08:27
git global url insteadOf setup
# one or the other, NOT both
[url "https://github"]
insteadOf = git://github
# or
[url "git@github.com:"]
insteadOf = git://github
@myshov
myshov / function_invocation.js
Last active February 23, 2026 13:47
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);
@hediet
hediet / main.md
Last active June 21, 2026 11:21
Proof that TypeScript's Type System is Turing Complete
type StringBool = "true"|"false";


interface AnyNumber { prev?: any, isZero: StringBool };
interface PositiveNumber { prev: any, isZero: "false" };

type IsZero<TNumber extends AnyNumber> = TNumber["isZero"];
type Next<TNumber extends AnyNumber> = { prev: TNumber, isZero: "false" };
type Prev<TNumber extends PositiveNumber> = TNumber["prev"];
@denistakeda
denistakeda / dashboard.js
Created October 16, 2016 07:21
React in functional style
import React, { PropTypes } from "react";
import IPropTypes from "react-immutable-proptypes";
import composeEnhances from "recompose/compose";
import setDisplayName from "recompose/setDisplayName";
import setPropTypes from "recompose/setPropTypes";
import onlyUpdateForPropTypes from "recompose/onlyUpdateForPropTypes";
import { connect } from "react-redux";