Skip to content

Instantly share code, notes, and snippets.

View andywer's full-sized avatar

Andy Wermke andywer

View GitHub Profile
@andywer
andywer / happypack.js
Last active July 15, 2017 11:42
@webpack-blocks/happypack - Concept
const { group } = require('@webpack-blocks/core')
module.exports = happypack
function happypack (blocks) {
return group(blocks.map(happyfyBlock))
}
/**
* Returns a new block wrapping `block` that creates a happypack loader config.
@andywer
andywer / block-update-function.js
Last active July 15, 2017 11:42
Possible webpack-blocks API
// With merge helper:
module.exports = function exampleBlock () {
return (context, { merge }) => merge({
module: {
rules: [
{
test: context.fileType('text/css'),
use: ['sample-css-loader']
}
@andywer
andywer / blockHelpers.js
Created March 1, 2017 18:21
webpack-blocks - New API core code
const webpackMerge = require('webpack-merge')
module.exports = {
merge,
addLoader,
addPlugin
}
function merge (configSnippet) {
return prevConfig => webpackMerge.smart(prevConfig, configSnippet)
@andywer
andywer / dctypes.js
Created March 4, 2017 16:24
Babylon plugin for elm/haskell-ish type declarations
// src/plugins/dctypes.js
import { types as tt } from "../tokenizer/types";
import { types as ct } from "../tokenizer/context";
import Parser from "../parser";
import "./flow";
const pp = Parser.prototype;
export default function (instance) {
@andywer
andywer / to-comment.md
Last active June 19, 2019 02:24
Double colon types in JS 🚀

Source

// test-code.js

add :: (number, number) => number

function add (x, y) {
  return x + y
}
@andywer
andywer / package.json
Created March 15, 2017 17:49
Double colon types, now published
{
"version": "0.0.0",
"scripts": {
"to-comments": "babel --plugins=@andywer/babel-plugin-transform-dctypes-comments --no-babelrc test-code.js",
"to-flow": "babel --plugins=@andywer/babel-plugin-transform-dctypes-to-flow --no-babelrc test-code.js",
"to-flow-runtime": "NODE_ENV=development babel --plugins=@andywer/babel-plugin-transform-dctypes-to-flow,flow-runtime --no-babelrc test-code.js"
},
"dependencies": {
"@andywer/babel-cli-dctypes": "7.0.0-alpha.1",
"@andywer/babel-plugin-transform-dctypes-comments": "^0.1.0",
@andywer
andywer / package.json
Last active July 15, 2017 11:41
Leakage async: Real world test
{
"scripts": {
"test": "mocha"
},
"engines": {
"node": ">= 7.0"
},
"devDependencies": {
"leakage": "./path/to/local/leakage/branch/feature/async-support",
"mocha": "^3.2.0",
@andywer
andywer / counter.js
Last active July 15, 2017 11:41
React Stateful (!) Functional Components
// counter.js
import stateful from 'new-fancy-statefulness'
const Counter = (props, state, { setState }) => (
<div>
<div>Clicked {state.clicks} times</div>
<button onClick={props.onClick}>Increase +</button>
</div>
)
@andywer
andywer / talk-proposal.md
Last active December 23, 2020 17:22
Reactive Conf 2017 ⚡️ Talk Proposal - Memory Leak Hunt 2017 Style

This is a proposal for lightning talk at Reactive Conf. Please 🌟 this gist to push the proposal!

Memory Leak Testing in 2017

Hi, I am Andy, creator of leakage - the node-powered memory leak testing library.

Instead of manual debugging it provides a structured approach to fix or even prevent memory leaks.

@andywer
andywer / API-Ideas.md
Last active June 13, 2017 13:05
threads v1.0 - API ideas
const fetchData = thread(require('worker-loader!./fetch-data'))
// or
const fetchData = thread(async url => {
  return (await fetch(url)).json()
})

// fetchData :: ThenableObservable

const data = await fetchData('/api/me')