This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ErrorMissingForename extends Error {} | |
class ErrorMissingSurname extends Error {} | |
const requiredParam = (ErrorType = Error) => { | |
throw new ErrorType() | |
} | |
function concatName ( | |
forename = requiredParam(ErrorMissingForename), | |
surname = requiredParam(ErrorMissingSurname) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form name="userinput" action="http://localhost:6789/input" method="GET"> | |
<textarea name="data" id="data" cols="30" rows="10"></textarea> | |
<button>Go!</button> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env osascript -l JavaScript | |
const Spotify = Application('Spotify') | |
const log = console.log.bind(console) | |
function run ([command, ...args]) { | |
const availableCommands = Object.keys(commands).filter(name => !name.includes('Usage')) | |
if (availableCommands.includes(command)) commands[command](...args) | |
else { |