- ES6 Katas
- Flexbox Froggy
- Haven’t used this one yet, but it’s TypeScript katas, https://mycodekatas.github.io/typescript.html
- Not a Kata per se, but still good, Flexbox Zombies
This file contains 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
interface Association<TKey, TValue> { | |
key: TKey; | |
info: TValue; | |
} | |
interface StringKeyInfo { | |
keyIndexes: Array<Association<string, number>>; | |
keyIsSet: Array<Association<string, boolean>>; | |
} |
This file contains 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
<style> | |
body { | |
background-image: linear-gradient(transparent 0px, transparent 1px, rgb(255, 255, 255) 1px, rgb(255, 255, 255) 20px), linear-gradient(to right, rgb(54, 69, 79) 0px, rgb(54, 69, 79) 1px, rgb(255, 255, 255) 1px, rgb(255, 255, 255) 20px); | |
background-position: 1.1875rem; | |
background-size: 1.25rem 1.25rem; | |
background-attachment: fixed; | |
} | |
</style> |
This file contains 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
// In response to https://twitter.com/housecor/status/930108010558640128 | |
function doubleAfter2Seconds(x) { | |
return new Promise(resolve => { | |
resolve(x * 2); | |
}, 2000); | |
} | |
async function addAsync(x) { | |
const { a, b, c } = await Promise.all([ | |
doubleAfter2Seconds(10), |
This file contains 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 getActiveTab() { | |
return new Promise((resolve, reject) => { | |
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { | |
const activeTab = tabs.find(t => t.active); | |
resolve(activeTab); | |
}); | |
}); | |
} |
This file contains 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
// Just having fun creating some polyfills. | |
/** | |
* A polyfill for Object.prototype.entries. | |
* | |
* @returns {[string, any][]} An array of tuples where each tuple is a key/value pair. | |
*/ | |
Object.prototype.entries = Object.prototype.entries || function() { | |
const obj = this; |
This file contains 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 expect(actual) { | |
function prettyJSON(objectToSerialize) { | |
return JSON.stringify(objectToSerialize, null, '\t') | |
} | |
return { | |
toBe(expected) { | |
if (actual === expected) { | |
console.log('✅ Pass') | |
} else { |
This file contains 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
module.exports = { | |
entry: { | |
acme_co_es5: [ | |
"@babel/polyfill", | |
"./public/javascripts/webpack_entry_points/acme_co.js" | |
] | |
}, | |
resolve: { | |
extensions: [".js", ".jsx"] | |
}, |
This file contains 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
/** | |
* Hook for drag attaching drag and drop functionality to a DOM element | |
* | |
* @param {object} props | |
* @param {Function} props.onDragOver The handler that runs when the dragover event is fired. | |
* @param {Function} props.onDragExit The handler that runs when the dragexit/dragleave events are fired. | |
* @param {Function} props.onDrop The handler that runs when the drop event is fired. | |
*/ | |
export function useDragAndDrop({ onDragOver, onDragExit, onDrop }) { | |
const [element, setElement] = useState(null); |