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
| const inBrowser = typeof window !== 'undefined' | |
| const inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform | |
| const weexPlatform = inWeex && WXEnvironment.platform.toLowerCase() | |
| const UA = inBrowser && window.navigator.userAgent.toLowerCase() | |
| const isIE = UA && /msie|trident/.test(UA) | |
| const isIE9 = UA && UA.indexOf('msie 9.0') > 0 | |
| const isEdge = UA && UA.indexOf('edge/') > 0 | |
| const isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android') | |
| const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios') |
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 cacheAsync = fn => { | |
| const cached = {}; | |
| return async (...args) => { | |
| const key = args.join('-'); | |
| if (cached[key] === undefined) { | |
| cached[key] = await fn(...args); | |
| } | |
| return cached[key]; |
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 debounce = (fn, delay = 0) => { | |
| let id; | |
| return (...args) => { | |
| if (id) { | |
| clearTimeout(id); | |
| } | |
| id = setTimeout(fn, delay, ...args); | |
| return id; | |
| }; | |
| }; |
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
| https://unsplash.it/200/200 | |
| ### | |
| https://picsum.photos/200/300 | |
| ### | |
| https://unavatar.now.sh/ |
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
| https://unsplash.it/200/200 | |
| ### | |
| https://picsum.photos/200/300 |
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
| function takeOverConsole(){ | |
| var console = window.console | |
| if (!console) return | |
| function intercept(method){ | |
| var original = console[method] | |
| console[method] = function(){ | |
| // do sneaky stuff | |
| if (original.apply){ | |
| // Do this for normal browsers | |
| original.apply(console, arguments) |
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
| .grid { | |
| display: grid; | |
| grid-template-columns: repeat(7, minmax(0, 1fr)); | |
| } |
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
| npx crontab-ui |
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
| wget -O /tmp/wallpaper.jpg https://unsplash.it/2560/1440/?random | |
| gsettings set org.gnome.desktop.background picture-uri file:///tmp/wallpaper.jpg |
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
| const toCamelCase = str => { | |
| let s = | |
| str && | |
| str | |
| .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) | |
| .map(x => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase()) | |
| .join(''); | |
| return s.slice(0, 1).toLowerCase() + s.slice(1); | |
| }; | |
| toCamelCase('some_database_field_name'); // 'someDatabaseFieldName' |