Skip to content

Instantly share code, notes, and snippets.

// 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'});
},
});
import { Compiler } from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
class ChunkErrorHandlerPlugin {
private options: object;
constructor(options?: object) {
this.options = options || {};
}
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()
@vm
vm / App-inline.js
Last active October 14, 2016 01:44
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' }}>
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)
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
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], [])
]
@vm
vm / curryOp.js
Last active February 26, 2016 19:27
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]
class Counter extends React.Component {
constructor(props) {
super(props)
this.state = {
counter: 0
}
}
}
class CounterWithState extends React.Component {