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')
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (Linkedin = { | |
| release: '1.0.5 stable', | |
| data: {}, | |
| config: { | |
| autoStart: true, | |
| inspectorSpeed: 5000, | |
| sendSpeed: 4000, | |
| pagerSpeed: 10000, | |
| scrollDownAuto: 600, | |
| debug: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| from urlparse import urlparse, parse_qs | |
| from PIL import Image | |
| import os | |
| import json | |
| print "Content-Type: application/json" | |
| print "" |
The popular open-source contract for web professionals by Stuff & Nonsense
- Originally published: 23rd December 2008
- Revised date: March 15th 2016
- Original post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requires -version 4 | |
| <# | |
| .SYNOPSIS | |
| <Overview of script> | |
| .DESCRIPTION | |
| <Brief description of script> | |
| .PARAMETER <Parameter_Name> | |
| <Brief description of parameter input required. Repeat this attribute if required> |
OlderNewer