Skip to content

Instantly share code, notes, and snippets.

View wegry's full-sized avatar

Zach Wegrzyniak wegry

  • Boston
  • 23:43 (UTC -05:00)
View GitHub Profile
@wegry
wegry / .eslintrc.yaml
Created July 9, 2016 22:07
Lightweight eslint config in yaml
---
env:
browser: true
parserOptions:
ecmaVersion: 6
sourceType:
module
ecmaFeatures:
jsx: true
@wegry
wegry / webpack.config.js
Last active September 24, 2016 16:07
Tree shaking, linting, pre-processed css, and react webpack@^2.1.0-beta.25 config
const path = require('path'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
webpack = require('webpack')
const plugins = [
new ExtractTextPlugin('app.css'),
new webpack.LoaderOptionsPlugin({
// test: /\.xxx$/, // may apply this only for some modules
options: {
eslint: {
@wegry
wegry / commonjs-to-es6-modules.js
Last active July 20, 2017 04:12
purescript psc 0.9 output webpack loader that allows tree shaking
"use strict"
/*
* Webpack 2 loader that can take CommonJS output by psc 0.9.1 and convert
* it into tree shakable ES6 modules. No transpiling required.
*/
const fs = require('fs')
const commonJsRequire = /var ([$\w]+) = require\("(.*)"\)/g
const moduleExports = /module\.exports = \{(\n( ([$\w]+): ([$\w]+)(, )?\n)*)?\};/m
const sizeNode = d => d.value + 5
const fill = d3.scale.category10();
d3.json('file.json', function(error, top) {
const {nodes, links} = top
const parents = {}
links.forEach(link => {
let target = link.target
let source = link.source
@wegry
wegry / .eslintrc.yaml
Last active December 8, 2016 02:30
eslint 3.3 yaml config
---
env:
browser: true
es6: true
parserOptions:
ecmaVersion: 6
sourceType: module
rules:
[format]
pretty = %Cblue%h%Creset %Cgreen[%ar]%Creset (%an) %s
[alias]
a = add
c = commit
co = checkout
d = diff
f = fetch
fmm = !git fetch origin master && git merge origin master
@wegry
wegry / JsonConfig.fs
Last active November 12, 2017 12:51
F# Enum Style Discriminated Unions serialized to strings with Json.NET for DUs with empty cases
// Fsharp 4.1.0
open System
open Newtonsoft.Json // 10.0.3
open Newtonsoft.Json.Converters
type ToStringJsonConverter () =
inherit JsonConverter()
override this.CanConvert objectType = true;
override this.WriteJson (writer: JsonWriter, value: obj, serializer: JsonSerializer): unit =
@wegry
wegry / import.re
Created February 28, 2018 10:34
ReasonML import of FFI module with a different name
[@bs.module "./i18n"]
external modelNameI18n: string =
"MODEL_NAME";
@wegry
wegry / Generic.fsproj
Created April 25, 2018 12:39
Extract XLSX into JSON
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
@wegry
wegry / PropTypes.bs.js
Last active May 15, 2018 06:56
Bucklescript FFI bindings with Reason for prop-types
import * as PropTypes from "prop-types";
var shape = PropTypes.default.shape();
var arrayOf = PropTypes.default.arrayOf();
var Internal = /* module */[
/* shape */shape,