React hook to catch page unload event in Nextjs and app router to prevent unsaved data loss. Example
const listener = usePageUnloadGuard();
listener.onBeforeUnload = () => !!someCondition;React hook to catch page unload event in Nextjs and app router to prevent unsaved data loss. Example
const listener = usePageUnloadGuard();
listener.onBeforeUnload = () => !!someCondition;| version: '2.1' | |
| services: | |
| php: | |
| tty: true | |
| build: | |
| context: . | |
| dockerfile: tests/Docker/Dockerfile-PHP | |
| args: | |
| version: cli | |
| volumes: |
adapted from this blog
# YAML
name: Jon# YAML
object:These commands generate and use private keys in unencrypted binary (not Base64 “PEM”) PKCS#8 format. The PKCS#8 format is used here because it is the most interoperable format when dealing with software that isn't based on OpenSSL.
OpenSSL has a variety of commands that can be used to operate on private
key files, some of which are specific to RSA (e.g. openssl rsa and
openssl genrsa) or which have other limitations. Here we always use
| # | |
| # Acts as a nginx HTTPS proxy server | |
| # enabling CORS only to domains matched by regex | |
| # /https?://.*\.mckinsey\.com(:[0-9]+)?)/ | |
| # | |
| # Based on: | |
| # * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html | |
| # * http://enable-cors.org/server_nginx.html | |
| # | |
| server { |
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
| --log_gc (Log heap samples on garbage collection for the hp2ps tool.) | |
| type: bool default: false | |
| --expose_gc (expose gc extension) | |
| type: bool default: false | |
| --max_new_space_size (max size of the new generation (in kBytes)) | |
| type: int default: 0 | |
| --max_old_space_size (max size of the old generation (in Mbytes)) | |
| type: int default: 0 | |
| --max_executable_size (max size of executable memory (in Mbytes)) | |
| type: int default: 0 |
| // data = ctx.getImageData(0, 0, image.width, image.height).data; | |
| // | |
| // mediancut(data, colorCount); | |
| // returns [[255,55,255], [233,34,233], [144,34,233], [89,34,233]]; | |
| function mediancut(data, n){ | |
| var boxes = [getBoundingBox(data)]; | |
| if(n !== 1){ | |
| boxes = cut(boxes[0]); | |
| while(boxes.length < n){ |