In addition to the Storybook for React setup, you'll also need to install these packages:
npm i -D @babel/core babel-loader css-loader style-loader
In addition to the Storybook for React setup, you'll also need to install these packages:
npm i -D @babel/core babel-loader css-loader style-loader
The helper function canvas-to-svg.js
wraps a given render function (or renderer object) so that you can use Canvas2D context methods as usual, but upon single frame export (with Cmd/Ctrl + S) it will produce both a PNG and SVG file.
This uses canvas2svg which is not a perfect solution, as the Canvas2D API was never designed to be translated to SVG. Its best to stick with simple shape and path operations.
Full instructions: first install the canvas-sketch CLI if you haven't already:
npm install canvas-sketch-cli -g
type EventHandler<T=any> = (data :T)=>void | |
export class EventEmitter<EventMap = {[k:string]:any}> { | |
_events = new Map<keyof EventMap,Set<EventHandler>>() | |
addListener<K extends keyof EventMap>(e :K, handler :EventHandler<EventMap[K]>) { | |
let s = this._events.get(e) | |
if (s) { | |
s.add(handler) | |
} else { |
/** | |
* useScroll React custom hook | |
* Usage: | |
* const { scrollX, scrollY, scrollDirection } = useScroll(); | |
*/ | |
import { useState, useEffect } from "react"; | |
export function useScroll() { | |
const [lastScrollTop, setLastScrollTop] = useState(0); |
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
import SyntaxHighlighter from 'react-syntax-highlighter'; | |
export default class CodeBlock extends React.PureComponent { | |
static propTypes = { | |
value: PropTypes.string.isRequired, | |
language: PropTypes.string, | |
} |
"use strict"; | |
// Load plugins | |
const autoprefixer = require("autoprefixer"); | |
const browsersync = require("browser-sync").create(); | |
const cp = require("child_process"); | |
const cssnano = require("cssnano"); | |
const del = require("del"); | |
const eslint = require("gulp-eslint"); | |
const gulp = require("gulp"); |
This content moved here: https://exploringjs.com/impatient-js/ch_arrays.html#quickref-arrays
Based off of: http://docs.sequelizejs.com/en/1.7.0/articles/express/
Create and initialize your a directory for your Express application.
$ mkdir sequelize-demo
/** | |
* This gist was inspired from https://gist.github.com/homam/8646090 which I wanted to work when uploading an image from | |
* a base64 string. | |
* Updated to use Promise (bluebird) | |
* Web: https://mayneweb.com | |
* | |
* @param {string} base64 Data | |
* @return {string} Image url | |
*/ | |
const imageUpload = async (base64) => { |