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
exports.handler = (context, event, callback) => { | |
const propId = parseInt(event.propId.trim()); | |
console.log('propId, ', propId); | |
if (!(propId > 0 && propId < 6)) return callback("That's not a valid option, try again!"); | |
return callback(null, props[propId]); | |
}; | |
const props = { |
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 isShiftable = <T>(arr: T[]): arr is { shift(): T } & Array<T> => arr.length > 0; |
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 { useState, useEffect } from 'react' | |
const useDebounce = <T>(value: T, delay: number): T => { | |
const [debouncedValue, setDebouncedValue] = useState<T>(value) | |
useEffect(() => { | |
const handler = setTimeout(() => setDebouncedValue(value), delay) | |
return () => clearTimeout(handler) | |
}, [value, delay]) |
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 { useEffect, useState } from 'react'; | |
function useDrop(ref, onLoad = () => {}) { | |
const [uploading, setUploading] = useState(false); | |
const [isOver, setOver] = useState(false); | |
const stopDefault = e => { | |
e.preventDefault(); | |
e.stopPropagation(); | |
}; | |
const dragOverHandler = e => { |
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
document.querySelectorAll('.torro_element_radio input[id$="0"]').forEach((el) => el.checked = true); | |
document.querySelectorAll('.torro_element_checkbox input[id$="0"]').forEach((el) => el.checked = true); | |
document.querySelector('textarea').value = 'durr'; | |
document.querySelector('input[type="submit"]').click(); |
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, { Fragment, Component } from 'react'; | |
import Helmet from 'react-helmet'; | |
import ReactMarkdown from 'react-markdown'; | |
import styles from './styles.scss'; | |
const importAll = (r) => r.keys().map(r); | |
const markdownFiles = importAll(require.context('./posts', false, /\.md$/)) | |
.sort() | |
.reverse(); |
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
// Example from Webpack docs here: https://webpack.js.org/guides/dependency-management/#context-module-api | |
function importAll (r) { | |
r.keys().forEach(r); | |
} | |
importAll(require.context('../components/', true, /\.js$/)); | |
// That's a little confusing... we're taking the require context (r), and then calling itself on each key? Oh right! | |
// Because r is actually this... | |
// ƒ webpackContext(req) { |
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
console.log(markdownContext.keys()); | |
/* Console | |
(4) ["./2017-01-1.md", "./2017-12-11.md", "./2018-01-08.md", "./2018-2-2.md"] | |
*/ |
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 markdownContext = require.context('./posts', false, /\.md$/); | |
console.log(markdownContext); | |
/* console | |
ƒ webpackContext(req) { | |
return __webpack_require__(webpackContextResolve(req)); | |
} | |
*/ |
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, { Fragment, Component } from 'react'; | |
import ReactMarkdown from 'react-markdown'; | |
import source from './posts/2018-01-08.md'; | |
class WhatsNew extends Component { | |
state = { | |
post: null, | |
} |
NewerOlder