A tiny ~150-byte polyfill for Promise.prototype.finally
.
Useful for browsers that support Promise but not the .finally()
method.
npm install finally-polyfill
MIT License | |
Copyright (c) 2021 Daniel Ethridge | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
#!/usr/bin/env ruby | |
# gem install active_support | |
require 'active_support/inflector' | |
require 'active_support/core_ext/string' | |
# gem install webrick (only ruby3) | |
require 'webrick' | |
# gem install mechanize |
/* | |
The following are examples of quirky and/or funny | |
JavaScript "gotchas". This file isn't meant to be | |
run in its totality. Rather, each section that is | |
deliniated with "// === //" style comments should | |
be run separately, using a browser's dev console. | |
I suggest trying these snippets on localhost | |
or "example.com" in order to see some of the | |
"phantom domain" image and iframe examples. |
//take a joi object and return a string that is actually ok to display on a front-end | |
import _ from 'lodash'; | |
function joiToEnglish(joiErr){ | |
return _ | |
.chain(joiErr.details) | |
.reduce((collected, detail) => { | |
collected[detail.context.key] = collected[detail.context.key] || []; | |
collected[detail.context.key].push(detail.message.replace(`"${detail.context.key}"`, '')); |
This is a ServiceWorker template to turn small github pages into offline ready app.
Whenever I make small tools & toys, I create github repo and make a demo page using github pages (like this one).
Often these "apps" are just an index.html
file with all the nessesary CSS and JavaScript in it (or maybe 2-3 html/css/js
files). I wanted to cache these files so that I can access my tools offline as well.
Make sure your github pages have HTTPS enforced, you can check Settings > GitHub Pages > Enforce HTTPS
of your repository.
This guide assumes you have the emmet
and language-babel
packages already installed in Atom
keymap.cson
file by clicking on Atom -> Keymap…
in the menu bar'atom-text-editor[data-grammar~="jsx"]:not([mini])':
Can't share the complete code because the app's closed source and still in stealth mode, but here's how I'm using React Router and Redux in a large app with server rendering and code splitting on routes.
addReducers()
callback available to the getComponents()
method of
each React Router route. Each route is responsible for adding any Redux
reducers it needs when it's loaded. (This isn't really necessary on the