Skip to content

Instantly share code, notes, and snippets.

extension NSMutableAttributedString {
func add(attribute: Attribute, range: NSRange) throws {
guard (range.location + range.length) <= length else {
throw AttributedStringError.InvalidRange(range: range)
}
addAttribute(attribute.name, value: attribute.value, range: range)
}
}
@michaelgilley
michaelgilley / webpack_profile_nodeapi.js
Created June 14, 2016 15:22
Snippet for grabbing Webpack stats in JSON format when using the Node API.
import webpack from 'webpack'
import {writeFileSync} from 'fs'
import {resolve} from 'path'
import config from 'webpack.config.js'
import webpackDevServer from 'webpack-dev-server'
config.profile = true
const compiler = webpack(config)