Skip to content

Instantly share code, notes, and snippets.

View fanyang89's full-sized avatar

fanyang fanyang89

View GitHub Profile
@fanyang89
fanyang89 / fuse.ts
Created April 29, 2018 09:04
Example fuse-box config with code splitting
import * as autoprefixer from "autoprefixer";
import * as express from "express";
import {
Bundle,
CSSPlugin,
FuseBox,
FuseBoxOptions,
ImageBase64Plugin,
JSONPlugin,
PlainJSPlugin,
@fanyang89
fanyang89 / themed.ts
Created February 26, 2018 08:36
Provide props to styled elements in Typescript
import * as React from "react";
import { ThemedStyledFunction } from "styled-components";
const themed = <IComponentProps, U extends HTMLElement = HTMLElement>(
styled: ThemedStyledFunction<any, any>,
): ThemedStyledFunction<IComponentProps & React.HTMLProps<U>, any> => styled;
export default themed;
// eg.
@fanyang89
fanyang89 / ProgressViewer.py
Created September 23, 2016 16:43
Simple progress viewer for Python3
import sys
import time
def view(cond, duration):
progressBarChar = '-\|/'
pos = 0
while cond():
print(progressBarChar[pos], sep='', end='', flush=True)
pos = (pos + 1) % len(progressBarChar)
time.sleep(duration)