This is an example to my article “How webpack’s ContextReplacementPlugin works”
You have the moment.js library, and you have a dynamic import:
require('./locale/' + name + '.js')| "use strict"; | |
| // Application variables | |
| var area, txt; | |
| var fontsize = 18; | |
| var s = { INIT: 1, PLAY: 2, PAUSED: 3, END: 4 }; | |
| var iplay, previplay, playstate = s.INIT; | |
| var start, end; | |
| var msg = null; | |
| var imsg; | |
| var voices = []; |
This is an example to my article “How webpack’s ContextReplacementPlugin works”
You have the moment.js library, and you have a dynamic import:
require('./locale/' + name + '.js')| import React, { Component } from "react"; | |
| class ClockWatcher extends Component { | |
| canvas = ""; | |
| ctx = ""; | |
| radius = ""; | |
| constructor(props) { | |
| super(props); | |
| this.state = { date: new Date(), |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Document</title> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
| (Linkedin = { | |
| release: '1.0.5 stable', | |
| data: {}, | |
| config: { | |
| autoStart: true, | |
| inspectorSpeed: 5000, | |
| sendSpeed: 4000, | |
| pagerSpeed: 10000, | |
| scrollDownAuto: 600, | |
| debug: true, |
| export default function useLocalStorage(key, initialValue, lifeSpan) { | |
| const [storedValue, setStoredValue] = useState(() => { | |
| try { | |
| const item = window.localStorage.getItem(key); | |
| const stampedValue = JSON.parse(item) | |
| const JSONValue = stampedValue | |
| && stampedValue.expire > Date.now() | |
| && JSON.parse(stampedValue.JSONValue) | |
| return JSONValue || initialValue; |
| export default function longPressEvents(callback, ms = 500) { | |
| let timeout = null | |
| const start = () => (timeout = setTimeout(callback, ms)) | |
| const stop = () => timeout && window.clearTimeout(timeout) | |
| return callback ? { | |
| onMouseDown: start, | |
| onMouseUp: stop, | |
| onMouseLeave: stop, |
| export const getContrastColor = function (bgColor) { | |
| var color = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor | |
| var r = parseInt(color.substring(0, 2), 16) // hexToR | |
| var g = parseInt(color.substring(2, 4), 16) // hexToG | |
| var b = parseInt(color.substring(4, 6), 16) // hexToB | |
| var uiColors = [r / 255, g / 255, b / 255] | |
| var c = uiColors.map((col) => { | |
| if (col <= 0.03928) { return col / 12.92 } | |
| return Math.pow((col + 0.055) / 1.055, 2.4) |
| import React, { useEffect, useRef, useState } from 'react' | |
| import './LazyImage.scss' | |
| const LazyImage = (props) => { | |
| const [ isLoaded, setIsLoaded ] = useState(false) | |
| const [ isVisible, setIsVisible ] = useState(false) | |
| const { src, alt, width, height, className } = props | |
| const placeHolderStyle = {paddingBottom: `${(height / width) * 100}%`} | |
| const imageRef = useRef() |
| #!/usr/bin/python | |
| from urlparse import urlparse, parse_qs | |
| from PIL import Image | |
| import os | |
| import json | |
| print "Content-Type: application/json" | |
| print "" |