Skip to content

Instantly share code, notes, and snippets.

View andywer's full-sized avatar

Andy Wermke andywer

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / sample.js
Created September 16, 2016 10:12
Listr Verbose Renderer Issue
const execa = require('execa')
const Listr = require('listr')
const rootListr = createListr([
{
title: 'root',
task: () => createListr([
{
title: 'sleep 1s',
task: () => execa.shell('echo "Sleeping 1s" && sleep 1 && echo "Done sleeping"')
@andywer
andywer / index.js
Created September 16, 2016 07:00
Listr 0.6.0 Issue
const execa = require('execa')
const Listr = require('listr')
const Observable = require('zen-observable')
const rootListr = new Listr([
{
title: 'root',
task: () => new Listr([
{
title: 'sleep 1s',
@andywer
andywer / passway.md
Last active August 26, 2016 22:27
Idea: Make REST communication as easy as a function call

Passway - Make REST communication as easy as a function call

What is this about?

  • Make message passing using REST as easy and convenient as possible
  • Convention over configuration for the basics, middleware concept for more powerful stuff
  • Make it easy for people to design software in microservices and provide open APIs

Sample shows code of a small demo page for doing a simple mathematical addition of two numbers (method calculation). Calculation is done on the server.

@andywer
andywer / index.js
Created July 8, 2016 09:57
Resticle idea: Additional gimmicks
import { createApi, Schema } from 'resticle'
const api = createApi('/api')
// Don't Repeat Yourself: Small middleware function to automatically provide `created_at` and `updated_at` timestamps
api.use(function timestampsMiddleware (api) {
api.extendModels((model, schema) => {
// Extend schema if timestamps are not already defined
schema.created_at = schema.created_at || Schema.Date()
schema.updated_at = schema.updated_at || Schema.Date()