This file contains 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 getURLParameters(url) { | |
var result = {}; | |
var searchIndex = url.indexOf("?"); | |
if (searchIndex == -1) return result; | |
var pageUrl = url.substring(searchIndex + 1); | |
var urlVariables = pageUrl.split('&'); | |
for (var i = 0; i < urlVariables.length; i++) { | |
var parameterName = urlVariables[i].split('='); | |
result[parameterName[0]] = parameterName[1]; |
This file contains 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 Promise from 'bluebird' | |
Promise.config({ | |
warnings: false, | |
cancellation: true, | |
}) | |
const convertJson = string => { | |
try { | |
return JSON.parse(string); |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |
This file contains 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 { series, parallel } = require('./orchestrator.js'); | |
const buildSync = () => 'this was build synchronously'; | |
const buildAsync = () => Promise.resolve('this could have been made asyncronously'); | |
const tasks = series( | |
series(buildAsync, buildAsync), | |
series(buildAsync, buildSync), |
This file contains 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
root = true | |
[*] | |
indent_style = space | |
indent_size = 2 | |
charset = utf-8 | |
trim_trailing_whitespace = true | |
insert_final_newline = true | |
[*.md] |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>SSE</title> | |
</head> | |
<body> | |
<script> |
This file contains 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 { withTimer } from './with-timer' | |
withTimer(() => { | |
const c = document.createElement('canvas') | |
document.body.appendChild(c) | |
const cc = c.getContext('2d') | |
let hue = 0 | |
return () => { | |
hue++ |
This file contains 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
// Create the controller that sends a signal if | |
// an abort is requested by the api | |
const abortController = new AbortController(); | |
// create a fetch, and pass the signal from the controller to | |
// the fetch options | |
const request = fetch('http://my-awesome-site.com/api/awesome', { | |
signal: abortController.signal, | |
}); |
This file contains 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 drawResizedImage( | |
context: CanvasRenderingContext2D, | |
imageElement: HTMLImageElement, | |
width: number = context.canvas.width, | |
height: number = context.canvas.height, | |
) { | |
// eventual image offset (0.5 is center) | |
const offsetX = 0.5; | |
const offsetY = 0.5; | |
// set image values; |
This file contains 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 { PassThrough } = require('stream'); | |
function combineStream(...streams) { | |
return streams.reduce((passthrough, stream, i) => { | |
stream.pipe(passthrough); | |
stream.once('end', () => { | |
streams.every(s => s.ended); | |
passthrough.emit('end'); | |
}); | |
return passthrough; |
OlderNewer