args(['-a', '-b', 'foo', '--c', '--d', 'bar', '--e=baz', '-f=foobarbaz'])
{ a: true, b: 'foo', c: true, d: 'bar', e: 'baz', f: 'foobarbaz' }
#!/usr/bin/env python | |
import sys | |
import pychromecast | |
URL = sys.argv[1] | |
chromecasts = pychromecast.get_chromecasts() | |
cast = next(cc for cc in chromecasts if cc.device.friendly_name == "Living Room") |
<form name="userinput" action="http://localhost:6789/input" method="GET"> | |
<textarea name="data" id="data" cols="30" rows="10"></textarea> | |
<button>Go!</button> | |
</form> |
class ErrorMissingForename extends Error {} | |
class ErrorMissingSurname extends Error {} | |
const requiredParam = (ErrorType = Error) => { | |
throw new ErrorType() | |
} | |
function concatName ( | |
forename = requiredParam(ErrorMissingForename), | |
surname = requiredParam(ErrorMissingSurname) |
#!/usr/bin/env bash | |
set -e -o pipefail | |
trap 'rm -rf ssl' INT | |
export CN="$1" | |
export C="${C-GB}" | |
export ST="${ST-England}" | |
export L="${L-London}" |
const tre = (strings, ...values) => { | |
const flags = values | |
.filter(v => v instanceof RegExp) | |
.map(re => re.flags) | |
.reduce( | |
(a, b) => | |
a + | |
b | |
.split("") | |
.filter(char => !a.includes(char)) |
const path = require('path') | |
const ExtractTextPlugin = require('extract-text-webpack-plugin') | |
const webpack = require('webpack') | |
const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js') | |
module.exports = (storybookBaseConfig, env) => { | |
const baseConfig = genDefaultConfig(storybookBaseConfig, env) | |
return Object.assign({}, baseConfig, { | |
node: { | |
fs: 'empty', |
// See-Saw problem. | |
// | |
// There are 12 people on an island. | |
// One of these 12 people weighs either more or less than the others. | |
// You have a see-saw, you can balance infinite people on either side, | |
// but can only use it a maximum of 3 times. How do you find the person? | |
// implement a function that returns the height of the odd person. | |
runPuzzle((people, seeSaw) => { |
import Foundation | |
print("Scanning for chromecasts") | |
class BrowserDelegate : NSObject, NetServiceBrowserDelegate { | |
var chromeCasts: [NetService] = [] | |
func netServiceBrowser(_ browser: NetServiceBrowser, didFind service: NetService, moreComing: Bool) { | |
let existingChromeCast = chromeCasts.filter({ $0.name == service.name }) |
;(function validateHtml() { | |
const getErrorExampleSnippet = (html, start, end) => { | |
const lines = html.split('\n') | |
const linesWeCareAbout = lines.slice(start.line - 1, end.line) | |
const region = linesWeCareAbout.map((l, i, ls) => { | |
const isFirstLine = i === 0 | |
const isLastLine = ls.length - 1 === i |