Skip to content

Instantly share code, notes, and snippets.

View Shuumatsu's full-sized avatar

为世人降下祝福 Shuumatsu

View GitHub Profile
#include <iostream>
using namespace std;
// 罗马数字共有 7 个,即 I(1)、V(5)、X(10)、L(50)、C(100)、D(500)和
// M(1000)
string transform(string accu, int n) {
if (n == 0)
return accu;
int ms = n / 1000;
import { STATUSES } from '@/constants'
import withUserInformation from '@/hocs/withUserInformation'
import { identity } from 'ramda'
import { branch, compose, renderComponent } from 'recompose'
import LoginPage from '../routes/login'
const privateComponent = branch(
({ loginStatus }) => loginStatus === STATUSES.SUCCESSED,
identity,
renderComponent(LoginPage)
import { curry } from 'ramda'
import React from 'react'
import { withStateHandlers } from 'recompose'
import styled, { css } from 'styled-components'
const initialState = { retryCount: 1 }
const stateHandlers = {
reload: ({ retryCount }) => _ => ({ retryCount: retryCount + 1 })
}
import React from 'react'
import styled, { keyframes } from 'styled-components'
const Svg = styled.svg.attrs({
version: '1.1',
xmlns: 'http://www.w3.org/2000/svg',
xmlnsXlink: 'http://www.w3.org/1999/xlink',
'xmlns:sketch': 'http://www.bohemiancoding.com/sketch/ns'
})`
position: relative;
export const sync = syncFn => (data, cb) => data |> syncFn |> cb;
export const compose = (taskList, cb) =>
reduceRight((next, task) => data => task(data, next), cb, taskList);
export const withErrorHandler = handler =>
map(task => (data, next) =>
data instanceof Error ? handler(data) : task(data, next)
);
const cache = new Map()
export default src =>
new Promise((resolve, reject) => {
if (cache.has(src)) resolve(cache.get(src))
const audio = document.createElement('audio')
audio.addEventListener('loadedmetadata', () => {
const duration = audio.duration
http://www.ics.uci.edu/~eppstein/161/960109.html
const cache = new WeakMap()
export default src => new Promise((resolve, reject) => {
if (cache.has(src))
resolve(cache.get(src))
const audio = document.createElement('audio')
audio.addEventListener('loadedmetadata', e => {
const duration = audio.duration
cache.set(src, duration)
const cache = new WeakMap()
export default async fileblob => new Promise((resolve, reject) => {
if (cache.has(fileblob))
resolve(cache.get(fileblob))
const reader = new FileReader()
reader.addEventListener('load', e => {
const src = e.target.result
cache.set(fileblob, src)
// 常规的递归方法
const flatten1 = arr => {
const result = []
for (const v of arr) {
Array.isArray(v) ?
result.push(...flatten(v)) :
result.push(v)
}
return result