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
// Importing IndexedDB promise-based wrapper | |
import { openDB } from 'idb'; | |
async function initializeDB() { | |
const db = await openDB('myDB', 1, { | |
upgrade(db) { | |
db.createObjectStore('lists', {keyPath: 'url'}); | |
}, | |
}); |
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 { Compiler } from 'webpack'; | |
import HtmlWebpackPlugin from 'html-webpack-plugin'; | |
class ChunkErrorHandlerPlugin { | |
private options: object; | |
constructor(options?: object) { | |
this.options = options || {}; | |
} |
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 csv | |
import xml.etree.ElementTree as ET | |
STAGING = True | |
domain = 'uniswap-staging.org' if STAGING else 'uniswap.org' | |
tree = ET.parse('sitemap-0.xml') | |
urlset = tree.getroot() |
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 React, { Component } from 'react' | |
const Timeline = ({ children }) => ( | |
<div style={{ display: 'flex', alignItems: 'center', flexDirection: 'column' }}> | |
{children.map(child => <div style={{ width: '16rem', padding: '1.4rem' }}>{child}</div>)} | |
</div> | |
) | |
const PostHeader = ({ authoredAt, author }) => ( | |
<div style={{ backgroundColor: '#e8fdf5', paddingTop: '1rem', paddingBottom: '1rem',fontSize: '875rem' }}> |
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 signal | |
def timeout(seconds): | |
def wraps(fn): | |
def inner(*args, **kwargs): | |
def handler(signum, frame): | |
raise TimeoutError | |
signal.signal(signal.SIGALRM, handler) | |
signal.alarm(seconds) |
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
from functools import partial | |
from inspect import signature | |
def curry(func, _arglen=None): | |
"""creates a curried version of the given function | |
>>> add = lambda a, b: a + b | |
>>> assert add(1, 2) == curry(add)(1)(2) | |
True |
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
def accumulate_with_remainder(xs): | |
"""implements accumulate while also returning the remainder | |
>>> accumulate_with_remainder([1,2,3]) | |
[ | |
([], [1,2,3]), | |
([1], [2,3]), | |
([1,2], [3]), | |
([1,2,3], []) | |
] |
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 { curry } from 'ramda' | |
const filter = curry((fn, xs) => { | |
ys = [] | |
for (let x of xs) { if (fn(x)) ys.push(y) } | |
return ys | |
}) | |
const xs = [1, 4, 3, 2] |
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
class Counter extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
counter: 0 | |
} | |
} | |
} | |
class CounterWithState extends React.Component { |
NewerOlder