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
<html> | |
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<div id="root"></div> | |
<script type="module"> | |
import * as d3 from "https://cdn.skypack.dev/d3"; | |
const width = 600; | |
const height = 600; | |
const links = [ |
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
{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-99.737664,37.717238],[-99.737665,37.717237],[-99.737666,37.717237],[-99.737667,37.717237],[-99.737667,37.717236],[-99.737668,37.717235],[-99.737669,37.717235],[-99.73767,37.717235],[-99.737671,37.717234],[-99.737671,37.717234],[-99.737672,37.717233],[-99.737673,37.717233],[-99.737674,37.717232],[-99.737675,37.717232],[-99.737676,37.717231],[-99.737676,37.717231],[-99.737677,37.717231],[-99.737678,37.717231],[-99.737679,37.717231],[-99.73768,37.717231],[-99.73768,37.717231],[-99.737681,37.717231],[-99.737682,37.717231],[-99.737683,37.71723],[-99.737684,37.71723],[-99.737684,37.71723],[-99.737685,37.71723],[-99.737686,37.71723],[-99.737687,37.71723],[-99.737688,37.71723],[-99.737688,37.71723],[-99.737689,37.71723],[-99.73769,37.71723],[-99.737691,37.71723],[-99.737692,37.71723],[-99.737693,37.71723],[-99.737693,37.71723],[-99.737694,37.71723],[-99.737695,37.71723],[-99.737696,37.71723],[-99.737697,37.71723],[-99.737697,37.71723],[-99.737698,37.717 |
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
-----BEGIN PGP PUBLIC KEY BLOCK----- | |
mQINBGCbFNwBEADeKF9lm6vUOEwKAAkkKhN2qQrMGRq7639N9PykWm+gE7eq1CGo | |
OQxqiMBxR+b7YB4zOGfdmItr/ygLOZjlIyoyCwLvx2PJDcU25SgnJN6e5pHs86Bc | |
MFnnfidMjPkFh1Zi9tirlLwZFrNp8Jn+7bEnA4l4ZbZItlciESN5ySsp+DPce1dr | |
st1JucYTQqOSPYozDHzbPV6A41SPah68B20MOzKp4g947lpI9VvZhaRnbyfCPnni | |
Itsm5kTscXEHET99pmEjQ7Ap32nKs7tgR2598iDrp0mejwfn+eP0mKqfc9TJ7f1Z | |
lYyQi+QUXdoywwGbj1tlxn5s0M5QrR9+vd6VrR+yQQA94v+kjOaqrCZKsSyhGkyN | |
Qk4YB3rLc+e+2ITvXJIwHM+QhPone9zA8za+D2KnJRuIC+KreN59Pm6TsyYSIsWO | |
WutBxmw7YHQjlyF0Am1wYEK96uMTmbTHoDo24CqGMXSH5niChPOR+2AiCtMcyWQF |
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
/** | |
* Data structure that can store up to `cap` elements. | |
* Should have 2 methods: `add` and `check`. | |
* If the capacity is reached, the next element should be added instead of | |
* the latest used element. | |
* The newest element is the one tha was `added` or `checked` the last. | |
* | |
* `check` operation just marks the element as "used". | |
* `add` adds a new element | |
* - if the element is already in the structure, just `check` it |
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 API_KEY = 'eee301d58fa69f9c700b2aadfb915a71'; | |
const BASE_URL = 'http://ws.audioscrobbler.com/2.0'; | |
/* Fetch data */ | |
function fetchArtist(artist) { | |
const searchParams = `artist=${artist}&api_key=${API_KEY}&format=json`; | |
fetch(`${BASE_URL}/?method=artist.gettopalbums&limit=5&${searchParams}`) | |
.then(async response => { |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
/** Scales values to be a percentage of their sum. E.g., [20, 30] -> [40, 60] */ | |
function scaleToPercentages(rows: Row[]): Row[] { | |
rows.forEach(([_, vs]) => Preconditions.checkArgument(vs.length === 1)); // Only supports one | |
// column. | |
if (rows.length === 0) { | |
return rows; | |
} | |
const sum = rows | |
.map(([_, [v]]) => v) | |
.reduce((acc, v) => acc + v, 0); |
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 * as React from 'react'; | |
type Store = { treasure: number }; | |
type Presenter = { digTreasure: (store: Store, place: string) => void }; | |
type MyCompo1Props = { store: Store, presenter: Presenter }; | |
class MyCompo1 extends React.Component<MyCompo1Props> { | |
render() { | |
/* should be an error because `this` in `digTreasure` will be not as expected */ | |
return <MyCompo2 onDig={this.digTreasure}/>; |
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 translateSelector(original){ | |
let result = original.replace(simpleRe, (match, value) => { | |
return replace(match, value); | |
}).replace(attributeRe, (match, op, value) => { | |
switch (op) { | |
case '=': | |
console.log('=', match, value) | |
return replace(match, value); | |
case '^=': | |
console.log('^=', match, value) |
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
/** | |
* Takes prefixes and suffixes from first occurence of those and populate them to all other values. | |
* Wrapper function wraps valid numbers and gets rid of NaNs. | |
* | |
* Example: | |
* const wrap = valueFormatter(['$10', '20', '30']); | |
* const label = wrap(10); // '$10' | |
*/ | |
class ValueFormatter { | |
prefix: string = ''; |
NewerOlder